Diffusers documentation
AutoencoderKLMagvit
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
< source >( 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
< source >( 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.DecoderOutputthay 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
< source >( x: Tensorreturn_dict: bool = True )
Mã hóa một lô ảnh thành các biến ẩn.
enable_tiling
< source >( 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
< source >( 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ộtDecoderOutputthay vì một tuple thông thường hay không. - generator (
torch.Generator, tùy chọn) — Mộttorch.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
< source >( latent_dist: DiagonalGaussianDistribution )
Đầu ra của phương pháp mã hóa của AutoencoderKL.
DecoderOutput
lớp diffusers.models.autoencoders.vae.DecoderOutput
< source >( sample: Tensorcommit_loss: typing.Optional[torch.FloatTensor] = None )
Đầu ra của phương pháp giải mã.