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 safetensors.torch import load_file as safe_load_file | |
| import time | |
| import sys | |
| direct_on_gpu = bool(int(sys.argv[1])) | |
| if direct_on_gpu: | |
| start_time = time.time() | |
| checkpoint = safe_load_file("/home/patrick_huggingface_co/stable-diffusion-v1-4/unet/diffusion_pytorch_model.safetensors", device=0) | |
| print("Directly on GPU", time.time() - start_time) | |
| else: | |
| start_time = time.time() | |
| checkpoint = safe_load_file("/home/patrick_huggingface_co/stable-diffusion-v1-4/unet/diffusion_pytorch_model.safetensors") | |
| checkpoint = {k: v.to("cuda:0") for k, v in checkpoint.items()} | |
| print("On CPU", time.time() - start_time) | |