Diffusers
English
stable-diffusion
stable-diffusion-diffusers
inpainting
art
artistic
anime
absolute-realism
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
| #!/usr/bin/env python3 | |
| from diffusers import StableDiffusionPipeline, DPMSolverSinglestepScheduler, DPMSolverMultistepScheduler, DEISMultistepScheduler, HeunDiscreteScheduler | |
| import time | |
| from huggingface_hub import HfApi | |
| import torch | |
| import sys | |
| path = sys.argv[1] | |
| api = HfApi() | |
| start_time = time.time() | |
| pipe = StableDiffusionPipeline.from_pretrained(path, torch_dtype=torch.float16) | |
| pipe.scheduler = HeunDiscreteScheduler.from_config(pipe.scheduler.config) | |
| pipe = pipe.to("cuda") | |
| prompt = "a highly realistic photo of green turtle" | |
| generator = torch.Generator(device="cuda").manual_seed(0) | |
| image = pipe(prompt, generator=generator, num_inference_steps=25).images[0] | |
| print("Time", time.time() - start_time) | |
| path = "/home/patrick_huggingface_co/images/aa.png" | |
| image.save(path) | |
| api.upload_file( | |
| path_or_fileobj=path, | |
| path_in_repo=path.split("/")[-1], | |
| repo_id="patrickvonplaten/images", | |
| repo_type="dataset", | |
| ) | |
| print("https://huggingface.co/datasets/patrickvonplaten/images/blob/main/aa.png") | |