Diffusers 文件

AutoencoderKLWan

Hugging Face's logo
加入 Hugging Face 社群

並獲得增強的文件體驗

開始使用

AutoencoderKLWan

Alibaba Wan 團隊在 Wan 2.1 中使用的帶 KL 損失的 3D 變分自編碼器 (VAE) 模型。

該模型可以透過以下程式碼片段載入。

from diffusers import AutoencoderKLWan

vae = AutoencoderKLWan.from_pretrained("Wan-AI/Wan2.1-T2V-1.3B-Diffusers", subfolder="vae", torch_dtype=torch.float32)

AutoencoderKLWan

class diffusers.AutoencoderKLWan

< >

( base_dim: int = 96 z_dim: int = 16 dim_mult: typing.Tuple[int] = [1, 2, 4, 4] num_res_blocks: int = 2 attn_scales: typing.List[float] = [] temperal_downsample: typing.List[bool] = [False, True, True] dropout: float = 0.0 latents_mean: typing.List[float] = [-0.7571, -0.7089, -0.9113, 0.1075, -0.1745, 0.9653, -0.1517, 1.5508, 0.4134, -0.0715, 0.5517, -0.3632, -0.1922, -0.9497, 0.2503, -0.2921] latents_std: typing.List[float] = [2.8184, 1.4541, 2.3275, 2.6558, 1.2196, 1.7708, 2.6052, 2.0743, 3.2687, 2.1526, 2.8652, 1.5579, 1.6382, 1.1253, 2.8251, 1.916] )

一個 VAE 模型,帶有 KL 損失,用於將影片編碼為潛在表示,並將潛在表示解碼為影片。在 [Wan 2.1] 中引入。

此模型繼承自 ModelMixin。有關所有模型實現的通用方法(如下載或儲存),請參閱超類文件。

包裝器

< >

( *args **kwargs )

停用切片

< >

( )

停用切片 VAE 解碼。如果之前啟用了 enable_slicing,此方法將恢復一步計算解碼。

停用平鋪

< >

( )

停用平鋪 VAE 解碼。如果之前啟用了 enable_tiling,此方法將恢復一步計算解碼。

啟用切片

< >

( )

啟用切片 VAE 解碼。啟用此選項後,VAE 會將輸入張量分片,分步計算解碼。這有助於節省一些記憶體並允許更大的批次大小。

啟用平鋪

< >

( tile_sample_min_height: typing.Optional[int] = None tile_sample_min_width: typing.Optional[int] = None tile_sample_stride_height: typing.Optional[float] = None tile_sample_stride_width: typing.Optional[float] = None )

引數

  • tile_sample_min_height (int, 可選) — 樣本在高度維度上被分割成瓷磚所需的最小高度。
  • tile_sample_min_width (int, 可選) — 樣本在寬度維度上被分割成瓷磚所需的最小寬度。
  • tile_sample_stride_height (int, 可選) — 兩個連續垂直切片之間的最小重疊量。這用於確保在高度維度上不會出現平鋪偽影。
  • tile_sample_stride_width (int, 可選) — 兩個連續水平切片之間的步幅。這用於確保在寬度維度上不會出現平鋪偽影。

啟用平鋪 VAE 解碼。啟用此選項後,VAE 將把輸入張量分割成瓦片,分多步計算編碼和解碼。這對於節省大量記憶體和處理更大的影像非常有用。

前向

< >

( sample: Tensor sample_posterior: bool = False return_dict: bool = True generator: typing.Optional[torch._C.Generator] = None )

引數

  • sample (torch.Tensor) — 輸入樣本。
  • return_dict (bool, 可選, 預設為 True) — 是否返回 DecoderOutput 而不是普通元組。

分塊解碼

< >

( z: Tensor return_dict: bool = True ) ~models.vae.DecoderOutputtuple

引數

  • z (torch.Tensor) — 輸入批次潛在向量。
  • return_dict (bool, 可選, 預設為 True) — 是否返回 ~models.vae.DecoderOutput 而不是普通元組。

返回

~models.vae.DecoderOutputtuple

如果 return_dict 為 True,則返回 ~models.vae.DecoderOutput,否則返回普通的 tuple

使用分塊解碼器解碼一批影像。

分塊編碼

< >

( x: Tensor ) torch.Tensor

引數

  • x (torch.Tensor) — 輸入批次影片。

返回

torch.Tensor

編碼影片的潛在表示。

使用分塊編碼器編碼一批影像。

DecoderOutput

class diffusers.models.autoencoders.vae.DecoderOutput

< >

( sample: Tensor commit_loss: typing.Optional[torch.FloatTensor] = None )

引數

  • sample (形狀為 (batch_size, num_channels, height, width)torch.Tensor) — 模型最後一層的解碼輸出樣本。

解碼方法的輸出。

< > 在 GitHub 上更新

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