Repolode
lucidrains

lucidrains/denoising-diffusion-pytorch

A PyTorch implementation of Denoising Diffusion Probabilistic Models for training image (and 1D sequence) generative models.

Stars
10,710
Forks
1,283
Open issues
169
Last commit
23 days ago

What is it?

This project is a PyTorch implementation of Denoising Diffusion Probabilistic Models, a generative modeling approach that learns to reverse a gradual noising process. It provides a U-Net backbone along with a GaussianDiffusion class that handles the forward noising, the training loss, and sampling from the trained model.

Beyond the core image pipeline, it includes a Trainer class that takes a folder of images and handles data loading, training loops, periodic sample logging, checkpointing, and optional FID calculation. It also supports Hugging Face Accelerate for multi-GPU training, mixed precision via amp, and DDIM-style faster sampling with fewer timesteps. A 1D U-Net and 1D diffusion variant is included for sequence data, and an XMWrapper adds multi-candidate loss calculation.

The library is installable from PyPI and is aimed at researchers and developers who want a readable, hackable reference implementation for experimenting with diffusion models.

Key features

  • 01Implements the DDPM training objective and sampling procedure in PyTorch.
  • 02Provides a configurable U-Net backbone with optional flash attention.
  • 03A Trainer class handles folder-based image datasets, checkpoints and sample logging.
  • 04Supports multi-GPU training through Hugging Face Accelerate and mixed precision.
  • 05Includes DDIM-style sampling with fewer steps and FID evaluation during training.
  • 06Offers a 1D U-Net and diffusion variant for sequence data.

Use cases

  • Training a small image generator on a custom folder of images.
  • Studying or modifying the core diffusion training and sampling code.
  • Prototyping diffusion models for one-dimensional sequence data.
  • Running multi-GPU diffusion training experiments with Accelerate.

Quick start

  1. 1

    Install the package from PyPI

    pip install denoising_diffusion_pytorch
  2. 2

    Build a model and diffusion object, then train on a folder of images with the Trainer class

  3. 3

    Start training

    trainer.train()

Things to know

  • Training on realistic image sizes requires a GPU and a lot of time (the example uses 700000 steps).

Topics

FAQ

What is denoising-diffusion-pytorch?
A PyTorch implementation of Denoising Diffusion Probabilistic Models for training image (and 1D sequence) generative models. This project is a PyTorch implementation of Denoising Diffusion Probabilistic Models, a generative modeling approach that learns to reverse a gradual noising process. It provides a U-Net backbone along with a GaussianDiffusion class that handles the forward noising, the training loss, and sampling from the trained model.
Is denoising-diffusion-pytorch free to use? What license does it have?
denoising-diffusion-pytorch is open source under the MIT license. Check the license terms before using it in commercial products.
Is denoising-diffusion-pytorch still maintained?
Actively maintained. The last commit to denoising-diffusion-pytorch was on Sep 29, 2026.
What can I use denoising-diffusion-pytorch for?
Training a small image generator on a custom folder of images. Studying or modifying the core diffusion training and sampling code. Prototyping diffusion models for one-dimensional sequence data. Running multi-GPU diffusion training experiments with Accelerate.
How do I install denoising-diffusion-pytorch?
Install the package from PyPI: pip install denoising_diffusion_pytorch Build a model and diffusion object, then train on a folder of images with the Trainer class Start training: trainer.train()
Where can I get denoising-diffusion-pytorch?
The source code and installation instructions are on GitHub: https://github.com/lucidrains/denoising-diffusion-pytorch

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects