LiteVAEModel<T>

Models & Types · AiDotNet.Diffusion.VAE

Lightweight VAE optimized for fast encoding/decoding on edge and mobile devices.

Inheritance: VAEModelBase<T> → LiteVAEModel<T>

Implements: IGeneratedParameterRegistrar<T>

For Beginners

Standard VAEs are large and slow — fine for servers but too slow for phones or real-time apps. LiteVAE uses efficient building blocks (like depthwise-separable convolutions) to achieve nearly the same quality at a fraction of the computational cost, enabling diffusion on mobile devices.

How It Works

LiteVAE replaces heavy encoder/decoder blocks with depthwise-separable convolutions and channel attention, achieving 3-5x faster encoding/decoding with minimal quality loss. Designed for real-time applications and resource-constrained environments.

Reference: Sauer et al., “LiteVAE: Lightweight and Efficient Variational Autoencoders for Latent Diffusion Models”, 2024

Example

var vae = new LiteVAEModel<float>(inputChannels: 3, latentChannels: 4, baseChannels: 64);
var image = Tensor<float>.CreateRandom(new[] { 1, 3, 512, 512 });
var latent = vae.Encode(image);

Constructors

Constructor Summary
LiteVAEModel(int inputChannels, int latentChannels, int baseChannels, ILossFunction<T> lossFunction, int? seed) Initializes a new LiteVAE model.

Properties

Property Summary
bool SupportsTiling { get; }
double LatentScaleFactor { get; }
int DownsampleFactor { get; }
int InputChannels { get; }
int LatentChannels { get; }

Methods

Method Summary
Tensor<T> Decode(Tensor<T> latent)
Tensor<T> Encode(Tensor<T> image, bool sampleMode)
ValueTuple<Tensor<T>, Tensor<T>> EncodeWithDistribution(Tensor<T> image)