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 上更新

© . This site is unofficial and not affiliated with Hugging Face, Inc.