Diffusers documentation
AutoencoderKLKVAE
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
< source >( 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
< source >( z: FloatTensorreturn_dict: bool = Truegenerator = None ) → ~models.vae.DecoderOutput or tuple
画像のバッチをデコードします。
encode
< source >( x: Tensorreturn_dict: bool = True )
バッチの画像を潜在変数にエンコードします。
forward
< source >( 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
< source >( z: Tensorreturn_dict: bool = True ) → ~models.vae.DecoderOutput or tuple
タイル化されたデコーダーを使用して、画像のバッチをデコードします。