Diffusers documentation

AutoencoderKLHunyuanImage

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

and get access to the augmented documentation experience

to get started

AutoencoderKLHunyuanImage

[HunyuanImage2.1]で使用されたKL損失付き2次元変分オートエンコーダ(VAE)モデル。

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

from diffusers import AutoencoderKLHunyuanImage

vae = AutoencoderKLHunyuanImage.from_pretrained("hunyuanvideo-community/HunyuanImage-2.1-Diffusers", subfolder="vae", dtype=torch.bfloat16)

AutoencoderKLHunyuanImage

class diffusers.AutoencoderKLHunyuanImage

< >

( in_channels: intout_channels: intlatent_channels: intblock_out_channels: tuple[int, ...]layers_per_block: intspatial_compression_ratio: intsample_size: intscaling_factor: float = Nonedownsample_match_channel: bool = Trueupsample_match_channel: bool = True )

空間タイル分割をサポートする2D画像用のVAEモデル。

このモデルは 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_size: int | None = Nonetile_overlap_factor: float | None = None )

パラメータ

  • tile_sample_min_size (int, 任意) — 空間次元に沿ってサンプルをタイルに分割するために必要な最小サイズです。
  • tile_overlap_factor (float, 任意) — 空間次元に沿って潜在変数をタイルに分割するために必要なオーバーラップ係数です。

空間タイル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) — 形状が (B, C, H, W) の潜在テンソル。
  • 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) — 形状が (B, C, T, H, W) の入力テンソル。

戻り値

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