Diffusers documentation

AutoencoderKLHunyuanVideo

You are viewing main version, which requires installation from source. If you'd like regular pip install, checkout the latest stable version (v0.42.1).
Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

AutoencoderKLHunyuanVideo

HunyuanVideoで使用されているKL損失付き3次元変分オートエンコーダ(VAE)モデルです。Tencentによって、HunyuanVideo: A Systematic Framework For Large Video Generative Modelsで紹介されました。

モデルは、以下のコードスニペットで読み込むことができます。

from diffusers import AutoencoderKLHunyuanVideo

vae = AutoencoderKLHunyuanVideo.from_pretrained("hunyuanvideo-community/HunyuanVideo", subfolder="vae", dtype=torch.float16)

AutoencoderKLHunyuanVideo

class diffusers.AutoencoderKLHunyuanVideo

< >

( in_channels: int = 3out_channels: int = 3latent_channels: int = 16down_block_types: tuple = ('HunyuanVideoDownBlock3D', 'HunyuanVideoDownBlock3D', 'HunyuanVideoDownBlock3D', 'HunyuanVideoDownBlock3D')up_block_types: tuple = ('HunyuanVideoUpBlock3D', 'HunyuanVideoUpBlock3D', 'HunyuanVideoUpBlock3D', 'HunyuanVideoUpBlock3D')block_out_channels: tuple = (128, 256, 512, 512)layers_per_block: int = 2act_fn: str = 'silu'norm_num_groups: int = 32scaling_factor: float = 0.476986spatial_compression_ratio: int = 8temporal_compression_ratio: int = 4mid_block_add_attention: bool = True )

KL損失を用いて、動画を潜在変数にエンコードし、潜在表現を動画にデコードするためのVAEモデルです。 HunyuanVideoで導入されました。

このモデルは ModelMixin を継承しています。すべてのモデルに実装されている汎用的なメソッド(ダウンロードや保存など)については、スーパークラスのドキュメントを参照してください。

decode

< >

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

パラメータ

  • z (torch.Tensor) — 潜在ベクトルの入力バッチ。
  • return_dict (bool、省略可、デフォルトはTrue) — ~models.vae.DecoderOutputを返すか、プレーンなタプルを返すかを指定します。

戻り値

~models.vae.DecoderOutput または tuple

return_dict が True の場合、~models.vae.DecoderOutput が返され、それ以外の場合は通常の tuple が返されます。

画像のバッチをデコードします。

enable_tiling

< >

( tile_sample_min_height: int | None = Nonetile_sample_min_width: int | None = Nonetile_sample_min_num_frames: int | None = Nonetile_sample_stride_height: float | None = Nonetile_sample_stride_width: float | None = Nonetile_sample_stride_num_frames: float | None = None )

パラメータ

  • tile_sample_min_height (int, 任意) — サンプルを高さ方向にタイル分割するために必要な最小高さ。
  • tile_sample_min_width (int, 任意) — 幅方向にサンプルをタイルに分割するために必要な最小幅です。
  • tile_sample_min_num_frames (int, 省略可) — フレーム次元にわたってサンプルをタイルに分割するために必要な最小フレーム数。
  • tile_sample_stride_height (int, 省略可) — 縦方向の連続する2つのタイル間の最小重複量です。これにより、高さ方向にタイル化によるアーティファクトが発生しないことを保証します。
  • tile_sample_stride_width (int, 任意) — 連続する2つの水平タイル間のストライドです。これにより、幅方向にタイル化によるアーティファクトが発生しないことを保証します。
  • tile_sample_stride_num_frames (int, 省略可) — 連続する2つのフレームタイル間のストライドです。これにより、フレーム次元にわたってタイル化によるアーティファクトが発生しないことを保証します。

タイル化VAEデコーディングを有効にします。このオプションを有効にすると、VAEは入力テンソルをタイルに分割し、デコーディングとエンコーディングを複数ステップで計算します。これにより、大量のメモリを節約し、より大きな画像の処理を可能にします。

encode

< >

( x: Tensorreturn_dict: bool = True )

パラメータ

  • x (torch.Tensor) — 画像の入力バッチ。
  • 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 が返されます。

tiled_decode

< >

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

パラメータ

  • z (torch.Tensor) — 潜在ベクトルの入力バッチ。
  • return_dict (bool、省略可、デフォルトはTrue) — ~models.vae.DecoderOutputを返すか、プレーンなタプルを返すかを指定します。

戻り値

~models.vae.DecoderOutput または tuple

return_dict が True の場合、~models.vae.DecoderOutput が返され、それ以外の場合は通常の tuple が返されます。

タイル化されたデコーダーを使用して、画像のバッチをデコードします。

tiled_encode

< >

( x: Tensor ) → torch.Tensor

パラメータ

  • x (torch.Tensor) — 入力バッチの動画。

戻り値

torch.Tensor

エンコードされた動画の潜在表現。

タイル化されたエンコーダーを使用して、画像のバッチをエンコードします。

DecoderOutput

class diffusers.models.autoencoders.vae.DecoderOutput

< >

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

パラメータ

  • sample (torch.Tensor、形状 (batch_size, num_channels, height, width)) — モデルの最終層からのデコード済み出力サンプルです。

デコードメソッドの出力。

Update on GitHub