Diffusers documentation

HeliosScheduler

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

HeliosScheduler

HeliosScheduler 基于 Helios 中提出的金字塔流匹配采样方法。

HeliosScheduler

类 diffusers.HeliosScheduler

< >

( num_train_timesteps: int = 1000shift: float = 1.0stages: int = 3stage_range: list = [0, 0.3333333333333333, 0.6666666666666666, 1]gamma: float = 0.3333333333333333thresholding: bool = Falseprediction_type: str = 'flow_prediction'solver_order: int = 2predict_x0: bool = Truesolver_type: str = 'bh2'lower_order_final: bool = Truedisable_corrector: list = []solver_p: SchedulerMixin = Noneuse_flow_sigmas: bool = Truescheduler_type: str = 'unipc'use_dynamic_shifting: bool = Falsetime_shift_type: typing.Literal['exponential', 'linear'] = 'exponential' )

convert_model_output

< >

( model_output: Tensor*argssample: Tensor = Nonesigma: Tensor = None**kwargs ) → torch.Tensor

参数

  • model_output (torch.Tensor) — 学习到的扩散模型的直接输出。
  • timestep (int) — 扩散链中的当前离散时间步。
  • sample (torch.Tensor) — 扩散过程生成的样本的当前实例。
  • sigma (torch.Tensor, 可选) — 噪声调度中当前步的 sigma。

返回值

torch.Tensor

转换后的模型输出。

将模型输出转换为 UniPC 算法所需的对应类型。

init_sigmas

< >

( )

初始化全局时间步和 sigma

init_sigmas_for_each_stage

< >

( )

初始化每个阶段的 timesteps

multistep_uni_c_bh_update

< >

( this_model_output: Tensor*argslast_sample: Tensor = Nonethis_sample: Tensor = Noneorder: int = Nonesigma_before: Tensor = Nonesigma: Tensor = None**kwargs ) → torch.Tensor

参数

  • this_model_output (torch.Tensor) — 模型在 x_t 处的输出。
  • this_timestep (int) — 当前时间步 t。
  • last_sample (torch.Tensor) — 最后一个预测器之前的生成样本 x_{t-1}。
  • this_sample (torch.Tensor) — 最后一个预测器 x_{t} 之后生成的样本。
  • order (int) — 此步骤中 UniC-p 的 p。有效精度阶数应为 order + 1。
  • sigma_before (torch.Tensor, 可选) — 噪声调度中前一步的 sigma。
  • sigma (torch.Tensor, 可选) — 噪声调度中当前步的 sigma。

返回值

torch.Tensor

当前时间步的修正后样本张量。

UniC (B(h) 版本) 的一步。

multistep_uni_p_bh_update

< >

( model_output: Tensor*argssample: Tensor = Noneorder: int = Nonesigma: Tensor = Nonesigma_next: Tensor = None**kwargs ) → torch.Tensor

参数

  • model_output (torch.Tensor) — 当前时间步下,学习到的扩散模型的直接输出。
  • prev_timestep (int) — 扩散链中的上一个离散时间步。
  • sample (torch.Tensor) — 扩散过程生成的样本的当前实例。
  • order (int) — 当前时间步的 UniP 阶数(对应于 UniPC-p 中的 p)。
  • sigma (torch.Tensor, 可选) — 噪声调度中当前步的 sigma。
  • sigma_next (torch.Tensor, 可选) — 噪声调度中下一步的 sigma。

返回值

torch.Tensor

上一步时间步的样本张量。

UniP(B(h) 版本)的单步。或者,如果指定了,则使用 self.solver_p。

set_begin_index

< >

( begin_index: int = 0 )

参数

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

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

set_timesteps

< >

( num_inference_steps: intstage_index: int | None = Nonedevice: typing.Union[str, torch.device] = Nonesigmas: bool | None = Nonemu: bool | None = Noneis_amplify_first_chunk: bool = False )

为每个阶段设置 timesteps 和 sigmas

time_shift

< >

( mu: floatsigma: floatt: Tensor ) → torch.Tensor

参数

  • mu (float) — 用于时间偏移的 mu 参数。
  • sigma (float) — 用于时间偏移的 sigma 参数。
  • t (torch.Tensor) — 输入的时间步。

返回值

torch.Tensor

时间偏移的时间步。

对 sigmas 应用时间偏移。

scheduling_helios

Update on GitHub