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