Diffusers 文档

FlowMatchHeunDiscreteScheduler

Hugging Face's logo
加入 Hugging Face 社区

并获取增强的文档体验

开始使用

FlowMatchHeunDiscreteScheduler

FlowMatchHeunDiscreteScheduler 基于 EDM 中介绍的 flow-matching 采样。

FlowMatchHeunDiscreteScheduler

class diffusers.FlowMatchHeunDiscreteScheduler

< >

( num_train_timesteps: int = 1000 shift: float = 1.0 )

参数

  • num_train_timesteps (int, 默认为 1000) — 用于训练模型的扩散步骤数。
  • timestep_spacing (str, 默认为 "linspace") — 时间步长应缩放的方式。有关更多信息,请参阅 Common Diffusion Noise Schedules and Sample Steps are Flawed 中的表 2。
  • shift (float, 默认为 1.0) — 时间步长计划的 shift 值。

Heun 调度器。

此模型继承自 SchedulerMixinConfigMixin。查看超类文档,了解库为所有调度器实现的通用方法,例如加载和保存。

scale_noise

< >

( sample: FloatTensor timestep: typing.Union[float, torch.FloatTensor] noise: typing.Optional[torch.FloatTensor] = None ) torch.FloatTensor

参数

  • sample (torch.FloatTensor) — 输入样本。
  • timestep (int, 可选) — 扩散链中的当前时间步。

返回值

torch.FloatTensor

缩放后的输入样本。

flow-matching 中的前向过程

set_begin_index

< >

( begin_index: int = 0 )

参数

  • begin_index (int) — 调度器的起始索引。

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

set_timesteps

< >

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

参数

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

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

step

< >

( model_output: FloatTensor timestep: typing.Union[float, torch.FloatTensor] sample: FloatTensor s_churn: float = 0.0 s_tmin: float = 0.0 s_tmax: float = inf s_noise: float = 1.0 generator: typing.Optional[torch._C.Generator] = None return_dict: bool = True ) ~schedulers.scheduling_Heun_discrete.HeunDiscreteSchedulerOutputtuple

参数

  • model_output (torch.FloatTensor) — 来自学习扩散模型的直接输出。
  • timestep (float) — 扩散链中当前的离散时间步。
  • sample (torch.FloatTensor) — 扩散过程创建的样本的当前实例。
  • s_churn (float) —
  • s_tmin (float) —
  • s_tmax (float) —
  • s_noise (float, 默认为 1.0) — 添加到样本的噪声的缩放因子。
  • generator (torch.Generator, 可选) — 随机数生成器。
  • return_dict (bool) — 是否返回 ~schedulers.scheduling_Heun_discrete.HeunDiscreteSchedulerOutput 或 tuple。

返回值

~schedulers.scheduling_Heun_discrete.HeunDiscreteSchedulerOutputtuple

如果 return_dict 为 True,则返回 ~schedulers.scheduling_Heun_discrete.HeunDiscreteSchedulerOutput,否则返回一个 tuple,其中第一个元素是样本张量。

通过反转 SDE,从上一个时间步预测样本。此函数从学习的模型输出(通常是预测的噪声)传播扩散过程。

< > 在 GitHub 上更新