Hugging Face Diffusers

🤗 Diffusers

The library of pretrained diffusion models for generating images, audio and video, with swappable generation pipelines and schedulers.

ActiveMediumv0.43.0Apache-2.0Generative AI

Official documentationTry the examples

Basic information

NameHugging Face Diffusers
Full name🤗 Diffusers
CategoryGenerative AI
DeveloperHugging Face
Release yearNot specified
Official websitegithub.com/huggingface/diffusers
GitHub repositoryhuggingface/diffusers
Official documentationNot specified
Package on PyPIdiffusers
LicenseApache-2.0 (PyPI license)
Project statusActive Had a release in the last 12 months
Latest version12 November 2026 (version 0.43.0)
Programming languagePython
Operating systemsOS Independent (as declared by the package on PyPI)
Required Python version>=3.11.0
Difficulty levelMedium

Data last checked: 21 November 2026 — source: PyPI JSON API (2026-11-21)

Overview

Diffusers separates ready-made pipelines, models (UNet and Transformers) and schedulers, so each part can be swapped. It supports Stable Diffusion and other models published on the Hub, and fine-tuning through LoRA and DreamBooth.

Running large models needs a GPU with enough memory, and model licenses vary from model to model, so check each model's card.

When to choose it? Choose it to generate images programmatically and to try and fine-tune diffusion models.

Uses

Main uses

  • Text-to-image generation
  • Image editing and inpainting
  • Fine-tuning with LoRA
  • Teaching diffusion models

Scientific fields

  • Generative AI
  • Design
  • Research

Suitable project types

  • An image generator with a custom style

Research applications

  • Experiments with diffusion schedulers and architectures

Diffusion models and image generation

Technical features

A feature is shown as "Supported" only if it is documented in the library's official documentation; anything we have not verified is shown as "Not specified".

CPU supportSupportedPossible but very slow for large models.
GPU supportSupported
CUDA compatibilitySupported
Distributed training or computingPartial or through an add-on
Automatic differentiation (Autodiff)SupportedThrough PyTorch.
Model deploymentPartial or through an add-on
Pre-trained modelsSupported
Supported data typesImages, text, audio, tensors
Integration with other librariesPyTorch, Hugging Face Transformers, PEFT
Flexibility (editorial estimate)High
Performance (editorial estimate)Depends on the GPU
Community (editorial estimate)Large
Documentation quality (editorial estimate)Excellent documentation

Installation and running

Shell
pip install diffusers

Compatibility: Python >=3.11.0 — according to the package data on PyPI, checked on 21 November 2026

Installing inside a virtual environment (venv or conda) is recommended. If you need compatibility with a specific CUDA version or operating system, refer to the official documentation, because this information changes with every release.

Code examples

Examples marked "Run and tested" were actually run, with their output, test date and library versions recorded; the others need a GPU or model downloads, so they were not run in the test environment.

MediumGenerating an image from text with DiffusersNot run

Goal: Loading a diffusion pipeline and generating an image.

Python — example.py
import torch
from diffusers import DiffusionPipeline

pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2-1-base", torch_dtype=torch.float16)
pipe = pipe.to("cuda")
image = pipe("a watercolor painting of a robot reading a book", num_inference_steps=25).images[0]
image.save("robot.png")

Code explanation

DiffusionPipeline.from_pretrained loads all the model's components (the text encoder, the U-Net, the scheduler and the decoder). It needs a GPU with enough memory and a download of several gigabytes, and some models require accepting their license on Hugging Face. Not run in the test environment.

Requirements

Shell
pip install diffusers transformers accelerate torch

How to run

Save the code in a file example.py then run it:

Shell
python example.py

This example was not run in the test environment: needs a GPU and a download of the model weights. Check it against the library documentation before relying on it.

Example page
ResearchThe forward diffusion process with a DDPM schedulerRun and tested

Goal: Seeing how the scheduler adds noise gradually, as in the DDPM paper.

Python — example.py
import torch
from diffusers import DDPMScheduler

torch.manual_seed(0)
sched = DDPMScheduler(num_train_timesteps=1000, beta_schedule="linear")
x0 = torch.randn(1, 3, 32, 32)
noise = torch.randn_like(x0)
for t in [0, 250, 500, 999]:
    xt = sched.add_noise(x0, noise, torch.tensor([t]))
    corr = torch.corrcoef(torch.stack([x0.flatten(), xt.flatten()]))[0, 1].item()
    print(f"t={t:4d}  sqrt(alpha_bar)={sched.alphas_cumprod[t].sqrt().item():.4f}  corr(x0,xt)={corr:.3f}")

Code explanation

DDPMScheduler computes the β schedule and the ᾱ_t coefficients. The add_noise function applies x_t = √ᾱ_t·x₀ + √(1−ᾱ_t)·ε. We measure how much of the original signal remains at different steps; this part needs no trained weights.

Requirements

Shell
pip install diffusers torch

How to run

Save the code in a file example.py then run it:

Shell
python example.py

Output recorded during testing

t=   0  sqrt(alpha_bar)=0.9999  corr(x0,xt)=1.000
t= 250  sqrt(alpha_bar)=0.7221  corr(x0,xt)=0.728
t= 500  sqrt(alpha_bar)=0.2789  corr(x0,xt)=0.293
t= 999  sqrt(alpha_bar)=0.0064  corr(x0,xt)=0.022

This example was actually run and tested on 21 November 2026 on a CPU — diffusers 0.43.0, torch 2.15.0, python 3.13.18

Example page

All Hugging Face Diffusers examples in the Code Explorer

Pros

  • A clear modular design
  • Many models on the Hub

Limitations

  • Needs a powerful GPU for large models
  • Model licenses differ

References and verification

  • Package page on PyPI (source of the version, licence and release date) Checked directly

    https://pypi.org/project/diffusers/

    Checked on: 21 November 2026 — version checked: 0.43.0 — reviewed by: the DLArabic team

  • Official website A link the package officially declares on PyPI

    https://github.com/huggingface/diffusers

    Checked on: 21 November 2026 — reviewed by: the DLArabic team

  • Official repository A link the package officially declares on PyPI

    https://github.com/huggingface/diffusers

    Checked on: 21 November 2026 — reviewed by: the DLArabic team

History of verified versions

VersionRelease dateChecked on
0.43.012 November 202621 November 2026

Page information last reviewed: 21 November 2026. The description was written originally for the encyclopedia and is not copied from the official websites.

Report information that needs updating