patrickvonplaten commited on
Commit
2a68f6b
1 Parent(s): cf6443d

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +21 -13
README.md CHANGED
@@ -16,34 +16,42 @@ tags:
16
 
17
  *We present high quality image synthesis results using diffusion probabilistic models, a class of latent variable models inspired by considerations from nonequilibrium thermodynamics. Our best results are obtained by training on a weighted variational bound designed according to a novel connection between diffusion probabilistic models and denoising score matching with Langevin dynamics, and our models naturally admit a progressive lossy decompression scheme that can be interpreted as a generalization of autoregressive decoding. On the unconditional CIFAR10 dataset, we obtain an Inception score of 9.46 and a state-of-the-art FID score of 3.17. On 256x256 LSUN, we obtain sample quality similar to ProgressiveGAN.*
18
 
19
- ## Usage
 
 
 
 
 
 
 
 
 
20
 
21
  See the following code:
22
 
23
  ```python
24
  # !pip install diffusers
25
- from diffusers import DiffusionPipeline
26
- import PIL.Image
27
- import numpy as np
28
 
29
- model_id = "google/ddpm-cifar10"
30
 
31
  # load model and scheduler
32
- ddpm = DiffusionPipeline.from_pretrained(model_id)
33
 
34
  # run pipeline in inference (sample random noise and denoise)
35
- image = ddpm()
36
 
37
- # process image to PIL
38
- image_processed = image.cpu().permute(0, 2, 3, 1)
39
- image_processed = (image_processed + 1.0) * 127.5
40
- image_processed = image_processed.numpy().astype(np.uint8)
41
- image_pil = PIL.Image.fromarray(image_processed[0])
42
 
43
  # save image
44
- image_pil.save("test.png")
45
  ```
46
 
 
 
 
 
 
 
47
  ## Samples
48
 
49
  1. ![sample_1](https://huggingface.co/datasets/patrickvonplaten/images/resolve/main/hf/ddpm-cifar10/image_0.png)
 
16
 
17
  *We present high quality image synthesis results using diffusion probabilistic models, a class of latent variable models inspired by considerations from nonequilibrium thermodynamics. Our best results are obtained by training on a weighted variational bound designed according to a novel connection between diffusion probabilistic models and denoising score matching with Langevin dynamics, and our models naturally admit a progressive lossy decompression scheme that can be interpreted as a generalization of autoregressive decoding. On the unconditional CIFAR10 dataset, we obtain an Inception score of 9.46 and a state-of-the-art FID score of 3.17. On 256x256 LSUN, we obtain sample quality similar to ProgressiveGAN.*
18
 
19
+ ## Inference
20
+
21
+ **DDPM** models can use *discrete noise schedulers* such as:
22
+
23
+ - [scheduling_ddpm](https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_ddpm.py)
24
+ - [scheduling_ddim](https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_ddim.py)
25
+ - [scheduling_pndm](https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_pndm.py)
26
+
27
+ for inference. Note that while the *ddpm* scheduler yields the highest quality, it also takes the longest.
28
+ For a good trade-off between quality and inference speed you might want to consider the *ddim* or *pndm* schedulers instead.
29
 
30
  See the following code:
31
 
32
  ```python
33
  # !pip install diffusers
34
+ from diffusers import DDPMPipeline, DDIMPipeline, PNDMPipeline
 
 
35
 
36
+ model_id = "google/ddpm-cifar10-32"
37
 
38
  # load model and scheduler
39
+ ddpm = DDPMPipeline.from_pretrained(model_id) # you can replace DDPMPipeline with DDIMPipeline or PNDMPipeline for faster inference
40
 
41
  # run pipeline in inference (sample random noise and denoise)
42
+ image = ddpm()["sample"]
43
 
 
 
 
 
 
44
 
45
  # save image
46
+ image[0].save("ddpm_generated_image.png")
47
  ```
48
 
49
+ For more in-detail information, please have a look at the [official inference example](_) # <- TODO(PVP) add link
50
+
51
+ ## Training
52
+
53
+ If you want to train your own model, please have a look at the [official training example]( ) # <- TODO(PVP) add link
54
+
55
  ## Samples
56
 
57
  1. ![sample_1](https://huggingface.co/datasets/patrickvonplaten/images/resolve/main/hf/ddpm-cifar10/image_0.png)