Diffusers 文档

输出

Hugging Face's logo
加入 Hugging Face 社区

并获得增强的文档体验

开始使用

输出

所有模型输出都是 BaseOutput 的子类,BaseOutput 是包含模型返回的所有信息的数据结构。输出也可以用作元组或字典。

例如

from diffusers import DDIMPipeline

pipeline = DDIMPipeline.from_pretrained("google/ddpm-cifar10-32")
outputs = pipeline()

outputs 对象是一个 ImagePipelineOutput,这意味着它具有 image 属性。

您可以像往常一样或使用关键字查找来访问每个属性,如果模型未返回该属性,您将获得 None

outputs.images
outputs["images"]

当将 outputs 对象视为元组时,它仅考虑不具有 None 值的属性。例如,通过索引检索图像会返回元组 (outputs.images)

outputs[:1]

要检查特定的 pipeline 或模型输出,请参阅其相应的 API 文档。

BaseOutput

class diffusers.utils.BaseOutput

< >

( )

所有模型输出的基类,作为数据类。具有 __getitem__,允许通过整数或切片(如元组)或字符串(如字典)进行索引,这将忽略 None 属性。否则,行为类似于常规 Python 字典。

您不能直接解包 BaseOutput。使用 to_tuple() 方法首先将其转换为元组。

to_tuple

< >

( )

将自身转换为包含所有非 None 属性/键的元组。

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 数组。

图像 pipelines 的输出类。

FlaxImagePipelineOutput

class diffusers.pipelines.pipeline_flax_utils.FlaxImagePipelineOutput

< >

( 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 数组。

图像 pipelines 的输出类。

replace

< >

( **updates )

返回一个新对象,用新值替换指定的字段。

AudioPipelineOutput

class diffusers.AudioPipelineOutput

< >

( audios: ndarray )

参数

  • audios (np.ndarray) — 形状为 (batch_size, num_channels, sample_rate) 的 NumPy 数组的去噪音频样本列表。

音频 pipelines 的输出类。

ImageTextPipelineOutput

diffusers.ImageTextPipelineOutput

< >

( images: typing.Union[typing.List[PIL.Image.Image], numpy.ndarray, NoneType] text: typing.Union[typing.List[str], typing.List[typing.List[str]], NoneType] )

参数

  • images (List[PIL.Image.Image] or np.ndarray) — 长度为 batch_size 的去噪 PIL 图像列表或形状为 (batch_size, height, width, num_channels) 的 NumPy 数组。
  • text (List[str] or List[List[str]]) — 长度为 batch_size 的生成文本字符串列表,或外部列表长度为 batch_size 的字符串列表的列表。

用于联合图像-文本管道的输出类。

< > 在 GitHub 上更新