File size: 2,454 Bytes
a3507d1 |
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 |
---
tags:
- ddim_diffusion
---
# Denoising Diffusion Implicit Models (DDIM)
**Paper**: [Denoising Diffusion Implicit Models](https://arxiv.org/abs/2010.02502)
**Abstract**:
*Denoising diffusion probabilistic models (DDPMs) have achieved high quality image generation without adversarial training, yet they require simulating a Markov chain for many steps to produce a sample. To accelerate sampling, we present denoising diffusion implicit models (DDIMs), a more efficient class of iterative implicit probabilistic models with the same training procedure as DDPMs. In DDPMs, the generative process is defined as the reverse of a Markovian diffusion process. We construct a class of non-Markovian diffusion processes that lead to the same training objective, but whose reverse process can be much faster to sample from. We empirically demonstrate that DDIMs can produce high quality samples 10× to 50× faster in terms of wall-clock time compared to DDPMs, allow us to trade off computation for sample quality, and can perform semantically meaningful image interpolation directly in the latent space.*
**Explanation on `eta` and `num_inference_steps`**
- `num_inference_steps` is called *S* in the following table
- `eta` is called *η* in the following table
![ddim](https://huggingface.co/datasets/patrickvonplaten/scientific_images/resolve/main/table_ddim.png)
## Usage
```python
# !pip install diffusers
from diffusers import DiffusionPipeline
import PIL.Image
import numpy as np
model_id = "fusing/ddim-lsun-bedroom"
# load model and scheduler
ddpm = DiffusionPipeline.from_pretrained(model_id)
# run pipeline in inference (sample random noise and denoise)
image = ddpm()
# process image to PIL
image_processed = image.cpu().permute(0, 2, 3, 1)
image_processed = (image_processed + 1.0) * 127.5
image_processed = image_processed.numpy().astype(np.uint8)
image_pil = PIL.Image.fromarray(image_processed[0])
# save image
image_pil.save("test.png")
```
## Samples
1. ![sample_1](https://huggingface.co/datasets/patrickvonplaten/images/resolve/main/hf/dipm-lsun-bedroom/image_0.png)
2. ![sample_1](https://huggingface.co/datasets/patrickvonplaten/images/resolve/main/hf/dipm-lsun-bedroom/image_1.png)
3. ![sample_1](https://huggingface.co/datasets/patrickvonplaten/images/resolve/main/hf/dipm-lsun-bedroom/image_2.png)
4. ![sample_1](https://huggingface.co/datasets/patrickvonplaten/images/resolve/main/hf/dipm-lsun-bedroom/image_3.png)
|