Diffusers documentation

FlowMatchHeunDiscreteScheduler

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

FlowMatchHeunDiscreteScheduler

FlowMatchHeunDiscreteScheduler 基于 EDM 中引入的 flow-matching 采样方法。

FlowMatchHeunDiscreteScheduler

类 diffusers.FlowMatchHeunDiscreteScheduler

< >

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

参数

  • num_train_timesteps (int,默认为 1000) — 用于训练模型的扩散步数。
  • shift (float,默认为 1.0) — 时间步调度的 shift 值。

Heun 调度器。

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

index_for_timestep

< >

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

参数

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

返回值

int

时间步在调度器中的索引。

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

scale_noise

< >

( sample: FloatTensortimestep: typing.Union[float, torch.FloatTensor]noise: FloatTensor ) → torch.FloatTensor

参数

  • sample (torch.FloatTensor) — 输入样本。
  • timestep (float 或 torch.FloatTensor) — 扩散链中的当前时间步。
  • noise (torch.FloatTensor) — 噪声张量。

返回值

torch.FloatTensor

经过缩放的输入样本。

流匹配中的前向过程

set_begin_index

< >

( begin_index: int = 0 )

参数

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

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

set_timesteps

< >

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

参数

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

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

步骤

< >

( model_output: FloatTensortimestep: typing.Union[float, torch.FloatTensor]sample: FloatTensors_churn: float = 0.0s_tmin: float = 0.0s_tmax: float = infs_noise: float = 1.0generator: typing.Optional[torch.Generator] = Nonereturn_dict: bool = True ) → FlowMatchHeunDiscreteSchedulerOutput or tuple

参数

  • model_output (torch.FloatTensor) — 学习到的扩散模型的直接输出。
  • timestep (float 或 torch.FloatTensor) — 扩散链中的当前离散时间步。
  • sample (torch.FloatTensor) — 扩散过程生成的样本的当前实例。
  • s_churn (float) — 控制采样过程中添加噪声量的随机性参数。值越高,随机性越强。
  • s_tmin (float) — 应用随机性的最小时间步阈值。仅当时间步大于该值时,才会添加噪声。
  • s_tmax (float) — 应用随机性的最大时间步阈值。仅当时间步低于此值时,才会添加噪声。
  • s_noise (float,默认为 1.0) — 添加到样本的噪声的缩放因子。
  • generator (torch.Generator,可选) — 随机数生成器。
  • return_dict (bool) — 是否返回 FlowMatchHeunDiscreteSchedulerOutput 元组。

返回值

FlowMatchHeunDiscreteSchedulerOutput 或 tuple

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

通过逆向 SDE 预测上一时间步的样本。此函数将扩散过程从学习到的模型输出(通常是预测的噪声)进行传播。

Update on GitHub