Buckets:
| # Latent Consistency Model Multistep Scheduler | |
| ## 概要 | |
| Simian Luo、Yiqin Tan、Longbo Huang、Jian Li、Hang Zhao による論文 [Latent Consistency Models: Synthesizing High-Resolution Images with Few-Step Inference](https://huggingface.co/papers/2310.04378) で、latent consistency models とともに導入された Multistep and onestep scheduler (Algorithm 3) です。この scheduler は、[LatentConsistencyModelPipeline](/docs/diffusers/main/ja/api/pipelines/latent_consistency_models#diffusers.LatentConsistencyModelPipeline) から 1〜8 ステップで良好なサンプルを生成できるはずです。 | |
| ## LCMScheduler[[diffusers.LCMScheduler]] | |
| #### diffusers.LCMScheduler[[diffusers.LCMScheduler]] | |
| ```python | |
| diffusers.LCMScheduler(num_train_timesteps: int = 1000, beta_start: float = 0.00085, beta_end: float = 0.012, beta_schedule: str = 'scaled_linear', trained_betas: numpy.ndarray | list[float] | None = None, original_inference_steps: int = 50, clip_sample: bool = False, clip_sample_range: float = 1.0, set_alpha_to_one: bool = True, steps_offset: int = 0, prediction_type: str = 'epsilon', thresholding: bool = False, dynamic_thresholding_ratio: float = 0.995, sample_max_value: float = 1.0, timestep_spacing: str = 'leading', timestep_scaling: float = 10.0, rescale_betas_zero_snr: bool = False) | |
| ``` | |
| [ソース](https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_lcm.py#L142) | |
| **パラメータ:** | |
| num_train_timesteps (`int`、デフォルトは`1000`) : モデルを学習するための拡散ステップ数。 | |
| beta_start (`float`、デフォルトは`0.00085`) : 推論の初期`beta`値。 | |
| beta_end (`float`、デフォルトは`0.012`) : 最終的な`beta`値。 | |
| beta_schedule (`str`、デフォルトは`"scaled_linear"`) : ベータスケジュール。モデルのステップ処理において、ベータの範囲からベータのシーケンスへのマッピングです。`linear`、`scaled_linear`、または`squaredcos_cap_v2`から選択します。 | |
| trained_betas (`np.ndarray` または `list[float]`、*任意*) : `beta_start` と `beta_end` をバイパスして、ベータの配列を直接コンストラクタに渡す場合に使用します。 | |
| original_inference_steps (`int`、デフォルトは`50`) : 線形間隔のタイムステップスケジュールを生成するために使用されるデフォルトの推論ステップ数です。最終的に、このスケジュールから`num_inference_steps`個の等間隔のタイムステップを抽出して、最終的なタイムステップスケジュールを形成します。 | |
| clip_sample (`bool`、デフォルトは `False`) : 数値の安定性を確保するために、予測サンプルをクリップします。 | |
| clip_sample_range (`float`、デフォルトは`1.0`) : サンプルクリッピングの最大振幅。`clip_sample=True`の場合にのみ有効です。 | |
| set_alpha_to_one (`bool`、デフォルトは`True`) : 各拡散ステップでは、そのステップと直前のステップのアルファの積の値が使用されます。最終ステップには直前のアルファが存在しません。このオプションが`True`の場合、直前のアルファの積は`1`に固定され、それ以外の場合はステップ0のアルファの値が使用されます。 | |
| steps_offset (`int`、デフォルトは`0`) : 一部のモデルファミリーで必要とされる、推論ステップに追加されるオフセットです。 | |
| prediction_type (`str`, defaults to `"epsilon"`) : Prediction type of the scheduler function; can be `epsilon` (predicts the noise of the diffusion process), `sample` (directly predicts the noisy sample`) or `v_prediction` (see section 2.4 of [Imagen Video](https://huggingface.co/papers/2210.02303) paper). | |
| thresholding (`bool`、デフォルトは`False`) : 「動的閾値処理」メソッドを使用するかどうか。Stable Diffusion などの潜在空間拡散モデルには適していません。 | |
| dynamic_thresholding_ratio (`float`、デフォルトは`0.995`) : 動的閾値化手法における比率。`thresholding=True`の場合にのみ有効です。 | |
| sample_max_value (`float`、デフォルトは`1.0`) : 動的閾値処理の閾値。`thresholding=True`の場合にのみ有効です。 | |
| timestep_spacing (`str`, defaults to `"leading"`) : The way the timesteps should be scaled. Refer to Table 2 of the [Common Diffusion Noise Schedules and Sample Steps are Flawed](https://huggingface.co/papers/2305.08891) for more information. | |
| timestep_scaling (`float`、デフォルトは `10.0`) : 一貫性モデルの境界条件 `c_skip` と `c_out` を計算する際に、タイムステップに掛けられる係数です。この値を大きくすると、近似誤差は小さくなります(ただし、デフォルトの `10.0` における近似誤差はすでにかなり小さいです)。 | |
| rescale_betas_zero_snr (`bool`、デフォルトは`False`) : ベータを再スケーリングして、終端SNRをゼロにするかどうか。これにより、モデルは中間の明るさに限定されず、非常に明るく暗いサンプルを生成できるようになります。[`--offset_noise`](https://github.com/huggingface/diffusers/blob/74fd735eb073eb1d774b1ab4154a0876eb82f055/examples/dreambooth/train_dreambooth.py#L506)とゆるく関連しています。 | |
| `LCMScheduler` は、非マルコフ的ガイダンスを用いて、DDPM(denoising diffusion probabilistic models)で導入されたデノイジング手順を拡張します。 | |
| このモデルは [SchedulerMixin](/docs/diffusers/main/ja/api/schedulers/overview#diffusers.SchedulerMixin) と [ConfigMixin](/docs/diffusers/main/ja/api/configuration#diffusers.ConfigMixin) を継承しています。[~ConfigMixin](/docs/diffusers/main/ja/api/configuration#diffusers.ConfigMixin) は、`num_train_timesteps` のような、スケジューラの `__init__` 関数に渡されるすべての設定属性を保存する処理を担当します。これらは `scheduler.config.num_train_timesteps` を介してアクセスできます。[SchedulerMixin](/docs/diffusers/main/ja/api/schedulers/overview#diffusers.SchedulerMixin) は、[SchedulerMixin.save_pretrained()](/docs/diffusers/main/ja/api/schedulers/overview#diffusers.SchedulerMixin.save_pretrained) および [from_pretrained()](/docs/diffusers/main/ja/api/schedulers/overview#diffusers.SchedulerMixin.from_pretrained) 関数を通じて、一般的な読み込みおよび保存機能を提供します。 | |
| #### add_noise[[diffusers.LCMScheduler.add_noise]] | |
| ```python | |
| add_noise(original_samples: Tensor, noise: Tensor, timesteps: IntTensor) | |
| ``` | |
| [ソース](https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_lcm.py#L667) | |
| **パラメータ:** | |
| original_samples (`torch.Tensor`) : ノイズが加えられる元のサンプル。 | |
| noise (`torch.Tensor`) : サンプルに追加するノイズ。 | |
| timesteps (`torch.IntTensor`) : 各サンプルのノイズレベルを示すタイムステップ。 | |
| **戻り値:** `torch.Tensor` | |
| ノイズ付きサンプル。 | |
| 各タイムステップにおけるノイズの大きさに従って、元のサンプルにノイズを追加します(これはフォワード拡散プロセスです)。 | |
| #### get_scalings_for_boundary_condition_discrete[[diffusers.LCMScheduler.get_scalings_for_boundary_condition_discrete]] | |
| ```python | |
| get_scalings_for_boundary_condition_discrete(timestep: int) | |
| ``` | |
| [ソース](https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_lcm.py#L548) | |
| **パラメータ:** | |
| timestep (`int`) : スケーリングを計算する離散タイムステップ。 | |
| **戻り値:** `tuple[float, float]` | |
| `c_skip`(入力サンプルのスケーリング)と`c_out`(予測されたノイズ除去済みサンプルのスケーリング)を含むタプル。 | |
| Latent Consistency Model で使用される、与えられた離散タイムステップに対する境界条件のスケーリング(`c_skip` および `c_out`)を計算します。 | |
| #### get_velocity[[diffusers.LCMScheduler.get_velocity]] | |
| ```python | |
| get_velocity(sample: Tensor, noise: Tensor, timesteps: IntTensor) | |
| ``` | |
| [ソース](https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_lcm.py#L710) | |
| **パラメータ:** | |
| sample (`torch.Tensor`) : 入力サンプル。 | |
| noise (`torch.Tensor`) : ノイズのテンソル。 | |
| timesteps (`torch.IntTensor`) : 速度計算用のタイムステップ。 | |
| **戻り値:** `torch.Tensor` | |
| 計算された速度。 | |
| 速度の式に従って、サンプルとノイズから速度予測を計算します。 | |
| #### index_for_timestep[[diffusers.LCMScheduler.index_for_timestep]] | |
| ```python | |
| index_for_timestep(timestep: typing.Union[float, torch.Tensor], schedule_timesteps: typing.Optional[torch.Tensor] = None) | |
| ``` | |
| [ソース](https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_lcm.py#L262) | |
| **パラメータ:** | |
| timestep (`float` または `torch.Tensor`) : スケジュール内で検索するタイムステップの値。 | |
| schedule_timesteps (`torch.Tensor`, *任意*) : 検索対象のタイムステップスケジュール。`None` の場合は `self.timesteps` を使用します。 | |
| **戻り値:** `int` | |
| スケジュールにおけるタイムステップのインデックスです。最初のステップでは、スケジュールの途中から開始する場合(画像から画像への生成など)にシグマをスキップすることを避けるため、複数の一致が存在する場合は2番目のインデックスを返します。 | |
| 与えられたタイムステップのタイムステップスケジュールにおけるインデックスを特定します。 | |
| #### previous_timestep[[diffusers.LCMScheduler.previous_timestep]] | |
| ```python | |
| previous_timestep(timestep) | |
| ``` | |
| [ソース](https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_lcm.py#L755) | |
| **パラメータ:** | |
| timestep (`int`) : 現在のタイムステップ。 | |
| **戻り値:** `int` または `torch.Tensor` | |
| 直前のタイムステップ。 | |
| 拡散チェーンにおける直前のタイムステップを計算します。 | |
| #### scale_model_input[[diffusers.LCMScheduler.scale_model_input]] | |
| ```python | |
| scale_model_input(sample: Tensor, timestep: int | None = None) | |
| ``` | |
| [ソース](https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_lcm.py#L341) | |
| **パラメータ:** | |
| sample (`torch.Tensor`) : 入力サンプル。 | |
| timestep (`int`, *任意*) : 拡散チェーンにおける現在のタイムステップ。 | |
| **戻り値:** `torch.Tensor` | |
| スケーリングされた入力サンプル。 | |
| 現在のタイムステップに応じて、デノイジングモデルの入力をスケーリングする必要があるスケジューラとの相互運用性を保証します。 | |
| #### set_begin_index[[diffusers.LCMScheduler.set_begin_index]] | |
| ```python | |
| set_begin_index(begin_index: int = 0) | |
| ``` | |
| [ソース](https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_lcm.py#L331) | |
| **パラメータ:** | |
| begin_index (`int`、デフォルトは`0`) : スケジューラの開始インデックス。 | |
| スケジューラの開始インデックスを設定します。この関数は、推論の前にパイプラインから実行する必要があります。 | |
| #### set_timesteps[[diffusers.LCMScheduler.set_timesteps]] | |
| ```python | |
| set_timesteps(num_inference_steps: int | None = None, device: typing.Union[str, torch.device, NoneType] = None, original_inference_steps: int | None = None, timesteps: list[int] | None = None, strength: float = 1.0) | |
| ``` | |
| [ソース](https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_lcm.py#L402) | |
| **パラメータ:** | |
| num_inference_steps (`int`、*任意*) : 事前学習済みモデルでサンプルを生成する際に使用する拡散ステップ数。使用する場合、`timesteps` は `None` である必要があります。 | |
| device (`str` または `torch.device`、*任意*) : timesteps を移動先とするデバイスです。`None` の場合、timesteps は移動されません。 | |
| original_inference_steps (`int`, *optional*) : 元の推論ステップ数です。線形間隔のタイムステップスケジュールを生成するために使用されます(`diffusers` の標準的な実装とは異なります)。その後、このスケジュールからインデックスの観点で等間隔に`num_inference_steps`個のタイムステップを抽出し、それを最終的なタイムステップスケジュールとして使用します。設定されていない場合、`original_inference_steps` 属性の値がデフォルトとして使用されます。 | |
| timesteps (`list[int]`, *任意*) : 任意の間隔でタイムステップをサポートするために使用するカスタムタイムステップ。`None` の場合、学習/蒸留のタイムステップスケジュール上でタイムステップ間に等間隔を設けるデフォルトのタイムステップ間隔戦略が使用されます。`timesteps` が渡された場合、`num_inference_steps` は `None` でなければなりません。 | |
| strength (`float`、デフォルトは`1.0`) : 部分タイムステップスケジュール(画像から画像への生成など)を生成するために使用される強度係数。`1.0`の場合、完全なスケジュールが使用されます。 | |
| **戻り値:** `None` | |
| 拡散チェーンで使用される離散タイムステップを設定します(推論の実行前に実行する必要があります)。 | |
| #### ステップ[[diffusers.LCMScheduler.step]] | |
| ```python | |
| step(model_output: Tensor, timestep: int, sample: Tensor, generator: typing.Optional[torch.Generator] = None, return_dict: bool = True) | |
| ``` | |
| [ソース](https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_lcm.py#L569) | |
| **パラメータ:** | |
| model_output (`torch.Tensor`) : 学習済み拡散モデルからの直接の出力です。 | |
| timestep (`int`) : 拡散チェーンにおける現在の離散タイムステップ。 | |
| sample (`torch.Tensor`) : 拡散プロセスによって生成されたサンプルの現在のインスタンス。 | |
| generator (`torch.Generator`, *任意*) : 再現可能なサンプリングのための乱数生成器。 | |
| return_dict (`bool`、デフォルトは`True`) : `LCMSchedulerOutput`を返すか、`tuple`を返すかを指定します。 | |
| **戻り値:** `LCMSchedulerOutput` または `tuple` | |
| `True` の場合、`LCMSchedulerOutput` が返され、それ以外の場合は、最初の要素がサンプルテンソルであるタプルが返されます。 | |
| 前回のタイムステップからのサンプルを、SDEを逆方向に適用することで予測します。この関数は、学習済みモデルの出力(最もよく使われるのは予測ノイズ)から拡散過程を伝播させます。 | |
Xet Storage Details
- Size:
- 15.2 kB
- Xet hash:
- cf1e3b106b20110b6856c718f70cba8fefa9f2d6c4e1dc44b2baf9bddbb22f7e
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.