Diffusers documentation

AutoencoderKLHunyuanImage

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

AutoencoderKLHunyuanImage

[HunyuanImage2.1]에서 사용된 KL 손실을 적용한 2D 변분 오토인코더(VAE) 모델입니다.

다음 코드 스니펫으로 모델을 로드할 수 있습니다.

from diffusers import AutoencoderKLHunyuanImage

vae = AutoencoderKLHunyuanImage.from_pretrained("hunyuanvideo-community/HunyuanImage-2.1-Diffusers", subfolder="vae", dtype=torch.bfloat16)

AutoencoderKLHunyuanImage

클래스 diffusers.AutoencoderKLHunyuanImage

< >

( in_channels: intout_channels: intlatent_channels: intblock_out_channels: tuple[int, ...]layers_per_block: intspatial_compression_ratio: intsample_size: intscaling_factor: float = Nonedownsample_match_channel: bool = Trueupsample_match_channel: bool = True )

공간 타일링을 지원하는 2D 이미지의 VAE 모델입니다.

이 모델은 ModelMixin에서 상속됩니다. 모든 모델에 대해 구현된 일반적 메서드(다운로드 또는 저장 등)에 대해서는 상위 클래스 문서를 확인하세요.

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이 반환됩니다.

이미지 배치(decode)를 디코딩합니다.

enable_tiling

< >

( tile_sample_min_size: int | None = Nonetile_overlap_factor: float | None = None )

매개변수

  • tile_sample_min_size (int, 선택 사항) — 공간 차원으로 샘플을 타일로 분리하는 데 필요한 최소 크기입니다.
  • tile_overlap_factor (float, 선택 사항) — 잠재 변수(latent)를 공간 차원 기준으로 타일로 분리하는 데 필요한 겹침 계수입니다.

공간 타일 VAE 디코딩을 활성화합니다. 이 옵션이 활성화되면 VAE는 입력 텐서를 타일로 분할하여 디코딩과 인코딩을 여러 단계로 계산합니다. 이는 대량의 메모리를 절약하고 더 큰 이미지를 처리할 수 있도록 하는 데 유용합니다.

encode

< >

( x: Tensorreturn_dict: bool = True )

매개변수

  • x (torch.Tensor) — 이미지 입력 배치.
  • return_dict (bool, 선택 사항, 기본값 True) — 일반 튜플 대신 ~models.autoencoder_kl.AutoencoderKLOutput을 반환할지 여부.

이미지 배치(latents)를 인코딩합니다.

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) — (B, C, H, W) 형태의 Latent 텐서.
  • return_dict (bool, 선택 사항, 기본값 True) — ~models.vae.DecoderOutput를 반환할지, 아니면 일반 튜플을 반환할지를 결정합니다.

반환값

~models.vae.DecoderOutput 또는 tuple

return_dict가 True이면 ~models.vae.DecoderOutput가 반환되고, 그렇지 않으면 일반 tuple이 반환됩니다.

공간 타일링 전략을 사용하여 잠재 변수를 디코딩합니다.

tiled_encode

< >

( x: Tensor ) → torch.Tensor

매개변수

  • x (torch.Tensor) — (B, C, T, H, W) 형식의 입력 텐서.

반환값

torch.Tensor

인코딩된 이미지의 잠재 표현(latent representation).

공간 타일링 전략을 사용하여 입력을 인코딩합니다.

DecoderOutput

class diffusers.models.autoencoders.vae.DecoderOutput

< >

( sample: Tensorcommit_loss: typing.Optional[torch.FloatTensor] = None )

매개변수

  • sample (torch.Tensor, shape (batch_size, num_channels, height, width)) — 모델의 마지막 레이어에서 디코딩된 출력 샘플입니다.

디코딩 메서드의 출력.

Update on GitHub