Diffusers 文档

FlowMatchEulerDiscreteScheduler

Hugging Face's logo
加入 Hugging Face 社区

并获得增强的文档体验

开始使用

FlowMatchEulerDiscreteScheduler

FlowMatchEulerDiscreteScheduler 基于 Stable Diffusion 3 中引入的 flow-matching 采样。

FlowMatchEulerDiscreteScheduler

diffusers.FlowMatchEulerDiscreteScheduler

< >

( num_train_timesteps: int = 1000 shift: float = 1.0 use_dynamic_shifting = False base_shift: typing.Optional[float] = 0.5 max_shift: typing.Optional[float] = 1.15 base_image_seq_len: typing.Optional[int] = 256 max_image_seq_len: typing.Optional[int] = 4096 invert_sigmas: bool = False shift_terminal: typing.Optional[float] = None use_karras_sigmas: typing.Optional[bool] = False use_exponential_sigmas: typing.Optional[bool] = False use_beta_sigmas: typing.Optional[bool] = False )

参数

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

Euler 调度器。

此模型继承自 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 = None device: typing.Union[str, torch.device] = None sigmas: typing.Optional[typing.List[float]] = None mu: typing.Optional[float] = 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 ) EulerDiscreteSchedulerOutputtuple

参数

  • 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) — 是否返回 EulerDiscreteSchedulerOutput 或 tuple。

返回

EulerDiscreteSchedulerOutputtuple

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

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

stretch_shift_to_terminal

< >

( t: Tensor ) torch.Tensor

参数

  • t (torch.Tensor) — 要拉伸和偏移的时间步张量。

返回

torch.Tensor

调整后的时间步张量,使得最终值等于 self.config.shift_terminal

拉伸和偏移时间步计划,以确保它在配置的 shift_terminal 配置值处终止。

参考: https://github.com/Lightricks/LTX-Video/blob/a01a171f8fe3d99dce2728d60a73fecf4d4238ae/ltx_video/schedulers/rf.py#L51

< > Update on GitHub