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
- Host: GitHub
- URL: https://github.com/fork123aniket/denoising-diffusion-probabilistic-model-from-scratch
- Owner: fork123aniket
- License: mit
- Created: 2023-03-31T07:40:17.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-05-01T12:21:44.000Z (about 3 years ago)
- Last Synced: 2025-01-16T06:25:21.240Z (over 1 year ago)
- Topics: denoising, denoising-algorithm, denoising-diffusion, denoising-images, denoising-network, image-generation, image-generator, pytorch, pytorch-implementation, pytorch-tutorial
- Language: Python
- Homepage:
- Size: 617 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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 |  |
| CIFAR-10 | conditional (on `Dog` and `Deer` classes) |  |