Diffusers documentation

AutoencoderKLHunyuanImageRefiner

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

AutoencoderKLHunyuanImageRefiner

HunyuanImage2.1のリファイナーパイプラインで使用される、KL損失付きの3次元変分オートエンコーダー(VAE)モデルです。

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

from diffusers import AutoencoderKLHunyuanImageRefiner

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

AutoencoderKLHunyuanImageRefiner

class diffusers.AutoencoderKLHunyuanImageRefiner

< >

( in_channels: int = 3out_channels: int = 3latent_channels: int = 32block_out_channels: tuple[int, ...] = (128, 256, 512, 1024, 1024)layers_per_block: int = 2spatial_compression_ratio: int = 16temporal_compression_ratio: int = 4downsample_match_channel: bool = Trueupsample_match_channel: bool = Truescaling_factor: float = 1.03682 )

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

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

パラメータ

  • tile_sample_min_height (int, 任意) — サンプルを高さ方向にタイル分割するために必要な最小高さ。
  • tile_sample_min_width (int, 任意) — 幅方向にサンプルをタイルに分割するために必要な最小幅です。
  • tile_sample_stride_height (int, 省略可) — 縦方向の連続する2つのタイル間の最小重複量です。これにより、高さ方向にタイル化によるアーティファクトが発生しないことを保証します。
  • tile_sample_stride_width (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: Tensor ) → torch.Tensor

パラメータ

  • z (torch.Tensor) — 潜在ベクトルの入力バッチ。

戻り値

torch.Tensor

デコードされた画像。

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

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