Model or dataset
huggingface/diffusers avatar
huggingface/diffusers

huggingface/diffusers: a PyTorch toolbox for running and training diffusion models

🤗 Diffusers: State-of-the-art diffusion models for image, video, and audio generation in PyTorch.

34,620 stars7,353 forksPythonApache-2.0

At a glance

What is it?
Diffusers is Hugging Face's Apache-2.0 Python library for pretrained diffusion pipelines, interchangeable schedulers and reusable model blocks. It is built for people who want to load a checkpoint in a few lines, then take the pipeline apart when they need to.
Who is it for?
Adopt diffusers if you are writing Python that needs to load a pretrained diffusion checkpoint, swap its scheduler, or train on top of the model blocks rather than calling a hosted endpoint. Skip it if you want a finished application: the repository ships pipelines, not a GUI, and the README points at the Hub for checkpoints.
Can I use it commercially?
Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 4 days ago.
What is it written in?
Mainly Python, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 27, 2026, and from our analysis. They are not legal advice.

DEEP OPEN-SOURCE ANALYSIS

What diffusers solves, and who ends up using it

Running a diffusion model is not one problem, it is three. You need the weights, the noise schedule that turns random latents into an image over a fixed number of steps, and the sampling loop that ties them together. Most projects that wrap diffusion models fuse all three into a single call, which is convenient until you want a different scheduler, a different number of steps, or a different checkpoint.

Diffusers separates them. The README describes three core components: diffusion pipelines for inference, interchangeable noise schedulers for different diffusion speeds and output quality, and pretrained models that can be used as building blocks and combined with schedulers to create your own end-to-end diffusion systems. That split is the whole design argument, and it is stated explicitly in the project's philosophy links: usability over performance, simple over easy, customizability over abstractions.

The audience follows from that. If you are a Python developer who wants to generate an image from a prompt in a script, the pipeline layer is enough. If you are training or fine-tuning, or if you are testing whether a different sampler changes your output, you drop one level and wire the model and scheduler yourself. The README also mentions audio and 3D structures of molecules alongside images, so the same abstractions are meant to stretch past the text-to-image case that most people arrive for.

Pipelines, schedulers and models: how the pieces fit together

A pipeline is the top-level object. It owns the tokenizer or text encoder, the denoising network, the scheduler, and the decode step, and it exposes a callable that takes a prompt and returns a result object. The README's quickstart uses DiffusionPipeline.from_pretrained with a model id, moves the object to a CUDA device, and reads the generated image off the .images attribute of the returned object.

The scheduler is the piece that is genuinely swappable. It decides how many timesteps the denoising loop runs and how each step maps a predicted noise residual back to a slightly less noisy sample. Because the README frames schedulers as interchangeable for different diffusion speeds and output quality, the intended workflow is that you change the scheduler without changing the weights.

The model layer is the lowest and most explicit. The README's second example loads DDPMScheduler and UNet2DModel from the same checkpoint, sets the timestep count, draws a noise tensor, and then writes the sampling loop by hand: call the model to get a noisy residual, pass that plus the timestep and the current input to scheduler.step, and take .prev_sample as the next input. That loop is the mechanism the pipeline hides. Seeing it written out is the fastest way to understand what the library is doing on your behalf, and it is also the escape hatch when a pipeline does not fit your case.

Installing diffusers and generating a first image

The README recommends installing into a virtual environment, from PyPI or Conda, and points at the official PyTorch documentation for installing PyTorch itself. The pip form pulls the torch extra:

bash
pip install --upgrade diffusers[torch]

The community-maintained Conda package is the alternative:

sh
conda install -c conda-forge diffusers

That is the whole install. There is no service to start and no config file to write. On Apple Silicon the README does not give inline instructions; it links to a separate guide on using Stable Diffusion on MPS, so read that page before assuming CUDA-specific flags translate.

For a first real use, the README's quickstart loads a pretrained checkpoint by id, casts it to half precision, moves it to the GPU, and calls it with a prompt:

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]

What you should see is a PIL image on the last line. Two things to watch. The dtype argument is what the README uses, not torch_dtype, so copy it as written for this version. And the first call downloads the checkpoint, which is the slow part; subsequent runs read from the local cache. The README says you can browse the Hub for more than 30,000 checkpoints, and that the model id in from_pretrained is what selects one.

Where diffusers is the wrong tool

The library is a Python toolbox, and the README does not present it as anything else. There is no bundled interface, no server, and no scheduling layer for serving requests. If your goal is to let a non-programmer type a prompt and get an image, diffusers is a dependency you would wrap, not a product you install.

