This repository contains the implementation of a Denoising Diffusion Probabilistic Model (DDPM) trained on the MNIST dataset.
The dependencies for this project are managed via pyproject.toml.
Github repo: https://github.com/locitran/diffusion
Three main components to keep in mind:
-
U-Net architecture + time embedding + attention block. A sketch is here
-
Annealing sampling in DDPM:
- Training the DDPM model using the variational lower bound (or noise matching):
git clone https://github.com/locitran/diffusion.git
cd diffusionpip install .python src/ddpm/train.py
# Plot results
python src/ddpm/plot.pyObserve the loss curve during DDPM training on MNIST.
Observe the generated images during DDPM training.
Observation: We start to recognize the image class from 25 to 30 epochs.
The sample.py script contains the logic for the reverse diffusion process.
Observe the denoising timeline of 5 generated images.
Observation: We start to recognize the image class after t=150. It does not seem to change the image class, but rather fine-tune the texture in the final 200 steps.
I generate 1000 samples and compute FID and IS. But before that we also need a trained classifier.
# Train the Classifier
python src/ddpm/classifier/train.py
# Compute FID and IS
python src/ddpm/metrics.py| Metric | My Model | Baseline (Ho et al.) |
|---|---|---|
| FID ↓ | 6.27 | 3.17 (CIFAR-10) |
| IS ↑ | 7.80 | 9.46 (CIFAR-10) |
FID: Frechet Inception Distance, the lower the better.
IS: Inception Score, the higher the better.


