https://github.com/berlin0308/conditional-ddpm-ddim
DDPM (Denoising Diffusion Probabilistic Models) and DDIM (Denoising Diffusion Implicit Models) for conditional image generation
https://github.com/berlin0308/conditional-ddpm-ddim
classifier-free-guidance conditional-generation diffusion-models digits human-faces
Last synced: 3 months ago
JSON representation
DDPM (Denoising Diffusion Probabilistic Models) and DDIM (Denoising Diffusion Implicit Models) for conditional image generation
- Host: GitHub
- URL: https://github.com/berlin0308/conditional-ddpm-ddim
- Owner: berlin0308
- Created: 2025-01-17T06:56:21.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2025-01-17T07:46:28.000Z (5 months ago)
- Last Synced: 2025-02-03T22:48:58.470Z (4 months ago)
- Topics: classifier-free-guidance, conditional-generation, diffusion-models, digits, human-faces
- Language: Python
- Homepage:
- Size: 30.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Conditional Diffusion Models: DDPM and DDIM
## Install Packages
With **Python3.8**, run the following command to install all the packages listed in the requirements.txt:pip3 install -r requirements.txt
## DDPM (Denoising Diffusion Probabilistic Models)
+ All DDPM implementation details are in ```p1_model.py```
+ A modified UNet that supports conditional learning by adding **time embedding** (time steps in the diffusion process) and **context embedding** (labels)
### Train DDPM on MNIST-M / SVHN Dataset
python3 p1_train.py
### Generate Digit Images
Use the model you just trained **OR** download the pretrained model directly:
gdown 1uX845gl81kgc-lHqo8SS78DBz8n1DWmS -O combined_ddpm.pth
Generate images for each digit (0-9) from MNIST-M / SVHN dataset:
python3 p1_inference.py --output_image_dir --model_path
For example:
| MNIST-M | SVHN |
| -------- | -------- |
|  |  |### Evaluation
The output images can be evaluated by ```digit_classifier.py```
python3 digit_classifier.py --folder --checkpoint
| | MNIST-M | SVHN | Average |
| -----| -------- | -------- | --- |
| Acuracy | 99.80% | 99.20% | 99.50% |## DDIM (Denoising Diffusion Implicit Models)
+ All DDPM implementation details are in ```p2_model.py```
### Generate Human Face Images
python3 p2_inference.py --noise_folder --output_folder --unet_model_path
With different ETA (Avg. MSE: 1.56):

### Interpolate Two Noises
python3 p2_interpolate.py
+ Linear interpolation (LERP): Simply linearly mixes the two noise vectors without considering their position on a hypersphere (by setting ```SLERP=False```)
+ Spherical Linear Interpolation (SLERP): Along the surface of a hypersphere (by setting ```SLERP=True```)| LERP | SLERP |
| -------- | -------- |
|  |  |