Diffusers 文件

AutoencoderKLLTX影片

Hugging Face's logo
加入 Hugging Face 社群

並獲得增強的文件體驗

開始使用

AutoencoderKLLTX影片

LTX中使用的具有KL損失的3D變分自動編碼器(VAE)模型由Lightricks引入。

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

from diffusers import AutoencoderKLLTXVideo

vae = AutoencoderKLLTXVideo.from_pretrained("Lightricks/LTX-Video", subfolder="vae", torch_dtype=torch.float32).to("cuda")

AutoencoderKLLTX影片

class diffusers.AutoencoderKLLTXVideo

< >

( in_channels: int = 3 out_channels: int = 3 latent_channels: int = 128 block_out_channels: typing.Tuple[int, ...] = (128, 256, 512, 512) down_block_types: typing.Tuple[str, ...] = ('LTXVideoDownBlock3D', 'LTXVideoDownBlock3D', 'LTXVideoDownBlock3D', 'LTXVideoDownBlock3D') decoder_block_out_channels: typing.Tuple[int, ...] = (128, 256, 512, 512) layers_per_block: typing.Tuple[int, ...] = (4, 3, 3, 3, 4) decoder_layers_per_block: typing.Tuple[int, ...] = (4, 3, 3, 3, 4) spatio_temporal_scaling: typing.Tuple[bool, ...] = (True, True, True, False) decoder_spatio_temporal_scaling: typing.Tuple[bool, ...] = (True, True, True, False) decoder_inject_noise: typing.Tuple[bool, ...] = (False, False, False, False, False) downsample_type: typing.Tuple[str, ...] = ('conv', 'conv', 'conv', 'conv') upsample_residual: typing.Tuple[bool, ...] = (False, False, False, False) upsample_factor: typing.Tuple[int, ...] = (1, 1, 1, 1) timestep_conditioning: bool = False patch_size: int = 4 patch_size_t: int = 1 resnet_norm_eps: float = 1e-06 scaling_factor: float = 1.0 encoder_causal: bool = True decoder_causal: bool = False spatial_compression_ratio: int = None temporal_compression_ratio: int = None )

引數

  • in_channels (int, 預設為 3) — 輸入通道數。
  • out_channels (int, 預設為 3) — 輸出通道數。
  • latent_channels (int, 預設為 128) — 潛在通道數。
  • block_out_channels (Tuple[int, ...], 預設為 (128, 256, 512, 512)) — 每個塊的輸出通道數。
  • spatio_temporal_scaling (Tuple[bool, ...], 預設為 (True, True, True, False)` — 塊是否應該包含時空下采樣。
  • layers_per_block (Tuple[int, ...], 預設為 (4, 3, 3, 3, 4)) — 每個塊的層數。
  • patch_size (int, 預設為 4) — 空間補丁的大小。
  • patch_size_t (int, 預設為 1) — 時間補丁的大小。
  • resnet_norm_eps (float, 預設為 1e-6) — ResNet歸一化層的epsilon值。
  • scaling_factor (float, 可選, 預設為 1.0) — 使用訓練集的第一批資料計算的訓練潛在空間的逐分量標準差。這用於在訓練擴散模型時將潛在空間縮放到單位方差。在傳遞給擴散模型之前,潛在空間會根據公式 z = z * scaling_factor 進行縮放。解碼時,潛在空間會根據公式 z = 1 / scaling_factor * z 縮放回原始比例。有關更多詳細資訊,請參閱《Latent Diffusion Models的高解析度影像合成》論文的4.3.2節和D.1節。
  • encoder_causal (bool, 預設為 True) — 編碼器是否應因果行為(未來幀僅取決於過去幀)。
  • decoder_causal (bool, 預設為 False) — 解碼器是否應因果行為(未來幀僅取決於過去幀)。

一個具有KL損失的VAE模型,用於將影像編碼為潛在表示,並將潛在表示解碼為影像。用於LTX

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

包裝器

< >

( *args **kwargs )

包裝器

< >

( *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_min_num_frames: typing.Optional[int] = None tile_sample_stride_height: typing.Optional[float] = None tile_sample_stride_width: typing.Optional[float] = None tile_sample_stride_num_frames: 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 將把輸入張量分割成瓦片,分多步計算編碼和解碼。這對於節省大量記憶體和處理更大的影像非常有用。

分塊解碼

< >

( z: Tensor temb: typing.Optional[torch.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

編碼影片的潛在表示。

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

AutoencoderKLOutput

class diffusers.models.modeling_outputs.AutoencoderKLOutput

< >

( latent_dist: DiagonalGaussianDistribution )

引數

  • latent_dist (DiagonalGaussianDistribution) — Encoder的編碼輸出,表示為DiagonalGaussianDistribution的均值和對數方差。DiagonalGaussianDistribution允許從分佈中取樣潛在變數。

AutoencoderKL 編碼方法的輸出。

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.