Diffusers documentation

AutoencoderKLKVAE

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

AutoencoderKLKVAE

KL損失付きの2次元変分オートエンコーダ(VAE)モデル。

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

import torch
from diffusers import AutoencoderKLKVAE

vae = AutoencoderKLKVAE.from_pretrained("kandinskylab/KVAE-2D-1.0", subfolder="diffusers", dtype=torch.bfloat16)

AutoencoderKLKVAE

class diffusers.AutoencoderKLKVAE

< >

( in_channels: int = 3channels: int = 128num_enc_blocks: int = 2num_dec_blocks: int = 2z_channels: int = 16double_z: bool = Truech_mult: typing.Tuple[int, ...] = (1, 2, 4, 8)sample_size: int = 1024 )

パラメータ

  • in_channels (int, 任意、デフォルトは 3) — 入力画像のチャネル数。
  • channels (int, 任意、デフォルトは 128) — マルチリゾリューションブロックのベースとなるチャネル数。
  • num_enc_blocks (int, 任意、デフォルトは 2) — エンコーダーのマルチリゾリューション層における Resnet ブロックの数。
  • num_dec_blocks (int, 任意、デフォルトは 2) — デコーダーのマルチリゾリューション層における Resnet ブロックの数。
  • z_channels (int、任意、デフォルト値は 16) — 潜在空間のチャネル数。
  • double_z (bool、省略可、デフォルトは True) — エンコーダーの出力チャネル数を2倍にするかどうかを指定します。
  • ch_mult (Tuple[int, ...]、任意、デフォルトは(1, 2, 4, 8)) — マルチリゾリューションブロックにおけるチャネルの乗数です。
  • sample_size (int、任意、デフォルトは1024) — サンプルの入力サイズ。

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

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

decode

< >

( z: FloatTensorreturn_dict: bool = Truegenerator = None ) → ~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、省略可) — サンプリングを決定論的に行うための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 が返されます。

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

Update on GitHub