Implementation of denoising diffusion models with schedules, improved sampling, and other extensions using Keras.
Python
120
69 commits
updated Jan 22, 2024

Diffusion models are trained to denoise noisy images, and can generate images by iteratively denoising pure noise.
This repository contains:
Stochasticity corresponds to eta in the DDIM paper, while the variance_preserving flag selects between the two sampling versions (Equation 16 in DDIM).second_order_alpha.num_multisteps between 1 and 5. Note that in the initial steps I use lower order multistep sampling, instead of other higher-order methods, for simplicity.schedule_type, see below.prediction_type. It can predict the unscaled random gaussian noise, the original image, or even the diffusion velocity (v in Section 4).loss_type, which correspond minimising the error of the predicted unscaled noise, predicted original image, or the diffusion velocity.The network was optimized to offer reasonable performance with modest compute requirements (training time is below an hour on an A100). Other design choices are explained in detail in the corresponding Keras code example.
KID at different sampling steps with different sampling techniques, using cosine schedule. Note that I selected the sampling hyperparameters using DDIM sampling and 5 diffusion steps.

For first order methods network evaluations = diffusion steps, and for second order methods network evaluations = 2 * diffusion steps.

For this plot I used 100 diffusion steps, and a start_log_snr and end_log_snr of 5.0 and -5.0 for symmetry, while their defaults are 2.5 and -7.5.
For implementation details, check out diffusion_schedule() in model.py.
Kernel Inception Distance (KID):
| Dataset / Loss | mean absolute error (MAE) | mean squared error (MSE) |
|---|---|---|
| Oxford Flowers | 0.282 | 0.399 |
| CelebA | 0.148 | 0.104 |
| Caltech Birds | 1.382 | 1.697 |
| CIFAR-10 | 0.217 | 0.175 |
| Network output / Loss weighting | noise | velocity | signal |
|---|---|---|---|
| noise | 0.282 | 0.327 | 0.348 |
| velocity | 0.299 | 0.290 | 0.333 |
| signal | 0.291 | 0.319 | 0.329 |
Trained with default hyperparameters if not mentioned otherwise, tuned on Oxford Flowers.
All visualizations below were generated using:
stochasticity = 1.0, variance_preserving = False)



For a similar implementation of GANs and GAN losses, check out this repository.
161 followers · starred Jan 2024
Implementation of denoising diffusion models with schedules, improved sampling, and other extensions using Keras.
Python
120
69 commits
updated Jan 22, 2024

Diffusion models are trained to denoise noisy images, and can generate images by iteratively denoising pure noise.
This repository contains:
Stochasticity corresponds to eta in the DDIM paper, while the variance_preserving flag selects between the two sampling versions (Equation 16 in DDIM).second_order_alpha.num_multisteps between 1 and 5. Note that in the initial steps I use lower order multistep sampling, instead of other higher-order methods, for simplicity.schedule_type, see below.prediction_type. It can predict the unscaled random gaussian noise, the original image, or even the diffusion velocity (v in Section 4).loss_type, which correspond minimising the error of the predicted unscaled noise, predicted original image, or the diffusion velocity.The network was optimized to offer reasonable performance with modest compute requirements (training time is below an hour on an A100). Other design choices are explained in detail in the corresponding Keras code example.
KID at different sampling steps with different sampling techniques, using cosine schedule. Note that I selected the sampling hyperparameters using DDIM sampling and 5 diffusion steps.

For first order methods network evaluations = diffusion steps, and for second order methods network evaluations = 2 * diffusion steps.

For this plot I used 100 diffusion steps, and a start_log_snr and end_log_snr of 5.0 and -5.0 for symmetry, while their defaults are 2.5 and -7.5.
For implementation details, check out diffusion_schedule() in model.py.
Kernel Inception Distance (KID):
| Dataset / Loss | mean absolute error (MAE) | mean squared error (MSE) |
|---|---|---|
| Oxford Flowers | 0.282 | 0.399 |
| CelebA | 0.148 | 0.104 |
| Caltech Birds | 1.382 | 1.697 |
| CIFAR-10 | 0.217 | 0.175 |
| Network output / Loss weighting | noise | velocity | signal |
|---|---|---|---|
| noise | 0.282 | 0.327 | 0.348 |
| velocity | 0.299 | 0.290 | 0.333 |
| signal | 0.291 | 0.319 | 0.329 |
Trained with default hyperparameters if not mentioned otherwise, tuned on Oxford Flowers.
All visualizations below were generated using:
stochasticity = 1.0, variance_preserving = False)



For a similar implementation of GANs and GAN losses, check out this repository.
161 followers · starred Jan 2024