Buckets:

hf-doc-build/doc / diffusers /main /ko /api /models /autoencoderkl_p_h3_image.md
mishig's picture
|
download
raw
7.69 kB

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]]

diffusers.AutoencoderKLPH3Image[[diffusers.AutoencoderKLPH3Image]]

diffusers.AutoencoderKLPH3Image(in_channels: int = 3, out_channels: int = 3, latent_channels: int = 24, block_out_channels: tuple = (128, 256, 256, 512, 512, 1024), layers_per_block: int = 2, spatial_downsample_factors: tuple = (2, 2, 2, 2, 1, 1), temporal_downsample_factors: tuple = (1, 2, 2, 1, 1, 1), norm_num_groups: int = 32, norm_eps: float = 1e-06, spatial_padding_mode: str = 'reflect', decoder_num_layers: int = 36, decoder_num_attention_heads: int = 32, decoder_attention_head_dim: int = 64, decoder_num_register_tokens: int = 4, decoder_ffn_mult: int = 4, decoder_rope_theta: float = 100.0, decoder_rope_dim_ratio: float = 0.75, decoder_norm_eps: float = 1e-05, latents_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[[diffusers.AutoencoderKLPH3Image.encode]]

encode(x: Tensor, return_dict: bool = True)

소스

매개변수:

x (torch.Tensor) : 단일 프레임 비디오로 구성된 입력 이미지 배치, shape (batch_size, in_channels, 1, height, width).

return_dict (bool, 선택 사항, 기본값 True) : 일반 튜플 대신 AutoencoderKLOutput을 반환할지 여부.

반환값:

인코딩된 이미지의 잠재 분포. 잠재 변수는 이후에 latents_mean / latents_std로 정규화됩니다.

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

decode[[diffusers.AutoencoderKLPH3Image.decode]]

decode(z: Tensor, return_dict: bool = True)

소스

매개변수:

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[[diffusers.AutoencoderKLPH3Image.enable_tiling]]

enable_tiling(tile_sample_min_height: int | None = None, tile_sample_min_width: int | None = None, tile_sample_min_overlap_height: int | None = None, tile_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[[diffusers.AutoencoderKLPH3Image.forward]]

forward(sample: Tensor, sample_posterior: bool = False, generator: typing.Optional[torch.Generator] = None, return_dict: bool = True)

소스

매개변수:

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)를 인코딩한 후 디코딩합니다.

Xet Storage Details

Size:
7.69 kB
·
Xet hash:
5e19549b5aecdf2025cb7d404b17ccc411655c3b276cad190ce9129fbc2884dd

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.