Diffusers documentation

AutoencoderKLAllegro

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

AutoencoderKLAllegro

Allegroで使用されたKL損失付き3次元変分オートエンコーダ(VAE)モデルは、RhymesAIによるAllegro: Open the Black Box of Commercial-Level Video Generation Modelで紹介されました。

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

from diffusers import AutoencoderKLAllegro

vae = AutoencoderKLAllegro.from_pretrained("rhymes-ai/Allegro", subfolder="vae", dtype=torch.float32).to("cuda")  # or "mps", "xpu", "cpu"

AutoencoderKLAllegro

class diffusers.AutoencoderKLAllegro

< >

( in_channels: int = 3out_channels: int = 3down_block_types: tuple = ('AllegroDownBlock3D', 'AllegroDownBlock3D', 'AllegroDownBlock3D', 'AllegroDownBlock3D')up_block_types: tuple = ('AllegroUpBlock3D', 'AllegroUpBlock3D', 'AllegroUpBlock3D', 'AllegroUpBlock3D')block_out_channels: tuple = (128, 256, 512, 512)temporal_downsample_blocks: tuple = (True, True, False, False)temporal_upsample_blocks: tuple = (False, True, True, False)latent_channels: int = 4layers_per_block: int = 2act_fn: str = 'silu'norm_num_groups: int = 32temporal_compression_ratio: float = 4sample_size: int = 320scaling_factor: float = 0.13force_upcast: bool = True )

パラメータ

  • in_channels (int, デフォルトは 3) — 入力画像のチャネル数。
  • out_channels (int, デフォルトは 3) — 出力のチャネル数。
  • down_block_types (tuple[str, ...]、デフォルトは ("AllegroDownBlock3D", "AllegroDownBlock3D", "AllegroDownBlock3D", "AllegroDownBlock3D")) — 使用するダウンブロックの種類を示す文字列のタプルです。
  • up_block_types (tuple[str, ...]、デフォルトは ("AllegroUpBlock3D", "AllegroUpBlock3D", "AllegroUpBlock3D", "AllegroUpBlock3D")) — 使用するアップブロックの種類を示す文字列のタプルです。
  • block_out_channels (tuple[int, ...]、デフォルトは (128, 256, 512, 512)) — 各ブロックの出力チャネル数を表す整数のタプルです。
  • temporal_downsample_blocks (tuple[bool, ...]、デフォルトは (True, True, False, False)) — 時間方向のダウンサンプリングを有効にするブロックを示すブール値のタプルです。
  • latent_channels (int、デフォルトは 4) — 潜在変数のチャネル数。
  • layers_per_block (int、デフォルトは 2) — ダウンブロックおよびアップブロックあたりの resnet、attention、temporal convolution の層数。
  • act_fn (str、デフォルトは "silu") — 使用する活性化関数。
  • norm_num_groups (int、デフォルトは32) — 正規化層で使用するグループ数。
  • temporal_compression_ratio (int、デフォルトは4) — サンプルの時間次元が圧縮される比率。
  • sample_size (int、デフォルトは 320) — デフォルトの潜在サイズです。
  • scaling_factor (float、デフォルト値は 0.13235) — 学習済み潜在空間の要素ごとの標準偏差です。これは、学習セットの最初のバッチを使用して計算されます。拡散モデルの学習時に、潜在空間を分散 1 にスケーリングするために使用されます。潜在変数は、拡散モデルに渡される前に z = z * scaling_factor という式でスケーリングされます。デコード時には、z = 1 / scaling_factor * z という式で元のスケールに戻されます。詳細については、High-Resolution Image Synthesis with Latent Diffusion Models 論文のセクション 4.3.2 と D.1 を参照してください。
  • force_upcast (bool、デフォルトは True) — 有効にすると、SD-XL などの高解像度画像パイプラインにおいて、VAE を float32 で実行するよう強制します。VAE を低精度の範囲でファインチューニング / 訓練し、精度の低下を抑えることが可能な場合、force_upcast を False に設定できます。参考: https://huggingface.co/madebyollin/sdxl-vae-fp16-fix

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

このモデルは 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 が返されます。

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

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、省略可) — PyTorchの乱数生成器。

戻り値

~models.vae.DecoderOutput または tuple

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

AutoencoderKLOutput

class diffusers.models.modeling_outputs.AutoencoderKLOutput

< >

( latent_dist: DiagonalGaussianDistribution )

パラメータ

  • latent_dist (DiagonalGaussianDistribution) — Encoder のエンコード出力を、DiagonalGaussianDistribution の平均と logvar として表したものです。 DiagonalGaussianDistribution を使用すると、この分布から潜在変数をサンプリングできます。

AutoencoderKLのエンコードメソッドの出力。

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