出力
すべてのモデルの出力は、モデルが返すすべての情報を含むデータ構造である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
すべてのモデル出力の基底クラスであり、dataclass として実装されています。__getitem__ を備えており、整数やスライス(タプルと同様)または文字列(辞書と同様)によるインデックス指定が可能です。この際、None の属性は無視されます。それ以外の動作は、通常の Python 辞書と同様です。
>
BaseOutputを直接アンパックすることはできません。まず to_tuple() メソッドを使用してタプルに変換してください。
None 以外のすべての属性/キーを含むタプルに self を変換します。
ImagePipelineOutput
class diffusers.ImagePipelineOutput
< source >( images: list[PIL.Image.Image] | numpy.ndarray )
画像パイプライン用の出力クラス。
AudioPipelineOutput
class diffusers.AudioPipelineOutput
< source >( audios: ndarray )
音声パイプライン用の出力クラス。
ImageTextPipelineOutput
class diffusers.ImageTextPipelineOutput
< source >( images: list[PIL.Image.Image] | numpy.ndarray | Nonetext: list[str] | list[list[str]] | None )
画像とテキストのジョイントパイプライン用の出力クラス。