Buckets:

hf-doc-build/doc / diffusers /v0.43.0 /zh /api /models /autoencoder_kl_kvae.md
mishig's picture
|
download
raw
4.73 kB

AutoencoderKLKVAE

带有 KL 散度损失的二维变分自编码器(VAE)模型。

可以使用以下代码片段加载该模型。

import torch
from diffusers import AutoencoderKLKVAE

vae = AutoencoderKLKVAE.from_pretrained("kandinskylab/KVAE-2D-1.0", subfolder="diffusers", dtype=torch.bfloat16)

AutoencoderKLKVAE[[diffusers.AutoencoderKLKVAE]]

diffusers.AutoencoderKLKVAE[[diffusers.AutoencoderKLKVAE]]

diffusers.AutoencoderKLKVAE(in_channels: int = 3, channels: int = 128, num_enc_blocks: int = 2, num_dec_blocks: int = 2, z_channels: int = 16, double_z: bool = True, ch_mult: typing.Tuple[int, ...] = (1, 2, 4, 8), sample_size: int = 1024)

源代码

参数:

in_channels (int, 可选,默认为 3):输入图像的通道数。

channels (int, 可选,默认为 128):多分辨率块中的基础通道数。

num_enc_blocks (int, 可选,默认为 2):编码器多分辨率层中 Resnet 块的数量。

num_dec_blocks (int, 可选,默认为 2):解码器多分辨率层中 Resnet 块的数量。

z_channels (int, 可选,默认为 16):潜在空间中的通道数。

double_z (bool,可选,默认为 True):是否将编码器的输出通道数加倍。

ch_mult (Tuple[int, ...],可选,默认为 (1, 2, 4, 8)):多分辨率块中的通道乘数。

sample_size (int,可选,默认为 1024):采样输入大小。

一个带有 KL 损失的 VAE 模型,用于将图像编码为潜在表示,并将潜在表示解码为图像。

该模型继承自 ModelMixin。有关为所有模型实现的通用方法(例如下载或保存),请查阅其父类文档。

decode[[diffusers.AutoencoderKLKVAE.decode]]

decode(z: FloatTensor, return_dict: bool = True, generator = None)

源代码

参数:

z (torch.Tensor) : 输入的潜在向量批次。

return_dict (bool,可选,默认为 True):是否返回 ~models.vae.DecoderOutput 而不是普通元组。

返回: ~models.vae.DecoderOutput 或 tuple

如果 return_dict 为 True,则返回 ~models.vae.DecoderOutput,否则返回普通的 tuple。

解码一批图像。

encode[[diffusers.AutoencoderKLKVAE.encode]]

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

源代码

参数:

x (torch.Tensor) : 输入图像批次。

return_dict (bool,可选,默认为 True):是否返回 ~models.autoencoder_kl.AutoencoderKLOutput 而不是普通元组。

返回值:

编码图像的潜在表示。如果 return_dict 为 True,则返回 ~models.autoencoder_kl.AutoencoderKLOutput,否则返回普通的 tuple。

将一批图像编码为潜在表示。

forward[[diffusers.AutoencoderKLKVAE.forward]]

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

源代码

参数:

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[[diffusers.AutoencoderKLKVAE.tiled_decode]]

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

源代码

参数:

z (torch.Tensor) : 输入的潜在向量批次。

return_dict (bool,可选,默认为 True):是否返回 ~models.vae.DecoderOutput 而不是普通元组。

返回: ~models.vae.DecoderOutput 或 tuple

如果 return_dict 为 True,则返回 ~models.vae.DecoderOutput,否则返回普通的 tuple。

使用分块解码器解码一批图像。

Xet Storage Details

Size:
4.73 kB
·
Xet hash:
c10eab16c8b8a12a0b6876debf0887792e03f97688e557b79c53247c2d480117

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