Shortcuts

mmagic.models.diffusion_schedulers.ddim_scheduler

Module Contents

Classes

EditDDIMScheduler

`EditDDIMScheduler` support the diffusion and reverse process

class mmagic.models.diffusion_schedulers.ddim_scheduler.EditDDIMScheduler(num_train_timesteps=1000, beta_start=0.0001, beta_end=0.02, beta_schedule='linear', variance_type='learned_range', timestep_values=None, clip_sample=True, set_alpha_to_one=True)[source]

`EditDDIMScheduler` support the diffusion and reverse process formulated in https://arxiv.org/abs/2010.02502.

The code is heavily influenced by https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_ddim.py. # noqa The difference is that we ensemble gradient-guided sampling in step function.

Parameters
  • num_train_timesteps (int, optional) – _description_. Defaults to 1000.

  • beta_start (float, optional) – _description_. Defaults to 0.0001.

  • beta_end (float, optional) – _description_. Defaults to 0.02.

  • beta_schedule (str, optional) – _description_. Defaults to “linear”.

  • variance_type (str, optional) – _description_. Defaults to ‘learned_range’.

  • timestep_values (_type_, optional) – _description_. Defaults to None.

  • clip_sample (bool, optional) – _description_. Defaults to True.

  • set_alpha_to_one (bool, optional) – _description_. Defaults to True.

set_timesteps(num_inference_steps, offset=0)[source]

set time steps.

scale_model_input(sample: torch.FloatTensor, timestep: Optional[int] = None) torch.FloatTensor[source]

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

Parameters
  • sample (torch.FloatTensor) – input sample

  • timestep (int, optional) – current timestep

Returns

scaled input sample

Return type

torch.FloatTensor

_get_variance(timestep, prev_timestep)[source]

get variance.

step(model_output: Union[torch.FloatTensor, numpy.ndarray], timestep: int, sample: Union[torch.FloatTensor, numpy.ndarray], cond_fn=None, cond_kwargs={}, eta: float = 0.0, use_clipped_model_output: bool = False, generator=None)[source]

step forward.

add_noise(original_samples, noise, timesteps)[source]

add noise.

__len__()[source]
Read the Docs v: latest
Versions
latest
stable
0.x
Downloads
pdf
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.