Diffusers 文件
AutoencoderKLMochi
並獲得增強的文件體驗
開始使用
AutoencoderKLMochi
Mochi 中使用的帶有 KL 損失的 3D 變分自動編碼器 (VAE) 模型由清華大學和智譜AI在 Mochi 1 Preview 中引入。
該模型可以透過以下程式碼片段載入。
from diffusers import AutoencoderKLMochi
vae = AutoencoderKLMochi.from_pretrained("genmo/mochi-1-preview", subfolder="vae", torch_dtype=torch.float32).to("cuda")
AutoencoderKLMochi
class diffusers.AutoencoderKLMochi
< 原始碼 >( in_channels: int = 15 out_channels: int = 3 encoder_block_out_channels: typing.Tuple[int] = (64, 128, 256, 384) decoder_block_out_channels: typing.Tuple[int] = (128, 256, 512, 768) latent_channels: int = 12 layers_per_block: typing.Tuple[int, ...] = (3, 3, 4, 6, 3) act_fn: str = 'silu' temporal_expansions: typing.Tuple[int, ...] = (1, 2, 3) spatial_expansions: typing.Tuple[int, ...] = (2, 2, 2) add_attention_block: typing.Tuple[bool, ...] = (False, True, True, True, True) latents_mean: typing.Tuple[float, ...] = (-0.06730895953510081, -0.038011381506090416, -0.07477820912866141, -0.05565264470995561, 0.012767231469026969, -0.04703542746246419, 0.043896967884726704, -0.09346305707025976, -0.09918314763016893, -0.008729793427399178, -0.011931556316503654, -0.0321993391887285) latents_std: typing.Tuple[float, ...] = (0.9263795028493863, 0.9248894543193766, 0.9393059390890617, 0.959253732819592, 0.8244560132752793, 0.917259975397747, 0.9294154431013696, 1.3720942357788521, 0.881393668867029, 0.9168315692124348, 0.9185249279345552, 0.9274757570805041) scaling_factor: float = 1.0 )
引數
- in_channels (int, 可選, 預設為 3) — 輸入影像中的通道數。
- out_channels (int, 可選, 預設為 3) — 輸出通道數。
- block_out_channels (
Tuple[int]
, 可選, 預設為(64,)
) — 塊輸出通道的元組。 - act_fn (
str
, 可選, 預設為"silu"
) — 要使用的啟用函式。 - scaling_factor (
float
, 可選, 預設為1.15258426
) — 使用訓練集第一批計算的訓練潛在空間的元件標準差。這用於在訓練擴散模型時將潛在空間縮放到單位方差。潛在空間在傳遞給擴散模型之前,透過公式z = z * scaling_factor
進行縮放。解碼時,潛在空間透過公式z = 1 / scaling_factor * z
縮放回原始比例。有關更多詳細資訊,請參閱 《使用潛在擴散模型進行高解析度影像合成》 論文的 4.3.2 節和 D.1 節。
用於將影像編碼為潛在空間並將潛在表示解碼為影像的帶有 KL 損失的 VAE 模型。用於 Mochi 1 preview。
此模型繼承自 ModelMixin。有關所有模型實現的通用方法(如下載或儲存),請參閱超類文件。
停用切片 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 )
啟用平鋪 VAE 解碼。啟用此選項後,VAE 將把輸入張量分割成瓦片,分多步計算編碼和解碼。這對於節省大量記憶體和處理更大的影像非常有用。
分塊解碼
< 原始碼 >( z: Tensor return_dict: bool = True ) → ~models.vae.DecoderOutput
或 tuple
使用分塊解碼器解碼一批影像。
使用分塊編碼器編碼一批影像。
DecoderOutput
class diffusers.models.autoencoders.vae.DecoderOutput
< 原始碼 >( sample: Tensor commit_loss: typing.Optional[torch.FloatTensor] = None )
解碼方法的輸出。