Diffusers documentation

AutoencoderKLKVAEVideo

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

AutoencoderKLKVAEVideo

带有 KL 损失的 3D 变分自编码器(VAE)模型。

可以使用以下代码片段加载该模型。

import torch
from diffusers import AutoencoderKLKVAEVideo

vae = AutoencoderKLKVAEVideo.from_pretrained("kandinskylab/KVAE-3D-1.0", subfolder="diffusers", dtype=torch.float16)

AutoencoderKLKVAEVideo

类 diffusers.AutoencoderKLKVAEVideo

< >

( ch: int = 128ch_mult: typing.Tuple[int, ...] = (1, 2, 4, 8)num_res_blocks: int = 2in_channels: int = 3out_ch: int = 3z_channels: int = 16temporal_compress_times: int = 4 )

参数

  • ch (int,可选,默认为 128) — 基础通道数。
  • ch_mult(Tuple[int],可选,默认为 (1, 2, 4, 8))— 每个层级的通道乘数。
  • num_res_blocks (int,可选,默认为 2) — 每个层级的残差块数量。
  • in_channels (int,可选,默认为 3) — 输入通道数。
  • out_ch (int,可选,默认为 3) — 输出通道数。
  • z_channels(int,可选,默认为 16)— 潜在通道的数量。
  • temporal_compress_times (int,可选,默认为 4) — 时间压缩因子。

一个用于将视频编码为潜在表示并将潜在表示解码为视频的 VAE 模型,包含 KL 损失。用于 KVAE。

该模型继承自 ModelMixin。有关为所有模型实现的通用方法(例如下载或保存),请参阅其父类文档。

decode

< >

( z: Tensorreturn_dict: bool = True ) → ~models.vae.DecoderOutput or tuple

参数

  • z (torch.Tensor) — 形状为 (B, C, T, H, W) 的潜在向量输入批次。
  • return_dict (bool,可选,默认为 True) — 是否返回 ~models.vae.DecoderOutput 而不是普通元组。

返回值

~models.vae.DecoderOutput 或 tuple

解码后的视频。

解码一批视频。

disable_slicing

< >

( )

禁用切片 VAE 解码。

enable_slicing

< >

( )

启用切片 VAE 解码。

encode

< >

( x: Tensorreturn_dict: bool = True )

参数

  • x (torch.Tensor) — 形状为 (B, C, T, H, W) 的输入视频批次。
  • return_dict (bool,可选,默认为 True) — 是否返回 ~models.autoencoder_kl.AutoencoderKLOutput 而不是普通元组。

将一批视频编码为潜在表示。

forward

< >

( sample: Tensorsample_posterior: bool = Falsereturn_dict: bool = Truegenerator: typing.Optional[torch.Generator] = None ) → ~models.vae.DecoderOutput or tuple

参数

  • sample (torch.Tensor) — 输入样本。
  • sample_posterior (bool,可选,默认为 False) — 是否从后验分布中采样。
  • return_dict (bool,可选,默认为 True) — 是否返回 DecoderOutput 而不是普通元组。
  • generator (torch.Generator,可选) — 用于使采样过程确定性的 torch.Generator。

返回值

~models.vae.DecoderOutput 或 tuple

如果 return_dict 为 True,则返回 ~models.vae.DecoderOutput,否则返回普通的 tuple。

Update on GitHub