Diffusers documentation

AutoencoderKLPH3Image

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

AutoencoderKLPH3Image

Pruna AI의 P-H3-Image 이미지 VAE입니다. MiniMax-H3의 비디오 VAE 인코더와 잠재 공간을 사용하며, 단일 잠재 프레임 이미지를 복원하는 ViT 디코더를 사용합니다.

AutoencoderKLMiniMaxH3의 관례를 따릅니다:

  • 이미지는 16배 공간 압축을 적용한 단일 프레임 비디오로 전달되며, 형식은 (batch_size, channels, 1, height, width)입니다.
  • Latents는 scaling_factor 대신 latents_mean / latents_std로 채널별로 정규화됩니다.
  • Pixels는 [0, 1] 범위의 ImageNet 정규화 RGB입니다: encode는 (pixel - imagenet_mean) / imagenet_std를 입력으로 기대하며, decode는 해당 공간의 값을 반환합니다.
  • 공간 타일링은 기본적으로 활성화되어 있으며, 타일 크기는 256픽셀이고 최소 64픽셀의 겹침을 가집니다.
import torch
from diffusers import AutoencoderKLPH3Image

vae = AutoencoderKLPH3Image.from_pretrained("PrunaAI/P-H3-Image", subfolder="vae", dtype=torch.bfloat16).to(
    "cuda"
)  # or "mps", "xpu", "cpu"

모델이 어떤 dtype로 로드되든, 인코더와 디코더의 출력 투영은 float32로 유지됩니다.

AutoencoderKLPH3Image

클래스 diffusers.AutoencoderKLPH3Image

< >

( in_channels: int = 3out_channels: int = 3latent_channels: int = 24block_out_channels: tuple = (128, 256, 256, 512, 512, 1024)layers_per_block: int = 2spatial_downsample_factors: tuple = (2, 2, 2, 2, 1, 1)temporal_downsample_factors: tuple = (1, 2, 2, 1, 1, 1)norm_num_groups: int = 32norm_eps: float = 1e-06spatial_padding_mode: str = 'reflect'decoder_num_layers: int = 36decoder_num_attention_heads: int = 32decoder_attention_head_dim: int = 64decoder_num_register_tokens: int = 4decoder_ffn_mult: int = 4decoder_rope_theta: float = 100.0decoder_rope_dim_ratio: float = 0.75decoder_norm_eps: float = 1e-05latents_mean: tuple = (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)latents_std: tuple = (1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0) )

P-H3-Image의 이미지 VAE: MiniMax-H3의 VAE 인코더와 잠재 공간으로, 단일 잠재 프레임을 디코딩하는 PH3ImageViTDecoder를 포함합니다.

이미지는 단일 프레임 비디오로 전달되며, 형식은 (batch_size, channels, 1, height, width)입니다. AutoencoderKLMiniMaxH3와 마찬가지로 픽셀은 [0, 1] 범위의 ImageNet 정규화 RGB(평균 (0.485, 0.456, 0.406), 표준편차 (0.229, 0.224, 0.225))이며, 공간 타일링은 기본적으로 활성화되어 있습니다.

encode

< >

( x: Tensorreturn_dict: bool = True )

매개변수

  • x (torch.Tensor) — 단일 프레임 비디오로 구성된 이미지 입력 배치, shape (batch_size, in_channels, 1, height, width).
  • return_dict (bool, 선택 사항, 기본값 True) — 단순 tuple 대신 AutoencoderKLOutput을 반환할지 여부.

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

decode

< >

( z: Tensorreturn_dict: bool = True ) → DecoderOutput or tuple

매개변수

  • z (torch.Tensor) — 입력 배치인 latents, shape (batch_size, latent_channels, 1, height, width).
  • return_dict (bool, 선택 사항, 기본값 True) — 일반 튜플 대신 DecoderOutput를 반환할지 여부.

반환값

DecoderOutput 또는 tuple

복호화된 이미지의 shape는 (batch_size, out_channels, 1, height, width)입니다.

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

enable_tiling

< >

( tile_sample_min_height: int | None = Nonetile_sample_min_width: int | None = Nonetile_sample_min_overlap_height: int | None = Nonetile_sample_min_overlap_width: int | None = None )

매개변수

  • tile_sample_min_height (int, 선택 사항) — 픽셀 공간에서의 타일 높이입니다. 이 값보다 높은 프레임은 높이 차원을 따라 분할됩니다.
  • tile_sample_min_width (int, 선택 사항) — 픽셀 공간에서의 타일 너비입니다. 이 값보다 넓은 프레임은 너비 차원을 따라 분할됩니다.
  • tile_sample_min_overlap_height (int, 선택 사항) — 연속된 세로 타일 두 개 사이의 최소 겹침 값(픽셀 단위).
  • tile_sample_min_overlap_width (int, 선택 사항) — 연속된 두 수평 타일 사이의 최소 겹침 폭(픽셀 단위).

타일 VAE 인코딩/디코딩 활성화. 이 옵션을 활성화하면 VAE가 프레임을 타일로 분할하고 각 타일을 개별적으로 인코딩 또는 디코딩한 뒤, 겹치는 부분을 선형 블렌딩으로 다시 결합합니다. 이를 통해 메모리 요구량이 줄어들고 더 큰 프레임을 처리할 수 있습니다.

forward

< >

( sample: Tensorsample_posterior: bool = Falsegenerator: typing.Optional[torch.Generator] = Nonereturn_dict: bool = True ) → DecoderOutput or tuple

매개변수

  • sample (torch.Tensor) — 단일 프레임 비디오로 구성된 이미지 입력 배치, shape (batch_size, in_channels, 1, height, width).
  • sample_posterior (bool, 선택 사항, 기본값 False) — 모드를 취하는 대신 사후 분포에서 샘플링할지 여부.
  • generator (torch.Generator, 선택 사항) — sample_posterior=True일 때 사용되는 Generator입니다.
  • return_dict (bool, 선택 사항, 기본값 True) — 일반 튜플 대신 DecoderOutput를 반환할지 여부.

반환값

DecoderOutput 또는 tuple

라운드 트립된 이미지, shape (batch_size, out_channels, 1, height, width).

이미지 배치(batch)를 인코딩한 후 디코딩합니다.

Update on GitHub