You are viewing main version, which requires installation from source. If you'd like
regular pip install, checkout the latest stable version (v0.42.1).
输出
所有模型输出都是 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
所有模型输出的基类,以 dataclass 形式实现。具有 __getitem__ 方法,支持通过整数或切片(类似元组)或字符串(类似字典)进行索引,且会忽略 None 属性。其他行为与普通 Python 字典一致。
> 无法直接解包
BaseOutput。请先使用 to_tuple() 方法将其转换为元组 >。
将 self 转换为一个元组,其中包含所有不为 None 的属性/键。
ImagePipelineOutput
类 diffusers.ImagePipelineOutput
< source >( images: list[PIL.Image.Image] | numpy.ndarray )
图像流水线输出类。
AudioPipelineOutput
类 diffusers.AudioPipelineOutput
< source >( audios: ndarray )
音频管道的输出类。
ImageTextPipelineOutput
class diffusers.ImageTextPipelineOutput
< source >( images: list[PIL.Image.Image] | numpy.ndarray | Nonetext: list[str] | list[list[str]] | None )
用于联合图像-文本流水线的输出类。