Diffusers
English
stable-diffusion
stable-diffusion-diffusers
inpainting
art
artistic
anime
absolute-realism
Run this model with HF Jobs
Run diffusers/tools on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/diffusers/tools. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/diffusers/tools on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use diffusers/tools with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use diffusers/tools with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("diffusers/tools", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
Commit ·
69f6fc2
1
Parent(s): db33e16
add local run script
Browse filesFiles changed (2)
- run_k_diffusion.pyAdded+38
- run_local.pyAdded+18
1234567891011121314151617181920212223242526272829303132333435363738#!/usr/bin/env python3#from diffusers import DiffusionPipeline, StableDiffusionPipeline, KDPM2DiscreteScheduler, KDPM2AncestralDiscreteScheduler, HeunDiscreteSchedulerfrom diffusers import DiffusionPipeline, StableDiffusionPipeline, HeunDiscreteSchedulerimport torchimport os
seed = 33inference_steps = 25
old_pipe = DiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", custom_pipeline="sd_text2img_k_diffusion")old_pipe = old_pipe.to("cuda")
for prompt in ["astronaut riding horse", "whale falling from sky", "magical forest", "highly photorealistic picture of johnny depp"]: # for sampler in ["sample_dpm_2_ancestral", "sample_dpm_2", "sample_heun"]:# for sampler in ["heun", "sample_dpm_2_ancestral", "sample_dpm_2"]: for sampler in ["sample_heun"]: old_pipe.set_sampler(sampler) torch.manual_seed(0) image = old_pipe(prompt, num_inference_steps=inference_steps).images[0] folder = f"a_{'_'.join(prompt.split())}" os.makedirs(f"/home/patrick_huggingface_co/images/{folder}", exist_ok=True) image.save(f"/home/patrick_huggingface_co/images/{folder}/{sampler}.png")
pipe = StableDiffusionPipeline(**old_pipe.components) pipe = pipe.to("cuda")
# if sampler == "sample_dpm_2":# pipe.scheduler = KDPM2DiscreteScheduler.from_config(pipe.scheduler.config)# elif sampler == "sample_dpm_2_ancestral":# pipe.scheduler = KDPM2AncestralDiscreteScheduler.from_config(pipe.scheduler.config) if sampler == "sample_heun": pipe.scheduler = HeunDiscreteScheduler.from_config(pipe.scheduler.config)
torch.manual_seed(0) image = pipe(prompt, num_inference_steps=inference_steps).images[0]
image.save(f"/home/patrick_huggingface_co/images/{folder}/hf_{sampler}.png") break123456789101112131415161718#!/usr/bin/env python3from diffusers import DiffusionPipelineimport torchimport os
import sys
local_path = sys.argv[1]local_path = os.path.abspath(local_path)
prompts = ["astronaut on mars", "Barack Obama smiling with a big grin"]
pipe = DiffusionPipeline.from_pretrained(local_path, torch_dtype=torch.float16)pipe = pipe.to("cuda")
for prompt in prompts: image = pipe(prompt).images[0] image.save(f"/home/patrick_huggingface_co/images/a_{'_'.join(prompt.split())}.png")run_k_diffusion.pyAdded+38
run_local.pyAdded+18