Merge branch 'main' of https://huggingface.co/aharshit123456/learn_ddpm
Browse files
README.md
CHANGED
@@ -1,98 +1,106 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
```
|
25 |
-
|
26 |
-
```
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
-
|
45 |
-
-
|
46 |
-
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
-
|
51 |
-
-
|
52 |
-
-
|
53 |
-
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
-
|
58 |
-
-
|
59 |
-
|
60 |
-
|
61 |
-
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
```
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
#
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: mit
|
3 |
+
datasets:
|
4 |
+
- uoft-cs/cifar10
|
5 |
+
- nyanko7/danbooru2023
|
6 |
+
language:
|
7 |
+
- en
|
8 |
+
---
|
9 |
+
# DDPM Project
|
10 |
+
|
11 |
+
This repository contains the implementation of Denoising Diffusion Probabilistic Models (DDPM).
|
12 |
+
|
13 |
+
## Table of Contents
|
14 |
+
- [Introduction](#introduction)
|
15 |
+
- [Installation](#installation)
|
16 |
+
- [Usage](#usage)
|
17 |
+
- [Contributing](#contributing)
|
18 |
+
|
19 |
+
## Introduction
|
20 |
+
Denoising Diffusion Probabilistic Models (DDPM) are a class of generative models that learn to generate data by reversing a diffusion process. This repository provides a comprehensive implementation of DDPM.
|
21 |
+
|
22 |
+
## Installation
|
23 |
+
To install the necessary dependencies, run:
|
24 |
+
```bash
|
25 |
+
pip install -r requirements.txt
|
26 |
+
```
|
27 |
+
|
28 |
+
## Usage
|
29 |
+
To train the model, use the following command:
|
30 |
+
```bash
|
31 |
+
python train.py
|
32 |
+
```
|
33 |
+
To generate samples, use:
|
34 |
+
```bash
|
35 |
+
python generate.py
|
36 |
+
```
|
37 |
+
|
38 |
+
## Game
|
39 |
+
To understand the model and it's workings, we're working on a cool cute little game where the user is the UNET reverser/diffusion model and is tasked to denoise the images with noise made of grids of lines.
|
40 |
+
|
41 |
+
Use [learndiffusion.vercel.app](learndiffusion.vercel.app) to access the primitive version of the game. You can also contribute to the game by checking out at the diffusion_game branch. A new model showcase will also be added such that the model's weights are loaded from the internet, model's files are installed and loaded into a gradio interface for direct use/inference on the vercel. Feel free to make changes for the same, issue is opened.
|
42 |
+
|
43 |
+
## Explanations and Mathematics
|
44 |
+
- slides from presentation :
|
45 |
+
- notes/explanations : [HERE](slides\notes)
|
46 |
+
- a cute lab talk ppt:
|
47 |
+
- plato's allegory : \<link to REPUBLIC>
|
48 |
+
|
49 |
+
## Resources
|
50 |
+
- Original Paper : https://arxiv.org/pdf/2006.11239
|
51 |
+
- Improvement Paper : https://arxiv.org/abs/2102.09672
|
52 |
+
- Improvement by OpenAI : https://arxiv.org/pdf/2105.05233
|
53 |
+
- Stable Diffusion Paper : https://arxiv.org/abs/2112.10752
|
54 |
+
-
|
55 |
+
|
56 |
+
### Papers for background
|
57 |
+
- UNET Paper for Biomedical Segmentation
|
58 |
+
- Autoencooder
|
59 |
+
- Variational Autoencoder
|
60 |
+
- Markov Hierarchical VAE
|
61 |
+
- Introductory Lectures on Diffusion Process
|
62 |
+
|
63 |
+
### Youtube videos and courses
|
64 |
+
#### Mathematics
|
65 |
+
- Outliers
|
66 |
+
- Omar Jahil
|
67 |
+
|
68 |
+
#### Pytorch Implementation
|
69 |
+
- [Deep Findr](https://www.youtube.com/watch?v=a4Yfz2FxXiY)
|
70 |
+
- [Notebook from Deep Findr](https://colab.research.google.com/drive/1sjy9odlSSy0RBVgMTgP7s99NXsqglsUL?usp=sharing)
|
71 |
+
|
72 |
+
## Pretrained Weights
|
73 |
+
weights from the model can be found in [pretrained_weights](https://drive.google.com/drive/folders/1NiQDI3e67I9FITVnrzNPP2Az0LABRpic?usp=sharing)
|
74 |
+
|
75 |
+
For loading the pretrained weights:
|
76 |
+
```
|
77 |
+
model2 = SimpleUnet()
|
78 |
+
model2.load_state_dict(torch.load("/content/drive/MyDrive/Research Work/mlsa/DDPM/model_weights.pth"))
|
79 |
+
model2.eval()
|
80 |
+
```
|
81 |
+
|
82 |
+
For making inferences
|
83 |
+
TODO: Errors in the sampling function, boolean errors and etc. Will open issues for solving by others as exercise if needed.
|
84 |
+
```
|
85 |
+
num_samples = 8 # Number of images to generate
|
86 |
+
image_size = (3, 32, 32) # Example for CIFAR10
|
87 |
+
noise = torch.randn(num_samples, *image_size).to("cuda")
|
88 |
+
|
89 |
+
model2.to("cuda")
|
90 |
+
# Generate images by denoising
|
91 |
+
with torch.no_grad():
|
92 |
+
generated_images = model2.sample(noise)
|
93 |
+
|
94 |
+
# Save the generated images
|
95 |
+
save_image(generated_images, "generated_images.png", nrow=4, normalize=True)
|
96 |
+
```
|
97 |
+
|
98 |
+
|
99 |
+
## Contributing
|
100 |
+
Contributions are welcome! Please open an issue or submit a pull request.
|
101 |
+
|
102 |
+
|
103 |
+
## Future Ideas
|
104 |
+
- Make the model onnx compatible for training and inferencing on Intel GPUs
|
105 |
+
- Build a Stable Diffusion model Text2Img using CLIP implementationnnnn !!!
|
106 |
+
- Train the current model for a much larger dataset with more generalizations and nuances
|