Diffusers documentation
AutoencoderKLHunyuanImageRefiner
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
< source >( 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
< source >( z: Tensorreturn_dict: bool = True ) → ~models.vae.DecoderOutput or tuple
画像のバッチをデコードします。
enable_tiling
< source >( 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
< 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: Tensor ) → torch.Tensor
タイル化されたデコーダーを使用して、画像のバッチをデコードします。
tiled_encode
< source >( x: Tensor ) → torch.Tensor
タイル化されたエンコーダーを使用して、画像のバッチをエンコードします。
DecoderOutput
class diffusers.models.autoencoders.vae.DecoderOutput
< source >( sample: Tensorcommit_loss: typing.Optional[torch.FloatTensor] = None )
デコードメソッドの出力。