The second limitation is the one the project names itself. The philosophy links list usability over performance as a design choice, which is an admission that the convenience layer is not tuned for throughput. The optimization documentation exists precisely because the default path is not the fast path. If you need the last increment of speed or the smallest possible memory footprint, you are expected to read that guide and apply the techniques yourself.

The third is version coupling. The quickstart uses DiffusionPipeline, a generic loader, but the README's documentation table lists separate guides for loading pipelines, models and schedulers, and the release notes for v0.40.0, v0.39.0 and v0.38.0 each mention new pipelines. That cadence means pipeline class names and arguments move between releases. Code that pins nothing will eventually break on an upgrade, and the README does not document a rollback path.

Diffusers compared with calling a hosted inference endpoint

The closest alternative for many teams is not another Python library, it is a hosted inference API, where you send a prompt and receive an image without owning the weights or the sampling loop. The difference in approach is where the model lives and who controls the schedule.

With diffusers, the checkpoint is downloaded to your machine and the denoising loop runs on your hardware. You choose the scheduler, the timestep count and the precision, and the README's manual loop example shows exactly how far down that control goes. Nothing leaves your process, and there is no per-call cost beyond your own compute. The trade is that you supply the GPU, the memory and the maintenance.

With a hosted endpoint, the sampling loop is someone else's code. You get a prompt in and an image out, but you cannot swap the scheduler or inspect the intermediate latents, and the model version is whatever the service offers. For a prototype or a low-volume internal tool, that is usually the right trade. For fine-tuning, for research on sampling behaviour, or for anything that must run without network access to a third party, it is not, and that is the case diffusers is built for.

Upgrade cost, licence and what to check before pinning

Diffusers ships under Apache-2.0, and the README carries the standard Apache header with the usual warranty disclaimer. That is a permissive licence, but the licence covers the library, not the checkpoints you load with it. Model weights on the Hub can carry their own terms, and the README says nothing about them; check the model card for whichever checkpoint you use, and treat the library licence and the model licence as two separate questions.

The upgrade cost is visible in the release history. Three releases landed between 2026-05-01 and 2026-08-20, and each one advertises new pipelines alongside core library improvements. New pipelines are additive, so they cost you nothing unless you want them. Core library improvements are the risk, because they can touch shared loading code. The repository's own Makefile shows how tightly the internals are checked: the quality target runs ruff, a doc-builder style check, and scripts that verify the doc table of contents and the dummy objects, and repo-consistency runs four separate check scripts. That is a signal that the project takes internal consistency seriously, but it also means the surface area is large enough to need those checks.

The practical move is to pin an exact version in your requirements and read the release notes for the versions between your pin and the one you want before moving. If a pipeline you depend on was renamed, that is where you will find out.

The last push to the repository was on 2026-08-20, the same day as the v0.40.0 release.

Editorial conclusion

Adopt diffusers if you are writing Python that needs to load a pretrained diffusion checkpoint, swap its scheduler, or train on top of the model blocks rather than calling a hosted endpoint. Skip it if you want a finished application: the repository ships pipelines, not a GUI, and the README points at the Hub for checkpoints. Before committing, verify the pipeline class for your target checkpoint exists in the version you pin, and check that your installed PyTorch build matches the device you intend to call .to() on.

Frequently asked questions

How do I install diffusers in Python?

The README recommends a virtual environment and gives two commands: pip install --upgrade diffusers[torch] for the official PyPI package, or conda install -c conda-forge diffusers for the community-maintained Conda package. PyTorch itself is installed separately, following its own documentation.

How do I use diffusers?

Load a pipeline with DiffusionPipeline.from_pretrained using a model id, move it to a device, and call it with a prompt, reading the result from the .images attribute. If you need more control, the README shows loading a scheduler and a model separately and writing the denoising loop yourself.

What is diffusers in AI?

It is Hugging Face's library of pretrained diffusion models for generating images, audio and 3D structures of molecules in PyTorch. The README describes three core components: diffusion pipelines, interchangeable noise schedulers, and pretrained models usable as building blocks.

How do I install diffusers from source?

The README does not give a from-source install procedure. It documents the pip and Conda routes only, and points contributors at the contribution guide for working on the library itself.

Official sources

  1. Official documentation
  2. Official README
  3. Project repository
  4. Release notes
For maintainers

Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/huggingface-diffusers.svg)](https://hysenlabs.com/projects/huggingface-diffusers)
Community notes

Community notes