Diffusers documentation

IPNDMScheduler

You are viewing main version, which requires installation from source. If you'd like regular pip install, checkout the latest stable version (v0.42.1).
Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

IPNDMScheduler

IPNDMScheduler 是一种四阶改进伪线性多步调度器。其原始实现可在 crowsonkb/v-diffusion-pytorch 中找到。

IPNDMScheduler

class diffusers.IPNDMScheduler

< >

( num_train_timesteps: int = 1000trained_betas: numpy.ndarray | list[float] | None = None )

参数

  • num_train_timesteps (int,默认为 1000) — 用于训练模型的扩散步数。
  • trained_betas(np.ndarray 或 List[float],可选)— 直接传入 betas 数组到构造函数中,以绕过 beta_start 和 beta_end。

四阶改进伪线性多步调度器。

该模型继承自 SchedulerMixin 和 ConfigMixin。有关该库为所有调度器实现的通用方法(例如加载和保存),请参阅父类文档。

index_for_timestep

< >

( timestep: typing.Union[float, torch.Tensor]schedule_timesteps: typing.Optional[torch.Tensor] = None ) → int

参数

  • timestep(float 或 torch.Tensor)— 要在调度器中查找的时间步值。
  • schedule_timesteps (torch.Tensor,可选) — 要搜索的时间步调度。如果为 None,则使用 self.timesteps。

返回值

int

时间步在调度器中的索引。对于第一个步骤,如果存在多个匹配项,则返回第二个索引,以避免在从调度器中间开始(例如,用于图像到图像任务)时跳过某个 sigma。

查找给定时间步在时间步调度中的索引。

scale_model_input

< >

( sample: Tensor*args**kwargs ) → torch.Tensor

参数

  • sample (torch.Tensor) — 输入样本。

返回值

torch.Tensor

经过缩放的输入样本。

确保与那些需要根据当前时间步对去噪模型输入进行缩放的调度器之间的可互换性。

set_begin_index

< >

( begin_index: int = 0 )

参数

  • begin_index (int,默认为 0) — 调度器的起始索引。

设置调度器的起始索引。此函数应在推理之前从流水线中运行。

set_timesteps

< >

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

参数

  • num_inference_steps (int) — 使用预训练模型生成样本时所用的扩散步数。
  • device (str 或 torch.device,可选) — 时间步应移动到的设备。如果为 None,则不移动时间步。

设置扩散链所使用的离散时间步(需在推理之前运行)。

步骤

< >

( model_output: Tensortimestep: typing.Union[int, torch.Tensor]sample: Tensorreturn_dict: bool = True ) → SchedulerOutput or tuple

参数

  • model_output (torch.Tensor) — 学习到的扩散模型的直接输出。
  • timestep (int 或 torch.Tensor) — 扩散链中的当前离散时间步。
  • sample (torch.Tensor) — 扩散过程生成的样本的当前实例。
  • return_dict (bool) — 是否返回 SchedulerOutput 或元组。

返回值

SchedulerOutput 或 tuple

If return_dict is True, SchedulerOutput is returned, otherwise a tuple is returned where the first element is the sample tensor.

通过逆向 SDE 预测上一步时间步的样本。此函数使用线性多步法传播样本。它多次执行前向传播以近似求解。

SchedulerOutput

class diffusers.schedulers.scheduling_utils.SchedulerOutput

< >

( prev_sample: Tensor )

参数

  • prev_sample(对于图像,形状为 (batch_size, num_channels, height, width) 的 torch.Tensor)— 前一时间步的已计算样本 (x_{t-1})。在去噪循环中,应将 prev_sample 用作下一个模型输入。

调度器 step 函数输出的基类。

Update on GitHub