Skip to content

PyTorch implementation of the Denoising Diffusion Probabilistic Model (DDPM) with DDIM sampling and classifier-free guidance, based on Ho et al.'s paper, evaluated on the MNIST dataset.

Notifications You must be signed in to change notification settings

Ofekirsh/Denoising-Diffusion-Probabilistic-Model

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Denoising Diffusion Probabilistic Model

This project implements the models proposed in Denoising-Diffusion-Probabilistic-Model (DDPM) paper written by Jonathan Ho, Ajay Jain, and Pieter Abbeel.

The models were ran over the following dataset:

  • MNIST

The results of the models can be found in results.pdf.

Below are generated image samples from the DDPM and DDIM methods:

  • DDIM (5 steps): Fewer denoising steps, resulting in quicker generation but slightly noisier images.

  • DDIM (10 steps): Improved clarity over 5 steps while still maintaining fast sampling.

  • DDIM (20 steps): Better image quality, showing clearer digits with fewer artifacts.

  • DDIM (50 steps): Nearly matches the DDPM quality, producing very clean and sharp digits.

  • DDPM Sample after 29 Epochs: A sample generated by the trained DDPM model after 29 epochs of training.

Setup

Prerequisites

  • Python 3.x
  • NumPy
  • torch
  • torchvision
  • matplotlib

You can install the dependencies using:

pip install -r requirements.txt

Running the code

To train the DDPM model on the MNIST dataset:

python main.py

You can customize training using the following command-line arguments:

Argument Description Default
--batch_size Number of images per mini-batch 128
--epochs Number of training epochs 30
--lr Initial learning rate for the optimizer 1e-3

Example with Custom Parameters:

python main.py --batch_size 64 --epochs 50 --lr 0.0005

Output Files

  • Samples: After every epoch, an image grid of generated MNIST digits is saved in ./samples/ as MNIST_{epoch}.png.
  • DDIM Samples: After training, DDIM samples are generated at steps [5, 10, 20, 50] and saved as DDIM_{steps}.png in the same folder.
  • Losses: The training loss for each epoch is saved to a file named loss_epochs.pkl.

About

PyTorch implementation of the Denoising Diffusion Probabilistic Model (DDPM) with DDIM sampling and classifier-free guidance, based on Ho et al.'s paper, evaluated on the MNIST dataset.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages