Buckets:
| # DEISMultistepScheduler | |
| Diffusion Exponential Integrator Sampler (DEIS) は、Qinsheng Zhang と Yongxin Chen による [Fast Sampling of Diffusion Models with Exponential Integrator](https://huggingface.co/papers/2204.13902) で提案されました。`DEISMultistepScheduler` は、拡散常微分方程式 (ODE) に対する高速な高次ソルバーです。 | |
| この実装では、DEIS論文の元の線形`t`空間ではなく、log-rho空間における多項式フィッティングの式を変更しています。この変更により、数値ソルバーに依存する代わりに、指数型多段更新に対して閉形式の係数が得られます。 | |
| 論文の抄録は以下の通りです: | |
| *ここ数年、Diffusion models~(DMs)は生成モデリングタスクにおいて高忠実度のサンプルを生成する上で大きな成功を収めています。DMの主要な制約の一つは、その悪名高い低速なサンプリング手順であり、通常、学習された拡散過程の数百から数千の時間離散化ステップを必要とします。私たちの目標は、サンプル品質を維持しながら、はるかに少ないステップ数でDMの高速サンプリング手法を開発することです。そのために、DMにおけるサンプリング手順を体系的に分析し、サンプル品質に影響を与える主要な要因を特定しました。その中でも、離散化手法が最も重要です。学習された拡散過程を慎重に検討することで、Diffusion Exponential Integrator Sampler~(DEIS)を提案します。これは、常微分方程式 (ODEs) の離散化のために設計されたExponential Integratorに基づいており、学習された拡散過程の半線形構造を活用して離散化誤差を低減します。提案手法は任意のDMに適用可能であり、わずか10ステップで高忠実度のサンプルを生成できます。実験では、1つのA6000 GPU上で約3分でCIFAR10から50k枚の画像を生成しました。さらに、事前学習済みDMを直接使用することで、スコア関数評価~(NFE) の回数が制限されている場合でも、最先端のサンプリング性能を達成しました。例えば、CIFAR10では10 NFEで4.17 FID、15 NFEのみで3.37 FIDおよび9.74 ISを達成しています。コードは[this https URL](https://github.com/qsh-zh/deis)で入手できます。* | |
| ## ヒント | |
| `solver_order` は 2 または 3 に設定することをお勧めします。`solver_order=1` は [DDIMScheduler](/docs/diffusers/main/ja/api/schedulers/ddim#diffusers.DDIMScheduler) と同等です。 | |
| [Imagen](https://huggingface.co/papers/2205.11487) の動的閾値化はサポートされており、ピクセル空間の拡散モデルでは、`thresholding=True` を設定することで動的閾値化を使用できます。 | |
| ## DEISMultistepScheduler[[diffusers.DEISMultistepScheduler]] | |
| #### diffusers.DEISMultistepScheduler[[diffusers.DEISMultistepScheduler]] | |
| ```python | |
| diffusers.DEISMultistepScheduler(num_train_timesteps: int = 1000, beta_start: float = 0.0001, beta_end: float = 0.02, beta_schedule: typing.Literal['linear', 'scaled_linear', 'squaredcos_cap_v2'] = 'linear', trained_betas: numpy.ndarray | list[float] | None = None, solver_order: int = 2, prediction_type: typing.Literal['epsilon', 'sample', 'v_prediction', 'flow_prediction'] = 'epsilon', thresholding: bool = False, dynamic_thresholding_ratio: float = 0.995, sample_max_value: float = 1.0, algorithm_type: typing.Literal['deis'] = 'deis', solver_type: typing.Literal['logrho'] = 'logrho', lower_order_final: bool = True, use_karras_sigmas: bool = False, use_exponential_sigmas: bool = False, use_beta_sigmas: bool = False, use_flow_sigmas: bool = False, flow_shift: float = 1.0, timestep_spacing: typing.Literal['linspace', 'leading', 'trailing'] = 'linspace', steps_offset: int = 0, use_dynamic_shifting: bool = False, time_shift_type: typing.Literal['exponential'] = 'exponential') | |
| ``` | |
| [ソース](https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_deis_multistep.py#L86) | |
| **パラメータ:** | |
| num_train_timesteps (`int`、デフォルトは`1000`) : モデルを学習するための拡散ステップ数。 | |
| beta_start (`float`、デフォルトは`0.0001`) : 推論の初期`beta`値。 | |
| beta_end (`float`、デフォルトは `0.02`) : 最終的な `beta` の値。 | |
| beta_schedule (`"linear"`、`"scaled_linear"`、または `"squaredcos_cap_v2"`、デフォルトは `"linear"`) : ベータスケジュール。ベータの範囲から、モデルのステップ処理に使用するベータのシーケンスへのマッピングです。`linear`、`scaled_linear`、または `squaredcos_cap_v2` から選択します。 | |
| trained_betas (`np.ndarray` または `list[float]`、*任意*) : `beta_start` と `beta_end` をバイパスして、ベータの配列を直接コンストラクタに渡す場合に使用します。 | |
| solver_order (`int`、デフォルトは`2`) : `1`、`2`、`3`のいずれかを取れるDEISのオーダーです。ガイド付きサンプリングには`solver_order=2`、無条件サンプリングには`solver_order=3`の使用を推奨します。 | |
| prediction_type (`"epsilon"`, `"sample"`, `"v_prediction"`, or `"flow_prediction"`, 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`), `v_prediction` (see section 2.4 of [Imagen Video](https://huggingface.co/papers/2210.02303) paper), or `flow_prediction`. | |
| thresholding (`bool`、デフォルトは`False`) : 「動的閾値処理」メソッドを使用するかどうか。Stable Diffusion などの潜在空間拡散モデルには適していません。 | |
| dynamic_thresholding_ratio (`float`、デフォルトは`0.995`) : 動的閾値化手法における比率。`thresholding=True`の場合にのみ有効です。 | |
| sample_max_value (`float`、デフォルトは`1.0`) : 動的閾値処理の閾値。`thresholding=True`の場合にのみ有効です。 | |
| algorithm_type (`"deis"`、デフォルトは`"deis"`) : ソルバーのアルゴリズムタイプ。 | |
| solver_type (`"logrho"`、デフォルトは `"logrho"`) : DEIS のソルバータイプ。 | |
| lower_order_final (`bool`、デフォルトは`True`) : 最終ステップで低次数のソルバーを使用するかどうか。推論ステップ数が15未満の場合のみ有効です。 | |
| use_karras_sigmas (`bool`, *任意*, デフォルトは `False`) : サンプリングプロセス中のノイズスケジュールにおけるステップサイズに Karras シグマを使用するかどうか。`True` の場合、シグマはノイズレベルの列 {σi} に基づいて決定されます。 | |
| use_exponential_sigmas (`bool`、*任意*、デフォルトは`False`) : サンプリングプロセス中のノイズスケジュールにおいて、ステップサイズに指数シグマを使用するかどうか。 | |
| use_beta_sigmas (`bool`, *optional*, defaults to `False`) : Whether to use beta sigmas for step sizes in the noise schedule during the sampling process. Refer to [Beta Sampling is All You Need](https://huggingface.co/papers/2407.12173) for more information. | |
| use_flow_sigmas (`bool`、*任意*、デフォルトは`False`) : サンプリングプロセス中のノイズスケジュールにおいて、ステップサイズにフローシグマを使用するかどうか。 | |
| flow_shift (`float`、*任意*、デフォルトは `1.0`) : フローベースモデルのフローシフトパラメータです。 | |
| timestep_spacing (`"linspace"`, `"leading"`, or `"trailing"`, defaults to `"linspace"`) : 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. | |
| steps_offset (`int`、デフォルトは`0`) : 一部のモデルファミリーで必要とされる、推論ステップに追加されるオフセットです。 | |
| use_dynamic_shifting (`bool`、デフォルトは`False`) : ノイズスケジュールに動的シフトを使用するかどうか。 | |
| time_shift_type (`"exponential"`、デフォルトは`"exponential"`) : 適用する時間シフトの種類。 | |
| `DEISMultistepScheduler` は、拡散常微分方程式(ODE)を解く高速な高次ソルバーです。 | |
| このモデルは [SchedulerMixin](/docs/diffusers/main/ja/api/schedulers/overview#diffusers.SchedulerMixin) と [ConfigMixin](/docs/diffusers/main/ja/api/configuration#diffusers.ConfigMixin) を継承しています。読み込みや保存など、ライブラリがすべてのスケジューラに対して実装している汎用的なメソッドについては、スーパークラスのドキュメントを参照してください。 | |
| #### add_noise[[diffusers.DEISMultistepScheduler.add_noise]] | |
| ```python | |
| add_noise(original_samples: Tensor, noise: Tensor, timesteps: IntTensor) | |
| ``` | |
| [ソース](https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_deis_multistep.py#L997) | |
| **パラメータ:** | |
| original_samples (`torch.Tensor`) : ノイズが加えられていない元のサンプル。 | |
| noise (`torch.Tensor`) : サンプルに追加するノイズ。 | |
| timesteps (`torch.IntTensor`) : サンプルにノイズを付加するタイムステップ。 | |
| **戻り値:** `torch.Tensor` | |
| ノイズ付きサンプル。 | |
| 指定されたタイムステップにおけるノイズスケジュールに従って、元のサンプルにノイズを追加します。 | |
| #### convert_model_output[[diffusers.DEISMultistepScheduler.convert_model_output]] | |
| ```python | |
| convert_model_output(model_output: Tensor, *args, sample: Tensor = None, **kwargs) | |
| ``` | |
| [ソース](https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_deis_multistep.py#L581) | |
| **パラメータ:** | |
| model_output (`torch.Tensor`) : 学習済み拡散モデルからの直接の出力です。 | |
| timestep (`int`) : 拡散チェーンにおける現在の離散タイムステップ。 | |
| sample (`torch.Tensor`) : 拡散プロセスによって生成されたサンプルの現在のインスタンス。 | |
| **戻り値:** `torch.Tensor` | |
| 変換後のモデルの出力。 | |
| DEISアルゴリズムが要求する対応する型に、モデルの出力を変換します。 | |
| #### deis_first_order_update[[diffusers.DEISMultistepScheduler.deis_first_order_update]] | |
| ```python | |
| deis_first_order_update(model_output: Tensor, *args, sample: Tensor = None, **kwargs) | |
| ``` | |
| [ソース](https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_deis_multistep.py#L641) | |
| **パラメータ:** | |
| model_output (`torch.Tensor`) : 学習済み拡散モデルからの直接の出力です。 | |
| timestep (`int`) : 拡散チェーンにおける現在の離散タイムステップ。 | |
| prev_timestep (`int`) : 拡散チェーンにおける直前の離散タイムステップ。 | |
| sample (`torch.Tensor`) : 拡散プロセスによって生成されたサンプルの現在のインスタンス。 | |
| **戻り値:** `torch.Tensor` | |
| 前のタイムステップのサンプルテンソル。 | |
| 1次DEIS(DDIMと同等)の1ステップ。 | |
| #### index_for_timestep[[diffusers.DEISMultistepScheduler.index_for_timestep]] | |
| ```python | |
| index_for_timestep(timestep: typing.Union[int, torch.Tensor], schedule_timesteps: typing.Optional[torch.Tensor] = None) | |
| ``` | |
| [ソース](https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_deis_multistep.py#L864) | |
| **パラメータ:** | |
| timestep (`int` または `torch.Tensor`) : インデックスを特定するためのタイムステップ。 | |
| schedule_timesteps (`torch.Tensor`, *任意*) : 検索対象のタイムステップスケジュール。`None` の場合は `self.timesteps` を使用します。 | |
| **戻り値:** `int` | |
| スケジュールにおけるタイムステップのインデックス。 | |
| スケジュール内の指定されたタイムステップのインデックスを取得します。 | |
| #### multistep_deis_second_order_update[[diffusers.DEISMultistepScheduler.multistep_deis_second_order_update]] | |
| ```python | |
| multistep_deis_second_order_update(model_output_list: list[torch.Tensor], *args, sample: Tensor = None, **kwargs) | |
| ``` | |
| [ソース](https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_deis_multistep.py#L702) | |
| **パラメータ:** | |
| model_output_list (`list[torch.Tensor]`) : 学習済み拡散モデルが現在のタイムステップおよびその後のタイムステップで直接出力する値。 | |
| sample (`torch.Tensor`) : 拡散プロセスによって生成されたサンプルの現在のインスタンス。 | |
| **戻り値:** `torch.Tensor` | |
| 前のタイムステップのサンプルテンソル。 | |
| 2次多段DEISの1ステップ。 | |
| #### multistep_deis_third_order_update[[diffusers.DEISMultistepScheduler.multistep_deis_third_order_update]] | |
| ```python | |
| multistep_deis_third_order_update(model_output_list: list[torch.Tensor], *args, sample: Tensor = None, **kwargs) | |
| ``` | |
| [ソース](https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_deis_multistep.py#L775) | |
| **パラメータ:** | |
| model_output_list (`list[torch.Tensor]`) : 学習済み拡散モデルが現在のタイムステップおよびその後のタイムステップで直接出力する値。 | |
| sample (`torch.Tensor`) : 拡散プロセスによって生成されたサンプルの現在のインスタンス。 | |
| **戻り値:** `torch.Tensor` | |
| 前のタイムステップのサンプルテンソル。 | |
| 3次多ステップDEISの1ステップ。 | |
| #### scale_model_input[[diffusers.DEISMultistepScheduler.scale_model_input]] | |
| ```python | |
| scale_model_input(sample: Tensor, *args, **kwargs) | |
| ``` | |
| [ソース](https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_deis_multistep.py#L981) | |
| **パラメータ:** | |
| sample (`torch.Tensor`) : 入力サンプル。 | |
| **戻り値:** `torch.Tensor` | |
| スケーリングされた入力サンプル。 | |
| 現在のタイムステップに応じて、デノイジングモデルの入力をスケーリングする必要があるスケジューラとの相互運用性を保証します。 | |
| #### set_begin_index[[diffusers.DEISMultistepScheduler.set_begin_index]] | |
| ```python | |
| set_begin_index(begin_index: int = 0) | |
| ``` | |
| [ソース](https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_deis_multistep.py#L262) | |
| **パラメータ:** | |
| begin_index (`int`、デフォルトは`0`) : スケジューラの開始インデックス。 | |
| スケジューラの開始インデックスを設定します。この関数は、推論の前にパイプラインから実行する必要があります。 | |
| #### set_timesteps[[diffusers.DEISMultistepScheduler.set_timesteps]] | |
| ```python | |
| set_timesteps(num_inference_steps: int, device: typing.Union[str, torch.device] = None, mu: float | None = None) | |
| ``` | |
| [ソース](https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_deis_multistep.py#L272) | |
| **パラメータ:** | |
| num_inference_steps (`int`) : 事前学習済みモデルでサンプルを生成する際に使用される拡散ステップの数。 | |
| device (`str` または `torch.device`、*任意*) : timesteps を移動先とするデバイスです。`None` の場合、timesteps は移動されません。 | |
| mu (`float`, *任意*) : 動的シフト用の mu パラメータ。`use_dynamic_shifting=True` かつ `time_shift_type="exponential"` の場合のみ使用されます。 | |
| 拡散チェーンで使用される離散タイムステップを設定します(推論の実行前に実行する必要があります)。 | |
| #### ステップ[[diffusers.DEISMultistepScheduler.step]] | |
| ```python | |
| step(model_output: Tensor, timestep: typing.Union[int, torch.Tensor], sample: Tensor, return_dict: bool = True) | |
| ``` | |
| [ソース](https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_deis_multistep.py#L917) | |
| **パラメータ:** | |
| model_output (`torch.Tensor`) : 学習済み拡散モデルからの直接の出力です。 | |
| timestep (`int` または `torch.Tensor`) : 拡散チェーンにおける現在の離散タイムステップ。 | |
| sample (`torch.Tensor`) : 拡散プロセスによって生成されたサンプルの現在のインスタンス。 | |
| return_dict (`bool`、デフォルトは`True`) : [SchedulerOutput](/docs/diffusers/main/ja/api/schedulers/ipndm#diffusers.schedulers.scheduling_utils.SchedulerOutput)を返すか、`tuple`を返すかを指定します。 | |
| **戻り値:** [SchedulerOutput](/docs/diffusers/main/ja/api/schedulers/ipndm#diffusers.schedulers.scheduling_utils.SchedulerOutput) または `tuple` | |
| `True` の場合、[SchedulerOutput](/docs/diffusers/main/ja/api/schedulers/ipndm#diffusers.schedulers.scheduling_utils.SchedulerOutput) が返され、それ以外の場合は、最初の要素がサンプルテンソルであるタプルが返されます。 | |
| 前のタイムステップのサンプルをSDEを逆方向に適用することで予測します。この関数は、マルチステップDEISを用いてサンプルを伝播します。 | |
| ## SchedulerOutput[[diffusers.schedulers.scheduling_utils.SchedulerOutput]] | |
| #### diffusers.schedulers.scheduling_utils.SchedulerOutput[[diffusers.schedulers.scheduling_utils.SchedulerOutput]] | |
| ```python | |
| diffusers.schedulers.scheduling_utils.SchedulerOutput(prev_sample: Tensor) | |
| ``` | |
| [ソース](https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_utils.py#L66) | |
| **パラメータ:** | |
| prev_sample (`torch.Tensor`、画像の場合は `(batch_size, num_channels, height, width)` の形状) : 前のタイムステップの計算済みサンプル `(x_{t-1})`。`prev_sample` は、デノイジングループの次のモデル入力として使用する必要があります。 | |
| スケジューラーの`step`関数の出力の基底クラス。 | |
Xet Storage Details
- Size:
- 18.2 kB
- Xet hash:
- d4cb830e5bf9bbf86830a16d48fa1385d9d7cc074faa2810426fe35af8c16f32
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.