huggingface /diffusers
🤗 Diffusers: State-of-the-art diffusion models for image, video, and audio generation in PyTorch.
★ 34,894⑂ 7,475👁 220⑃ 8,438● 5,718▤ 96◈ 676
34,894
stars
+4+43
7,475
forks
220
watchers
8,438
prs
5,718
issues
96
releases
676
discussions
README
🤗 Diffusers is the go-to library for state-of-the-art pretrained diffusion models for generating images, audio, and even 3D structures of molecules. Whether you're looking for a simple inference solution or training your own diffusion models, 🤗 Diffusers is a modular toolbox that supports both. Our library is designed with a focus on usability over performance, simple over easy, and customizability over abstractions.
🤗 Diffusers offers three core components:
- State-of-the-art diffusion pipelines that can be run in inference with just a few lines of code.
- Interchangeable noise schedulers for different diffusion speeds and output quality.
- Pretrained models that can be used as building blocks, and combined with schedulers, for creating your own end-to-end diffusion systems.
Installation
We recommend installing 🤗 Diffusers in a virtual environment from PyPI or Conda. For more details about installing PyTorch, please refer to their official documentation.
PyTorch
With pip (official package):
bash
pip install --upgrade diffusers[torch]
With conda (maintained by the community):
sh
conda install -c conda-forge diffusers
Apple Silicon (M1/M2) support
Please refer to the How to use Stable Diffusion in Apple Silicon guide.
Quickstart
Generating outputs is super easy with 🤗 Diffusers. To generate an image from text, use the from_pretrained method to load any pretrained diffusion model (browse the Hub for 30,000+ checkpoints):
python
from diffusers import DiffusionPipeline
import torch
pipeline = DiffusionPipeline.from_pretrained("stable-diffusion-v1-5/stable-diffusion-v1-5", dtype=torch.float16)
pipeline.to("cuda")
pipeline("An image of a squirrel in Picasso style").images[0]
You can also dig into the models and schedulers toolbox to build your own diffusion system:
python
from diffusers import DDPMScheduler, UNet2DModel
from PIL import Image
import torch
scheduler = DDPMScheduler.from_pretrained("google/ddpm-cat-256")
model = UNet2DModel.from_pretrained("google/ddpm-cat-256").to("cuda")
scheduler.set_timesteps(50)
sample_size = model.config.sample_size
noise = torch.randn((1, 3, sample_size, sample_size), device="cuda")
input = noise
for t in scheduler.timesteps:
with torch.no_grad():
noisy_residual = model(input, t).sample
prev_noisy_sample = scheduler.step(noisy_residual, t, input).prev_sample
input = prev_noisy_sample
image = (input / 2 + 0.5).clamp(0, 1)
image = image.cpu().permute(0, 2, 3, 1).numpy()[0]
image = Image.fromarray((image 255).round().astype("uint8"))
image
Check out the Quickstart to launch your diffusion journey today!
How to navigate the documentation
| Documentation | What can I learn? |
|-------------------------------------------------------------------Top issues
#9108can't resume training with quantized base model45 comments · 2024-08-07#5808Inpainting produces results that are uneven with input image43 comments · 2023-11-15#13401Help us profile important pipelines and improve if needed42 comments · 2026-04-03#9924Can we get more schedulers for flow based models such as SD3, SD3.5, and flux40 comments · 2024-11-14#9180Pipeline has no attribute '_execution_device'38 comments · 2024-08-14#9279Support dynamic LoRA loading with `torch.compile` model37 comments · 2024-08-26#7219Add SUPIR Upscaler36 comments · 2024-03-05#5894Error RuntimeError: Invalid buffer size 36 comments · 2023-11-22
Discussions
#14951What is the easiest Diffusers pipeline to start with for a beginner?1 comments · 2026-10-05#14893Real-time serving on diffusers with LTX-2.5 (22B video DiT, single GPU) — notes and two negative results0 comments · 2026-09-28#14857One obsession text encoder3 comments · 2026-09-23#14823A four-layer evidence pattern for apps that persist Diffusers outputs0 comments · 2026-09-20#14813How to generate white background images instead of colorful?3 comments · 2026-09-19#14251[Modular Diffusers] Repo ID to custom path mapping0 comments · 2026-07-20#14173🎬 [Showcase] AI-Generated Anime Short - 'Light in the Ruins'0 comments · 2026-07-12#13912[removed]0 comments · 2026-06-10
Latest release
v0.42.1 — fix component resolution in `from_pretrained` to prevent `trust_remote_code` bypass v0.42.1 2026-10-27This is a security release. See GHSA-4prv-5hj7-c2xr for details. This patch release fixes how a component's declared library name is resolved when loading with from_pretrained. Pipelines and models declare each component as a ["", ""] pair in model_index.json / config.json. This release changes how that library name is resolved across the DiffusionPipeline, AutoModel, and ModularPipeline loading paths, and adds a clearer error when the declared class is not found in the resolved module. All users on 0.42.0 are encouraged to upgrade: pip install diffusers==0.42.1