Diffusers 文档
输出
并获得增强的文档体验
开始使用
输出
所有模型输出都是 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
所有模型输出作为数据类的基类。具有一个 __getitem__
方法,允许通过整数或切片(如元组)或字符串(如字典)进行索引,这将忽略 None
属性。否则,它的行为与普通的 Python 字典相同。
您不能直接解包 BaseOutput
。请使用 to_tuple() 方法将其转换为元组。
将自身转换为包含所有非 None
属性/键的元组。
ImagePipelineOutput
class diffusers.ImagePipelineOutput
< 来源 >( images: typing.Union[typing.List[PIL.Image.Image], numpy.ndarray] )
图像流水线的输出类。
FlaxImagePipelineOutput
class diffusers.pipelines.pipeline_flax_utils.FlaxImagePipelineOutput
< 来源 >( images: typing.Union[typing.List[PIL.Image.Image], numpy.ndarray] )
图像流水线的输出类。
返回一个新对象,用新值替换指定的字段。
AudioPipelineOutput
class diffusers.AudioPipelineOutput
< 来源 >( audios: ndarray )
音频流水线的输出类。
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] )
联合图像-文本流水线的输出类。