Diffusers documentation

AutoencoderKLMagvit

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

AutoencoderKLMagvit

Mô hình autoencoder biến phân 3D (VAE) với tổn thất KL được sử dụng trong EasyAnimate do Alibaba PAI giới thiệu.

Mô hình có thể được tải bằng đoạn mã sau.

from diffusers import AutoencoderKLMagvit

vae = AutoencoderKLMagvit.from_pretrained("alibaba-pai/EasyAnimateV5.1-12b-zh", subfolder="vae", dtype=torch.float16).to("cuda")  # or "mps", "xpu", "cpu"

AutoencoderKLMagvit

lớp diffusers.AutoencoderKLMagvit

< >

( in_channels: int = 3latent_channels: int = 16out_channels: int = 3block_out_channels: tuple = [128, 256, 512, 512]down_block_types: tuple = ['SpatialDownBlock3D', 'SpatialTemporalDownBlock3D', 'SpatialTemporalDownBlock3D', 'SpatialTemporalDownBlock3D']up_block_types: tuple = ['SpatialUpBlock3D', 'SpatialTemporalUpBlock3D', 'SpatialTemporalUpBlock3D', 'SpatialTemporalUpBlock3D']layers_per_block: int = 2act_fn: str = 'silu'norm_num_groups: int = 32scaling_factor: float = 0.7125spatial_group_norm: bool = True )

Mô hình VAE có tổn thất KL để mã hóa ảnh thành các ẩn và giải mã các biểu diễn ẩn thành ảnh. Mô hình này được sử dụng trong EasyAnimate.

Mô hình này kế thừa từ ModelMixin. Hãy xem tài liệu của lớp cha để biết các phương thức chung được triển khai cho tất cả các mô hình (chẳng hạn như tải xuống hoặc lưu trữ).

decode

< >

( z: Tensorreturn_dict: bool = True ) → ~models.vae.DecoderOutput or tuple

Tham số

  • z (torch.Tensor) — Lô đầu vào của các vector ẩn.
  • return_dict (bool, tùy chọn, mặc định là True) — Có nên trả về một ~models.vae.DecoderOutput thay vì một tuple thông thường hay không.

Trả về

~models.vae.DecoderOutput hoặc tuple

Nếu return_dict là True, một ~models.vae.DecoderOutput sẽ được trả về, ngược lại một tuple thông thường sẽ được trả về.

Giải mã một lô ảnh.

encode

< >

( x: Tensorreturn_dict: bool = True )

Tham số

  • x (torch.Tensor) — Lô đầu vào của các hình ảnh.
  • return_dict (bool, tùy chọn, mặc định là True) — Có nên trả về một ~models.autoencoder_kl.AutoencoderKLOutput thay vì một tuple thông thường hay không.

Mã hóa một lô ảnh thành các biến ẩn.

enable_tiling

< >

( tile_sample_min_height: int | None = Nonetile_sample_min_width: int | None = Nonetile_sample_min_num_frames: int | None = Nonetile_sample_stride_height: float | None = Nonetile_sample_stride_width: float | None = Nonetile_sample_stride_num_frames: float | None = None )

Tham số

  • tile_sample_min_height (int, tùy chọn) — Chiều cao tối thiểu cần thiết để một mẫu được tách thành các ô (tile) theo chiều cao.
  • tile_sample_min_width (int, tùy chọn) — Chiều rộng tối thiểu cần thiết để một mẫu được tách thành các ô (tile) theo chiều rộng.
  • tile_sample_stride_height (int, tùy chọn) — Lượng chồng lấn tối thiểu giữa hai gạch dọc liên tiếp. Điều này nhằm đảm bảo không có hiện tượng lỗi ghép gạch nào xảy ra dọc theo chiều cao.
  • tile_sample_stride_width (int, tùy chọn) — Bước nhảy giữa hai lát cắt ngang liên tiếp. Điều này nhằm đảm bảo không có hiện tượng lỗi lát cắt nào xuất hiện trên chiều rộng.

Bật giải mã VAE dạng gạch. Khi tùy chọn này được bật, VAE sẽ chia tensor đầu vào thành các gạch để tính toán giải mã và mã hóa qua nhiều bước. Điều này hữu ích để tiết kiệm một lượng lớn bộ nhớ và cho phép xử lý các hình ảnh lớn hơn.

forward

< >

( sample: Tensorsample_posterior: bool = Falsereturn_dict: bool = Truegenerator: typing.Optional[torch.Generator] = None ) → ~models.vae.DecoderOutput or tuple

Tham số

  • sample (torch.Tensor) — Mẫu đầu vào.
  • sample_posterior (bool, tùy chọn, mặc định là False) — Có lấy mẫu từ posterior hay không.
  • return_dict (bool, tùy chọn, mặc định là True) — Có nên trả về một DecoderOutput thay vì một tuple thông thường hay không.
  • generator (torch.Generator, tùy chọn) — Một torch.Generator để làm cho việc lấy mẫu trở nên tất định.

Trả về

~models.vae.DecoderOutput hoặc tuple

Nếu return_dict là True, một ~models.vae.DecoderOutput sẽ được trả về, ngược lại một tuple thông thường sẽ được trả về.

AutoencoderKLOutput

lớp diffusers.models.modeling_outputs.AutoencoderKLOutput

< >

( latent_dist: DiagonalGaussianDistribution )

Tham số

  • latent_dist (DiagonalGaussianDistribution) — Đầu ra được mã hóa của Encoder, được biểu diễn dưới dạng mean và logvar của DiagonalGaussianDistribution. DiagonalGaussianDistribution cho phép lấy mẫu các latent từ phân phối này.

Đầu ra của phương pháp mã hóa của AutoencoderKL.

DecoderOutput

lớp diffusers.models.autoencoders.vae.DecoderOutput

< >

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

Tham số

  • sample (torch.Tensor có hình dạng (batch_size, num_channels, height, width)) — Mẫu đầu ra đã giải mã từ lớp cuối cùng của mô hình.

Đầu ra của phương pháp giải mã.

Update on GitHub