Diffusers 文档

输出

Hugging Face's logo
加入 Hugging Face 社区

并获得增强的文档体验

开始使用

输出

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

< >

( )

所有模型输出作为数据类的基类。具有一个 __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 数组。

图像流水线的输出类。

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

图像流水线的输出类。

替换

< >

( **updates )

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

AudioPipelineOutput

class diffusers.AudioPipelineOutput

< >

( audios: ndarray )

参数

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

音频流水线的输出类。

ImageTextPipelineOutput

class 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]np.ndarray) — 长度为 batch_size 的去噪 PIL 图像列表或形状为 (batch_size, height, width, num_channels) 的 NumPy 数组。
  • text (List[str]List[List[str]]) — 长度为 batch_size 的生成文本字符串列表,或其外部列表长度为 batch_size 的字符串列表的列表。

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

< > 在 GitHub 上更新