Skip to content

denoising-diffusion-pytorch

A PyTorch implementation of the denoising diffusion model for generating images, plus a 1D variant.

Stars
10.7k
Forks
1.3k
Licence
MIT
Language
Python
Last update
1 months ago
Type
Library

What it is

This is a Python library that implements Denoising Diffusion Probabilistic Models in PyTorch. Diffusion models learn to generate new data, such as images, by learning to reverse a process that gradually adds noise to training examples. People use it to experiment with or train their own generative models, and to study how the method works.

  • Build a small diffusion model in code and sample images from it after training
  • Train a model on a folder of images using the Trainer class, which writes samples and checkpoints to ./results
  • Wrap a diffusion model in XMWrapper to compute loss over multiple candidates during training
  • Train a 1D sequence diffusion model using Unet1D and GaussianDiffusion1D

Great for

  • Researchers and engineers who want a readable PyTorch reference for diffusion models
  • Developers training a small image generator on their own folder of images
  • People learning how denoising diffusion works by reading and running code
  • Anyone wanting a 1D sequence variant of the same approach

Not ideal for

  • Non-programmers wanting a ready-made image generator with a click-to-use interface, since the README only shows code usage
  • Users needing a supported production product, since the README describes no such guarantees
  • Teams needing large-scale pretrained models, since the README covers training code rather than released weights
Step-by-step guide: how to use denoising-diffusion-pytorchInstall, first run, examples, tips and FAQs

How to get it

  1. 1

    Install with a package manager

    You'll need: Python · PyTorch

    Install from PyPI

    pip install denoising_diffusion_pytorch
  2. 2

    Run it

    • Install the package with pip
    • Create a Unet and GaussianDiffusion model as shown in the Usage section
    • Pass a batch of images to the diffusion model to compute a loss and call backward
    • Call diffusion.sample after training to generate images
  3. 3

    Get the most out of it

    • Use the Trainer class with a folder of images to avoid writing your own training loop
    • Enable amp = True for mixed precision training, as shown in the README
    • Use sampling_timesteps with DDIM-style sampling for faster inference, per the README example
    • Use accelerate config and accelerate launch for multi-GPU training

Downloads

Strengths

  • Short, readable usage examples in the README for both direct and Trainer-based workflows
  • Covers several related papers and options such as DDIM-style faster sampling and multi-GPU training via Accelerate
  • Published under the permissive MIT license

Trade-offs

  • The README is brief on theory and parameter details, so you will likely need the cited papers or the code itself
  • Full training settings in the examples (such as 700000 steps) imply substantial compute, which the README does not quantify
  • Some features like the FID calculation and flash attention depend on options the README mentions without full explanation

How it compares

ProjectStarsTypeLevelUpdatedBest for
denoising-diffusion-pytorch (this)10.7kLibraryintermediate1 months agoResearchers and engineers who want a readable PyTorch reference for diffusion models
Awesome-Diffusion-Models12.4kCurated listbeginner2.3 years agoStudents who want a structured set of introductory material on diffusion models
AI-For-Beginners70.5kLearning resourcebeginner13 days agoBeginners who want a structured, self-paced introduction to AI
awesome-ai-engineering22.5kCurated listbeginner16 days agoDevelopers who want an overview of the AI engineering topics covered in the description
awesome-artificial-intelligence16.8kCurated listbeginner3 months agoSoftware developers who want to learn the foundations behind language models and agents
DALLE2-pytorch11.3kLibraryadvanced2.5 years agoMachine learning researchers replicating or studying the DALL-E 2 architecture

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.