Diffusers documentation

输出

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

输出

所有模型输出都是 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]

要查看特定流水线或模型的输出,请参阅其对应的 API 文档。

BaseOutput

class diffusers.utils.BaseOutput

< >

( )

所有模型输出的基类,以 dataclass 形式实现。具有 __getitem__ 方法,支持通过整数或切片(类似元组)或字符串(类似字典)进行索引,且会忽略 None 属性。其他行为与普通 Python 字典一致。

> 无法直接解包 BaseOutput。请先使用 to_tuple() 方法将其转换为元组 >。

to_tuple

< >

( )

将 self 转换为一个元组,其中包含所有不为 None 的属性/键。

ImagePipelineOutput

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

图像流水线输出类。

AudioPipelineOutput

类 diffusers.AudioPipelineOutput

< >

( audios: ndarray )

参数

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

音频管道的输出类。

ImageTextPipelineOutput

class diffusers.ImageTextPipelineOutput

< >

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

参数

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

用于联合图像-文本流水线的输出类。

Update on GitHub