Diffusers documentation
AutoencoderKLQwenImage21
AutoencoderKLQwenImage21
Qwen-Image 2.1에서 사용하는 64채널 변분 오토인코더입니다. 공간적으로 16배 압축하며, 채널별 latents_mean / latents_std은 단일 스케일링 계수가 아닌 config의 일부입니다.
import torch
from diffusers import AutoencoderKLQwenImage21
vae = AutoencoderKLQwenImage21.from_pretrained("Qwen/Qwen-Image-2.1", subfolder="vae", dtype=torch.bfloat16)AutoencoderKLQwenImage21
클래스 diffusers.AutoencoderKLQwenImage21
< source >( base_dim: int = 96decoder_base_dim: int | None = 144z_dim: int = 64dim_mult: list = [1, 2, 4, 8, 8]num_res_blocks: int = 2attn_scales: list = []temperal_downsample: list = [False, True, True, True]dropout: float = 0.0latents_mean: list = [0.5126, 0.7721, -0.0631, 1.3506, -0.7855, -2.1025, -0.3458, 1.3722, 1.8873, -1.7177, -0.651, 0.2732, 0.7562, -0.6163, -1.0277, 3.8363, 2.021, 0.0472, 0.932, 2.0087, 2.4954, -0.1391, -1.4249, 1.8464, -0.5236, 1.2826, 3.7046, -1.3035, 2.7286, -1.4518, -1.9036, -1.9955, -0.0342, -1.0265, -0.7636, 3.0555, 0.0746, -3.0751, -0.1076, 1.7376, -1.0914, -1.9435, -0.2784, -1.368, 0.4809, -0.4433, 0.3764, 0.5729, -2.0595, 1.096, -1.326, -2.0211, -5.0179, 0.5275, 4.0162, 1.8505, 0.3026, 1.9373, 1.4937, 0.2632, 0.5547, -1.7121, -0.1562, 0.0304]latents_std: list = [3.2001, 3.2936, 3.4321, 3.0091, 3.1061, 4.0379, 4.0705, 3.791, 3.0785, 3.65, 3.9308, 3.0904, 2.8778, 3.7675, 3.732, 5.0756, 3.2864, 4.0397, 3.1317, 4.0443, 2.9249, 3.9454, 3.0988, 4.2489, 3.4896, 3.8513, 3.9323, 3.4719, 3.7498, 4.283, 3.5694, 4.2467, 3.9037, 3.2947, 5.077, 3.5075, 3.27, 3.4767, 2.8063, 5.1125, 3.5327, 4.7833, 3.1286, 4.1819, 3.8527, 3.8312, 3.5605, 4.3875, 3.9624, 4.0168, 3.5643, 4.055, 5.5614, 4.2963, 4.408, 3.4959, 3.8747, 3.7608, 3.5735, 3.149, 3.7662, 3.6746, 3.4563, 3.8161]is_residual: bool = Truein_channels: int = 4out_channels: int = 4patch_size: int | None = Nonescale_factor_temporal: int | None = 8scale_factor_spatial: int | None = 16 )
KL 손실을 사용하여 비디오를 잠재 변수로 인코딩하고 잠재 표현을 비디오로 디코딩하는 VAE 모델입니다. [Qwen Image 2]에서 소개되었습니다.
이 모델은 ModelMixin에서 상속됩니다. 모든 모델에 대해 구현된 일반적 메서드(다운로드 또는 저장 등)에 대해서는 상위 클래스 문서를 확인하세요.
decode
< source >( z: Tensorreturn_dict: bool = True ) → ~models.vae.DecoderOutput or tuple
이미지 배치(decode)를 디코딩합니다.
encode
< source >( x: Tensorreturn_dict: bool = True )
이미지 배치(latents)를 인코딩합니다.
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 = None )
매개변수
- tile_sample_min_height (
int, 선택 사항) — 높이 차원에서 샘플이 타일로 분리되려면 필요한 최소 높이입니다. - tile_sample_min_width (
int, 선택 사항) — 샘플이 너비 차원으로 타일 분리되려면 필요한 최소 너비입니다. - tile_sample_stride_height (
int, 선택 사항) — 연속된 세로 타일 사이의 최소 겹침 양입니다. 이는 높이 차원에서 타일링 아티팩트가 발생하지 않도록 보장하기 위한 것입니다. - tile_sample_stride_width (
int, 선택 사항) — 연속된 두 수평 타일 사이의 스트라이드입니다. 이는 너비 차원에서 타일링 아티팩트가 발생하지 않도록 보장하기 위한 것입니다.
타일 VAE 디코딩을 활성화합니다. 이 옵션이 활성화되면 VAE는 입력 텐서를 타일로 분할하여 디코딩 및 인코딩을 여러 단계로 계산합니다. 이는 대량의 메모리를 절약하고 더 큰 이미지를 처리할 수 있도록 하는 데 유용합니다.
forward
< source >( sample: Tensorsample_posterior: bool = Falsereturn_dict: bool = Truegenerator: typing.Optional[torch.Generator] = None ) → DecoderOutput or tuple
매개변수
- sample (
torch.Tensor) — 입력 샘플. - sample_posterior (
bool, 선택 사항, 기본값False) — 모드를 취하는 대신 사후 분포에서 샘플링할지 여부. - return_dict (
bool, 선택 사항, 기본값True) — 일반 튜플 대신DecoderOutput를 반환할지 여부. - generator (
torch.Generator, 선택 사항) —sample_posterior가True일 때 사용되는 Generator입니다.
반환값
DecoderOutput 또는 tuple
return_dict가 True인 경우 DecoderOutput, 그렇지 않으면 단순한 tuple입니다.
tiled_decode
< source >( z: Tensorreturn_dict: bool = True ) → ~models.vae.DecoderOutput or tuple
tiled decoder를 사용하여 이미지 배치(decoding)를 디코딩합니다.
tiled_encode
< source >( x: Tensor ) → torch.Tensor
타일 인코더를 사용하여 이미지 배치 인코딩
AutoencoderKLOutput
클래스 diffusers.models.modeling_outputs.AutoencoderKLOutput
< source >( latent_dist: DiagonalGaussianDistribution )
AutoencoderKL 인코딩 메서드의 출력.
DecoderOutput
class diffusers.models.autoencoders.vae.DecoderOutput
< source >( sample: Tensorcommit_loss: typing.Optional[torch.FloatTensor] = None )
디코딩 메서드의 출력.