DDIM¶
Denoising Diffusion Implicit Models (DDIM) by Jiaming Song, Chenlin Meng and Stefano Ermon.
The abstract from the paper is:
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.
The original codebase can be found at ermongroup/ddim.
mindone.diffusers.DDIMPipeline
¶
Bases: DiffusionPipeline
Pipeline for image generation.
This model inherits from [DiffusionPipeline
]. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).
PARAMETER | DESCRIPTION |
---|---|
unet |
A
TYPE:
|
scheduler |
A scheduler to be used in combination with
TYPE:
|
Source code in mindone/diffusers/pipelines/ddim/pipeline_ddim.py
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 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
|
mindone.diffusers.DDIMPipeline.__call__(batch_size=1, generator=None, eta=0.0, num_inference_steps=50, use_clipped_model_output=None, output_type='pil', return_dict=False)
¶
The call function to the pipeline for generation.
PARAMETER | DESCRIPTION |
---|---|
batch_size |
The number of images to generate.
TYPE:
|
generator |
A
TYPE:
|
eta |
Corresponds to parameter eta (η) from the DDIM paper. Only applies
to the [
TYPE:
|
num_inference_steps |
The number of denoising steps. More denoising steps usually lead to a higher quality image at the expense of slower inference.
TYPE:
|
use_clipped_model_output |
If
TYPE:
|
output_type |
The output format of the generated image. Choose between
TYPE:
|
return_dict |
Whether or not to return a [
TYPE:
|
>>> from mindone.diffusers import DDIMPipeline
>>> import PIL.Image
>>> import numpy as np
>>> # load model and scheduler
>>> pipe = DDIMPipeline.from_pretrained("fusing/ddim-lsun-bedroom")
>>> # run pipeline in inference (sample random noise and denoise)
>>> image = pipe(eta=0.0, num_inference_steps=50)
>>> # 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")
RETURNS | DESCRIPTION |
---|---|
Union[ImagePipelineOutput, Tuple]
|
[ |
Source code in mindone/diffusers/pipelines/ddim/pipeline_ddim.py
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 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
|
mindone.diffusers.pipelines.pipeline_utils.ImagePipelineOutput
dataclass
¶
Bases: BaseOutput
Output class for image pipelines.
Source code in mindone/diffusers/pipelines/pipeline_utils.py
69 70 71 72 73 74 75 76 77 78 79 80 |
|