Diffusers documentation

DDPM

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

DDPM

Jonathan Ho、Ajay Jain、Pieter Abbeel による Denoising Diffusion Probabilistic Models (DDPM) は、同名の拡散ベースのモデルを提案しています。🤗 Diffusers ライブラリでは、DDPM は論文の discrete denoising scheduler およびパイプラインを指します。

論文の抄録は以下の通りです:

非平衡熱力学の考察に着想を得た潜在変数モデルの一種である拡散確率モデルを用いた、高品質な画像合成の結果を提示します。私たちの最良の結果は、拡散確率モデルと Langevin 動力学を用いたノイズ除去スコアマッチングとの間の新たな関連性に基づいて設計された加重変分境界で訓練することで得られ、私たちのモデルは、自己回帰デコーディングの一般化と解釈できる漸進的有圧縮スキームを自然に許容します。無条件 CIFAR10 データセットでは、Inception スコア 9.46 と、最先端の FID スコア 3.17 を達成しました。256x256 の LSUN では、ProgressiveGAN と同様のサンプル品質を得ました。

元のコードベースは hohonathanho/diffusion で確認できます。

スケジューラーのトレードオフ、すなわち速度と品質のバランスをどのように探求するかを学ぶには、ガイドを必ずご確認ください。また、同じコンポーネントを複数のパイプラインに効率的に読み込む方法については、パイプライン間でコンポーネントを再利用するセクションを参照してください。

DDPMPipeline

class diffusers.DDPMPipeline

< >

( unet: UNet2DModelscheduler: DDPMScheduler )

パラメータ

  • unet (UNet2DModel) — エンコードされた画像の潜在変数からノイズを除去するためのUNet2DModel。
  • scheduler (SchedulerMixin) — unet と組み合わせて、エンコードされた画像のノイズ除去に使用するスケジューラ。DDPMScheduler または DDIMScheduler のいずれかです。

画像生成用のPipeline。

このモデルは DiffusionPipeline を継承しています。すべてのパイプラインに実装されている汎用的なメソッド(ダウンロード、保存、特定のデバイスでの実行など)については、スーパークラスのドキュメントを参照してください。

__call__

< >

( batch_size: int = 1generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = Nonenum_inference_steps: int = 1000output_type: str | None = 'pil'return_dict: bool = True ) → ImagePipelineOutput or tuple

パラメータ

  • batch_size (int、任意、デフォルトは 1)— 生成する画像の数を指定します。
  • generator (torch.Generator、省略可) — 生成を決定論的にするためのtorch.Generator。
  • num_inference_steps (int、任意、デフォルト値は 1000)— デノイジングのステップ数です。デノイジングのステップ数を増やすと、推論速度が遅くなる代わりに、通常はより高品質な画像が得られます。
  • output_type (str, 任意、デフォルトは "pil") — 生成された画像の出力形式です。"pil" (PIL.Image)、"np" (np.array)、または "pt" (torch.Tensor) から選択します。
  • return_dict (bool, optional, defaults to True) — Whether or not to return a ImagePipelineOutput instead of a plain tuple.

戻り値

ImagePipelineOutput または tuple

return_dict が True の場合、ImagePipelineOutput が返され、それ以外の場合は tuple が返されます。このとき、最初の要素は生成された画像のリストです。

生成用の pipeline への呼び出し関数。

例:

>>> from diffusers import DDPMPipeline

>>> # load model and scheduler
>>> pipe = DDPMPipeline.from_pretrained("google/ddpm-cat-256")

>>> # run pipeline in inference (sample random noise and denoise)
>>> image = pipe().images[0]

>>> # save image
>>> image.save("ddpm_generated_image.png")

ImagePipelineOutput

class diffusers.ImagePipelineOutput

< >

( images: list[PIL.Image.Image] | numpy.ndarray )

パラメータ

  • images (List[PIL.Image.Image] または np.ndarray) — batch_size 長さのデノイズ済み PIL 画像のリスト、または (batch_size, height, width, num_channels) の形状を持つ NumPy 配列です。

画像パイプライン用の出力クラス。

Update on GitHub