denoising-diffusion-pytorch
Implementation of Denoising Diffusion Probabilistic Model in Pytorch
This repository is a PyTorch implementation of a technique called Denoising Diffusion Probabilistic Models, often shortened to DDPM. The core idea is a way to generate new images by learning how to reverse a gradual noise-adding process. You take real images, slowly corrupt them with random noise over many steps until they look like static, then train a neural network to undo that corruption step by step. Once trained, the network can start from pure noise and work backwards to produce a brand-new, realistic image.
The library is installable as a standard Python package and exposes two main components. The first is a U-Net model, which is the neural network architecture that does the heavy lifting of predicting and removing noise at each step. The second is a GaussianDiffusion wrapper that handles the full noising and denoising schedule around that model. You pass your training images to it, call a training step to get a loss value, and after enough iterations the model learns to synthesize new images at the same resolution.
For simpler workflows, the package includes a Trainer class that you point at a folder of images. It handles batching, mixed-precision arithmetic (which speeds up training on modern graphics cards), and periodic saving of generated samples and model checkpoints to a results folder. Multi-GPU training is supported through an integration with the Accelerate library: you run a short configuration command once, then launch your training script with a single line change.
Beyond images, the library also supports generating sequences of numbers in one dimension, useful for time-series or audio-like data. This 1D variant follows the same structure: a 1D U-Net, a diffusion wrapper, and a trainer. The author notes that the 1D trainer does not automatically evaluate quality of generated sequences because the meaning of the data varies too much by use case, so adding your own evaluation logic on top is expected.
The project cites a series of academic papers that established and refined the DDPM approach, including work on faster sampling strategies and improved noise schedules. It is a research-oriented implementation aimed at people who want to experiment with or build on top of diffusion-based generation techniques.