#
Inverse Denoising Diffusion Implicit Models (DDIMInverse)

##
Overview

This scheduler is the inverted scheduler of Denoising Diffusion Implicit Models (DDIM) by Jiaming Song, Chenlin Meng and Stefano Ermon. The implementation is mostly based on the DDIM inversion definition of Null-text Inversion for Editing Real Images using Guided Diffusion Models

##
DDIMInverseScheduler

###
class diffusers.DDIMInverseScheduler

< source >

( num_train_timesteps: int = 1000 beta_start: float = 0.0001 beta_end: float = 0.02 beta_schedule: str = 'linear' trained_betas: typing.Union[numpy.ndarray, typing.List[float], NoneType] = None clip_sample: bool = True set_alpha_to_zero: bool = True steps_offset: int = 0 prediction_type: str = 'epsilon' clip_sample_range: float = 1.0 **kwargs )

Parameters

- num_train_timesteps (`int`) — number of diffusion steps used to train the model.
- beta_start (`float`) — the starting `beta` value of inference.
- beta_end (`float`) — the final `beta` value.
- beta_schedule (`str`) — the beta schedule, a mapping from a beta range to a sequence of betas for stepping the model. Choose from `linear`, `scaled_linear`, or `squaredcos_cap_v2`.
- trained_betas (`np.ndarray`, optional) — option to pass an array of betas directly to the constructor to bypass `beta_start`, `beta_end` etc.
- clip_sample (`bool`, default `True`) — option to clip predicted sample for numerical stability.
- clip_sample_range (`float`, default `1.0`) — the maximum magnitude for sample clipping. Valid only when `clip_sample=True`.
- set_alpha_to_zero (`bool`, default `True`) — each diffusion step uses the value of alphas product at that step and at the previous one. For the final step there is no previous alpha. When this option is `True` the previous alpha product is fixed to `0`, otherwise it uses the value of alpha at step `num_train_timesteps - 1`.
- steps_offset (`int`, default `0`) — an offset added to the inference steps. You can use a combination of `offset=1` and `set_alpha_to_zero=False`, to make the last step use step `num_train_timesteps - 1` for the previous alpha product.
- prediction_type (`str`, default `epsilon`, optional) — prediction type of the scheduler function, one of `epsilon` (predicting the noise of the diffusion process), `sample` (directly predicting the noisy sample`) or` v_prediction` (see section 2.4 https://imagen.research.google/video/paper.pdf)

DDIMInverseScheduler is the reverse scheduler of DDIMScheduler.

~ConfigMixin takes care of storing all config attributes that are passed in the scheduler’s `__init__` function, such as `num_train_timesteps`. They can be accessed via `scheduler.config.num_train_timesteps`. SchedulerMixin provides general loading and saving functionality via the SchedulerMixin.save_pretrained() and from_pretrained() functions.

For more details, see the original paper: https://arxiv.org/abs/2010.02502

####
scale_model_input

< source >

( sample: FloatTensor timestep: typing.Optional[int] = None ) → `torch.FloatTensor`

Parameters

- sample (`torch.FloatTensor`) — input sample
- timestep (`int`, optional) — current timestep

Returns

`torch.FloatTensor`

scaled input sample

Ensures interchangeability with schedulers that need to scale the denoising model input depending on the current timestep.

####
set_timesteps

< source >

( num_inference_steps: int device: typing.Union[str, torch.device] = None )

Parameters

- num_inference_steps (`int`) — the number of diffusion steps used when generating samples with a pre-trained model.

Sets the discrete timesteps used for the diffusion chain. Supporting function to be run before inference.