DDIM
Last updated
Last updated
(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 .
( unetscheduler )
Parameters
unet () β A UNet2DModel
to denoise the encoded image latents.
scheduler () β A scheduler to be used in combination with unet
to denoise the encoded image. Can be one of , or .
Pipeline for image generation.
This model inherits from . Check the superclass documentation for the generic methods implemented for all pipelines (downloading, saving, running on a particular device, etc.).
__call__
Parameters
batch_size (int
, optional, defaults to 1) β The number of images to generate.
num_inference_steps (int
, optional, defaults to 50) β The number of denoising steps. More denoising steps usually lead to a higher quality image at the expense of slower inference.
output_type (str
, optional, defaults to "pil"
) β The output format of the generated image. Choose between PIL.Image
or np.array
.
Returns
The call function to the pipeline for generation.
Example:
Copied
( images: typing.Union[typing.List[PIL.Image.Image], numpy.ndarray] )
Parameters
images (List[PIL.Image.Image]
or np.ndarray
) β List of denoised PIL images of length batch_size
or NumPy array of shape (batch_size, height, width, num_channels)
.
Output class for image pipelines.
( batch_size: int = 1generator: typing.Union[torch._C.Generator, typing.List[torch._C.Generator], NoneType] = Noneeta: float = 0.0num_inference_steps: int = 50use_clipped_model_output: typing.Optional[bool] = Noneoutput_type: typing.Optional[str] = 'pil'return_dict: bool = True ) β or tuple
generator (torch.Generator
, optional) β A to make generation deterministic.
eta (float
, optional, defaults to 0.0) β Corresponds to parameter eta (Ξ·) from the paper. Only applies to the , and is ignored in other schedulers. A value of 0
corresponds to DDIM and 1
corresponds to DDPM.
use_clipped_model_output (bool
, optional, defaults to None
) β If True
or False
, see documentation for . If None
, nothing is passed downstream to the scheduler (use None
for schedulers which donβt support this argument).
return_dict (bool
, optional, defaults to True
) β Whether or not to return a instead of a plain tuple.
or tuple
If return_dict
is True
, is returned, otherwise a tuple
is returned where the first element is a list with the generated images