SDXLVAEModel<T>
Models & Types · AiDotNet.Diffusion.VAE
SDXL-optimized VAE with improved decoder fidelity for 1024x1024 generation.
Inheritance: VAEModelBase<T> → SDXLVAEModel<T>
Implements: IGeneratedParameterRegistrar<T>
For Beginners
SDXL generates 1024x1024 images (4x more pixels than SD 1.5’s 512x512). The VAE decoder was retrained specifically for this higher resolution to produce sharper, more detailed reconstructions. The encoder remains compatible with the standard SD VAE, but the decoder is significantly improved.
How It Works
The SDXL VAE is a fine-tuned version of the Stable Diffusion VAE with improved decoder weights for higher fidelity reconstruction at 1024x1024 resolution. Uses the same architecture as StandardVAE but with SDXL-specific scale factors and optimized decoder weights trained on high-resolution data.
Reference: Podell et al., “SDXL: Improving Latent Diffusion Models for High-Resolution Image Synthesis”, ICLR 2024
Example
var vae = new SDXLVAEModel<float>(inputChannels: 3, latentChannels: 4, baseChannels: 128);
var image = Tensor<float>.CreateRandom(new[] { 1, 3, 1024, 1024 });
var latent = vae.Encode(image);
Constructors
| Constructor | Summary |
|---|---|
SDXLVAEModel(int inputChannels, int latentChannels, int baseChannels, int[] channelMultipliers, ILossFunction<T> lossFunction, int? seed) |
Initializes a new SDXL VAE model. |
Properties
| Property | Summary |
|---|---|
bool SupportsSlicing { get; } |
|
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) |