Diffusers 文档
DDPM
并获取增强的文档体验
开始使用
DDPM
Denoising Diffusion Probabilistic Models (DDPM) 由 Jonathan Ho、Ajay Jain 和 Pieter Abbeel 提出了一种同名的基于扩散的模型。在 🤗 Diffusers 库中,DDPM 指的是论文中的*离散去噪 scheduler* 以及 pipeline。
论文摘要如下:
我们展示了使用扩散概率模型合成高质量图像的结果,扩散概率模型是一类受非平衡热力学考虑启发的隐变量模型。我们的最佳结果是通过在加权变分界上训练获得的,该变分界根据扩散概率模型和使用 Langevin 动力学的去噪分数匹配之间的新颖联系而设计,并且我们的模型自然地允许一种渐进的、有损的解压缩方案,该方案可以被解释为自回归解码的推广。在无条件 CIFAR10 数据集上,我们获得了 9.46 的 Inception 分数和 3.17 的最先进 FID 分数。在 256x256 LSUN 上,我们获得了与 ProgressiveGAN 相似的样本质量。
原始代码库可以在以下位置找到: hohonathanho/diffusion.
请务必查看 Schedulers 指南,了解如何探索 scheduler 速度和质量之间的权衡,并查看跨 pipelines 重用组件 部分,了解如何有效地将相同的组件加载到多个 pipelines 中。
DDPMPipeline
class diffusers.DDPMPipeline
< source >( unet scheduler )
参数
- unet (UNet2DModel) — 用于去噪编码图像 latent 的
UNet2DModel
。 - scheduler (SchedulerMixin) — 与
unet
结合使用的调度器,用于对编码后的图像进行去噪。 可以是 DDPMScheduler 或 DDIMScheduler 之一。
用于图像生成的 Pipeline。
此模型继承自 DiffusionPipeline。 查看超类文档以获取所有 pipeline 通用的方法(下载、保存、在特定设备上运行等)。
__call__
< source >( 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 ) → ImagePipelineOutput 或 tuple
参数
- batch_size (
int
, 可选,默认为 1) — 要生成的图像数量。 - generator (
torch.Generator
, 可选) — 用于使生成具有确定性的torch.Generator
。 - num_inference_steps (
int
, 可选,默认为 1000) — 去噪步骤的数量。 更多的去噪步骤通常会以较慢的推理速度为代价带来更高质量的图像。 - output_type (
str
, 可选,默认为"pil"
) — 生成图像的输出格式。 在PIL.Image
或np.array
之间选择。 - return_dict (
bool
, 可选,默认为True
) — 是否返回 ImagePipelineOutput 而不是普通 tuple。
返回
ImagePipelineOutput 或 tuple
如果 return_dict
为 True
,则返回 ImagePipelineOutput,否则返回一个 tuple
,其中第一个元素是包含生成图像的列表
pipeline 的调用函数,用于生成。
ImagePipelineOutput
class diffusers.ImagePipelineOutput
< source >( images: typing.Union[typing.List[PIL.Image.Image], numpy.ndarray] )
图像 pipeline 的输出类。