An open API service indexing awesome lists of open source software.

https://github.com/fork123aniket/denoising-diffusion-probabilistic-model-from-scratch

Implementation of Denoising Diffusion Probabilistic Model from Scratch for Image Generation Task in PyTorch
https://github.com/fork123aniket/denoising-diffusion-probabilistic-model-from-scratch

denoising denoising-algorithm denoising-diffusion denoising-images denoising-network image-generation image-generator pytorch pytorch-implementation pytorch-tutorial

Last synced: about 1 month ago
JSON representation

Implementation of Denoising Diffusion Probabilistic Model from Scratch for Image Generation Task in PyTorch

Awesome Lists containing this project

README

          

# Denoising Diffusion Probabilistic Model from Scratch

This repository implements a fast, yet simple version of the [***Denoising Diffusion Probabilistic Models***](https://arxiv.org/abs/2006.11239) paper for the `image generation` task. ***Denoising score matching*** technique is used to allow the network for rapid estimation of data distribution’s gradient. Moreover, the ***Langevin sampling*** method is also performed to generate images from their corresponding true data distribution. This implementation provides ***unconditional*** along with ***conditional*** ([***Classifier-free Diffusion Guidance (CFG)***](https://arxiv.org/abs/2207.12598) and [***Exponential Moving Average (EMA)***]( https://proceedings.neurips.cc/paper_files/paper/2019/file/3001ef257407d5a371a96dcd947c7d93-Paper.pdf)) sampling approaches.

## Requirements

- `PyTorch`
- `torchvision`
- `numpy`
- `PIL`
- `matplotlib`
- `logging`
- `tqdm`

## Usage

### Data

The ***unconditional*** model is trained on [***Landscape Pictures***](https://www.kaggle.com/datasets/arnaud58/landscape-pictures) dataset and the ***conditional*** model is trained on [***CIFAR-10***](https://www.kaggle.com/datasets/joaopauloschuler/cifar10-64x64-resized-via-cai-super-resolution) dataset.

### Training and Testing

- To see the implementation of ***conditional*** and ***unconditional*** sampling methods, check `DDPM.py`.
- All the network architectures for `EMA`, `UNet`, etc. can be found in the `models.py` file.
- To train ***DDPMs*** for either of the sampling approaches (***conditional*** and ***unconditional***) and generate the images, run `DDPM`.py.
- All hyperparameters to control the training and testing phases of the model are provided in the given `DDPM.py` file.

## Results

The images generated by both ***conditional*** and ***unconditional*** models can be seen below:-

| Training Dataset | Sampling Type | Generated Images |
| ---------------------- |:-------------------:|:------------------------:|
| Landscape Pictures | unconditional | ![alt text](https://github.com/fork123aniket/Denoising-Diffusion-Probabilistic-Model-from-Scratch/blob/main/Images/Landscape.PNG) |
| CIFAR-10 | conditional (on `Dog` and `Deer` classes) | ![alt text](https://github.com/fork123aniket/Denoising-Diffusion-Probabilistic-Model-from-Scratch/blob/main/Images/Dog.PNG) ![alt text](https://github.com/fork123aniket/Denoising-Diffusion-Probabilistic-Model-from-Scratch/blob/main/Images/Deer.PNG)|