flux2vae ¶
Classes¶
fastvideo.models.vaes.flux2vae.AutoencoderKLFlux2 ¶
AutoencoderKLFlux2(config: Flux2VAEConfig)
Bases: Module, ParallelTiledVAE
A VAE model with KL loss for encoding images into latents and decoding latent representations into images.
This model inherits from [ParallelTiledVAE] for tiling support and uses standard diffusers Encoder/Decoder components for Flux2 image generation.
Source code in fastvideo/models/vaes/flux2vae.py
Attributes¶
fastvideo.models.vaes.flux2vae.AutoencoderKLFlux2.attn_processors property ¶
Methods:¶
fastvideo.models.vaes.flux2vae.AutoencoderKLFlux2.decode ¶
decode(z: FloatTensor, return_dict: bool = True, generator=None) -> Union[DecoderOutput, FloatTensor]
Decode a batch of images.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
z | `torch.Tensor` | Input batch of latent vectors. | required |
return_dict | `bool`, *optional*, defaults to `True` | Whether to return a [ | True |
Returns:
| Type | Description |
|---|---|
Union[DecoderOutput, FloatTensor] | [ |
Source code in fastvideo/models/vaes/flux2vae.py
fastvideo.models.vaes.flux2vae.AutoencoderKLFlux2.encode ¶
encode(x: Tensor, return_dict: bool = True) -> Union[AutoencoderKLOutput, Tuple[DiagonalGaussianDistribution]]
Encode a batch of images into latents.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x | `torch.Tensor` | Input batch of images. | required |
return_dict | `bool`, *optional*, defaults to `True` | Whether to return a [ | True |
Returns:
| Type | Description |
|---|---|
Union[AutoencoderKLOutput, Tuple[DiagonalGaussianDistribution]] | The latent representations of the encoded images. If |
Union[AutoencoderKLOutput, Tuple[DiagonalGaussianDistribution]] | [ |
Source code in fastvideo/models/vaes/flux2vae.py
fastvideo.models.vaes.flux2vae.AutoencoderKLFlux2.forward ¶
forward(sample: Tensor, sample_posterior: bool = False, return_dict: bool = True, generator: Optional[Generator] = None) -> Union[DecoderOutput, Tensor]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sample | `torch.Tensor` | Input sample. | required |
sample_posterior | `bool`, *optional*, defaults to `False` | Whether to sample from the posterior. | False |
return_dict | `bool`, *optional*, defaults to `True` | Whether or not to return a [ | True |
Source code in fastvideo/models/vaes/flux2vae.py
fastvideo.models.vaes.flux2vae.AutoencoderKLFlux2.set_attn_processor ¶
Sets the attention processor to use to compute attention.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
processor | `dict` of `AttentionProcessor` or only `AttentionProcessor` | The instantiated processor class or a dictionary of processor classes that will be set as the processor for all If | required |
Source code in fastvideo/models/vaes/flux2vae.py
fastvideo.models.vaes.flux2vae.AutoencoderKLFlux2.set_default_attn_processor ¶
Disables custom attention processors and sets the default attention implementation.
Source code in fastvideo/models/vaes/flux2vae.py
fastvideo.models.vaes.flux2vae.AutoencoderKLFlux2.tiled_decode ¶
Decode a batch of images using a tiled decoder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
z | `torch.Tensor` | Input batch of latent vectors. | required |
return_dict | `bool`, *optional*, defaults to `True` | Whether or not to return a [ | True |
Returns:
| Type | Description |
|---|---|
Union[DecoderOutput, Tensor] | [ |
Source code in fastvideo/models/vaes/flux2vae.py
fastvideo.models.vaes.flux2vae.AutoencoderKLFlux2.tiled_encode ¶
tiled_encode(x: Tensor, return_dict: bool = True) -> AutoencoderKLOutput
Encode a batch of images using a tiled encoder.
When this option is enabled, the VAE will split the input tensor into tiles to compute encoding in several steps. This is useful to keep memory use constant regardless of image size. The end result of tiled encoding is different from non-tiled encoding because each tile uses a different encoder. To avoid tiling artifacts, the tiles overlap and are blended together to form a smooth output. You may still see tile-sized changes in the output, but they should be much less noticeable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x | `torch.Tensor` | Input batch of images. | required |
return_dict | `bool`, *optional*, defaults to `True` | Whether or not to return a [ | True |
Returns:
| Type | Description |
|---|---|
AutoencoderKLOutput | [ |