Diffusers 文件

DDPM

Hugging Face's logo
加入 Hugging Face 社群

並獲得增強的文件體驗

開始使用

DDPM

去噪擴散機率模型 (DDPM) 由 Jonathan Ho、Ajay Jain 和 Pieter Abbeel 提出,該模型是一個基於擴散的模型,名稱與論文相同。在 🤗 Diffusers 庫中,DDPM 指的是論文中的*離散去噪排程器*以及相應的管道。

論文摘要如下:

我們利用擴散機率模型(一種受非平衡熱力學啟發而建立的潛變數模型)取得了高質量影像合成結果。我們透過根據擴散機率模型與 Langevin 動力學去噪分數匹配之間的新穎聯絡設計的加權變分下界進行訓練,獲得了最佳結果。我們的模型自然支援漸進式有損解壓方案,該方案可解釋為自迴歸解碼的推廣。在無條件 CIFAR10 資料集上,我們獲得了 9.46 的 Inception 分數和 3.17 的最先進 FID 分數。在 256x256 LSUN 上,我們獲得了與 ProgressiveGAN 相似的樣本質量。

原始程式碼庫可在 hojonathanho/diffusion 找到。

請務必檢視排程器指南,瞭解如何探索排程器速度與質量之間的權衡,並參閱跨管道重用元件部分,瞭解如何高效地將相同元件載入到多個管道中。

DDPMPipeline

class diffusers.DDPMPipeline

< >

( unet: UNet2DModel scheduler: DDPMScheduler )

引數

影像生成管道。

此模型繼承自 DiffusionPipeline。請查閱超類文件,瞭解所有管道實現的通用方法(下載、儲存、在特定裝置上執行等)。

__call__

< >

( batch_size: int = 1 generator: typing.Union[torch._C.Generator, typing.List[torch._C.Generator], NoneType] = None num_inference_steps: int = 1000 output_type: typing.Optional[str] = 'pil' return_dict: bool = True ) ImagePipelineOutputtuple

引數

  • batch_size (int, 可選, 預設為 1) — 要生成的影像數量。
  • generator (torch.Generator, 可選) — 一個 torch.Generator 用於使生成具有確定性。
  • num_inference_steps (int, 可選, 預設為 1000) — 去噪步數。更多的去噪步數通常會產生更高質量的影像,但推理速度會變慢。
  • output_type (str, 可選, 預設為 "pil") — 生成影像的輸出格式。在 PIL.Imagenp.array 之間選擇。
  • return_dict (bool, 可選, 預設為 True) — 是否返回 ImagePipelineOutput 而不是普通元組。

返回

ImagePipelineOutputtuple

如果 return_dictTrue,則返回 ImagePipelineOutput,否則返回一個 tuple,其中第一個元素是生成的影像列表

用於生成的管道的呼叫函式。

示例

>>> 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: typing.Union[typing.List[PIL.Image.Image], numpy.ndarray] )

引數

  • images (List[PIL.Image.Image]np.ndarray) — 長度為 batch_size 的去噪 PIL 影像列表或形狀為 (batch_size, height, width, num_channels) 的 NumPy 陣列。

影像流水線的輸出類。

< > 在 GitHub 上更新

© . This site is unofficial and not affiliated with Hugging Face, Inc.