# AutoencoderKLHunyuanVideo15

Tencent の [HunyuanVideo1.5](https://github.com/Tencent-Hunyuan/HunyuanVideo-1.5) で使用される、KL 損失付きの 3 次元変分オートエンコーダ (VAE) モデルです。

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

```python
from diffusers import AutoencoderKLHunyuanVideo15

vae = AutoencoderKLHunyuanVideo15.from_pretrained("hunyuanvideo-community/HunyuanVideo-1.5-Diffusers-480p_t2v", subfolder="vae", dtype=torch.float32)

# make sure to enable tiling to avoid OOM
vae.enable_tiling()
```

## AutoencoderKLHunyuanVideo15[[diffusers.AutoencoderKLHunyuanVideo15]]

#### diffusers.AutoencoderKLHunyuanVideo15[[diffusers.AutoencoderKLHunyuanVideo15]]

```python
diffusers.AutoencoderKLHunyuanVideo15(in_channels: int = 3, out_channels: int = 3, latent_channels: int = 32, block_out_channels: tuple[int] = (128, 256, 512, 1024, 1024), layers_per_block: int = 2, spatial_compression_ratio: int = 16, temporal_compression_ratio: int = 4, downsample_match_channel: bool = True, upsample_match_channel: bool = True, scaling_factor: float = 1.03682)
```

[ソース](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/models/autoencoders/autoencoder_kl_hunyuanvideo15.py#L634)

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

このモデルは [ModelMixin](/docs/diffusers/v0.43.0/ja/api/models/overview#diffusers.ModelMixin) を継承しています。すべてのモデルに実装されている汎用的なメソッド（ダウンロードや保存など）については、スーパークラスのドキュメントを参照してください。

#### decode[[diffusers.AutoencoderKLHunyuanVideo15.decode]]

```python
decode(z: Tensor, return_dict: bool = True)
```

[ソース](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/models/autoencoders/autoencoder_kl_hunyuanvideo15.py#L779)

**パラメータ:**

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

return_dict (`bool`、*任意*、デフォルトは`True`) : プレーンなタプルではなく`~models.vae.DecoderOutput`を返すかどうか。

**戻り値:** `~models.vae.DecoderOutput` または `tuple`

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

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

#### encode[[diffusers.AutoencoderKLHunyuanVideo15.encode]]

```python
encode(x: Tensor, return_dict: bool = True)
```

[ソース](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/models/autoencoders/autoencoder_kl_hunyuanvideo15.py#L741)

**パラメータ:**

x (`torch.Tensor`) : 画像の入力バッチ。

return_dict (`bool`、*任意*、デフォルトは`True`) : プレーンなタプルではなく`~models.autoencoder_kl.AutoencoderKLOutput`を返すかどうか。

**戻り値:**

エンコードされた動画の潜在表現。`return_dict`がTrueの場合、`~models.autoencoder_kl.AutoencoderKLOutput`が返され、それ以外の場合は通常の`tuple`が返されます。

バッチの画像を潜在変数にエンコードします。

#### enable_tiling[[diffusers.AutoencoderKLHunyuanVideo15.enable_tiling]]

```python
enable_tiling(tile_sample_min_height: int | None = None, tile_sample_min_width: int | None = None, tile_latent_min_height: int | None = None, tile_latent_min_width: int | None = None, tile_overlap_factor: float | None = None)
```

[ソース](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/models/autoencoders/autoencoder_kl_hunyuanvideo15.py#L702)

**パラメータ:**

tile_sample_min_height (`int`, *optional*) : サンプルを高さ方向にタイル分割するために必要な最小高さ。

tile_sample_min_width (`int`, *optional*) : サンプルを幅方向にタイル分割するために必要な最小幅。

tile_latent_min_height (`int`, *任意*) : 潜在変数（latent）を高さ方向にタイル分割するために必要な最小高さ。

tile_latent_min_width (`int`, *optional*) : 潜在変数（latent）を幅方向にタイル分割するために必要な最小幅。

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

#### forward[[diffusers.AutoencoderKLHunyuanVideo15.forward]]

```python
forward(sample: Tensor, sample_posterior: bool = False, return_dict: bool = True, generator: typing.Optional[torch.Generator] = None)
```

[ソース](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/models/autoencoders/autoencoder_kl_hunyuanvideo15.py#L926)

**パラメータ:**

sample (`torch.Tensor`) : 入力サンプル。

sample_posterior (`bool`、*任意*、デフォルトは`False`) : 事後分布からサンプリングするかどうか。

return_dict (`bool`、*任意*、デフォルトは`True`) : プレーンなタプルではなく`DecoderOutput`を返すかどうか。

generator (`torch.Generator`, *任意*) : サンプリングを決定論的にするための [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html)。

**戻り値:** `~models.vae.DecoderOutput` または `tuple`

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

#### tiled_decode[[diffusers.AutoencoderKLHunyuanVideo15.tiled_decode]]

```python
tiled_decode(z: Tensor)
```

[ソース](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/models/autoencoders/autoencoder_kl_hunyuanvideo15.py#L877)

**パラメータ:**

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

**戻り値:** `torch.Tensor`

デコードされた画像。

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

#### tiled_encode[[diffusers.AutoencoderKLHunyuanVideo15.tiled_encode]]

```python
tiled_encode(x: Tensor)
```

[ソース](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/models/autoencoders/autoencoder_kl_hunyuanvideo15.py#L829)

**パラメータ:**

x (`torch.Tensor`) : 入力バッチの動画。

**戻り値:** `torch.Tensor`

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

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

## DecoderOutput[[diffusers.models.autoencoders.vae.DecoderOutput]]

#### diffusers.models.autoencoders.vae.DecoderOutput[[diffusers.models.autoencoders.vae.DecoderOutput]]

```python
diffusers.models.autoencoders.vae.DecoderOutput(sample: Tensor, commit_loss: typing.Optional[torch.FloatTensor] = None)
```

[ソース](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/models/autoencoders/vae.py#L49)

**パラメータ:**

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

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

