High-quality Variational Autoencoder (VAE) for Stable Diffusion XL (SDXL) models, featuring enhanced reconstruction quality and improved detail preservation.
Model Description
The SDXL VAE is an improved variational autoencoder component for Stable Diffusion XL that significantly enhances the quality of generated images. This VAE was specifically retrained by Stability AI with optimized training parameters to improve local, high-frequency details in generated images.
Key Improvements:
Enhanced Training: Trained with larger batch size (256 vs 9) for better convergence
Exponential Moving Average (EMA): Weight tracking with EMA for improved stability
Superior Reconstruction: Outperforms original SD VAE across all evaluation metrics
Detail Preservation: Significantly better at preserving fine details and textures
Face Quality: Trained on LAION-Aesthetics and LAION-Humans for improved human subject rendering
This VAE is compatible with all SDXL-based models and can be used as a drop-in replacement for the standard VAE to improve output quality.
1pipe.enable_attention_slicing()2pipe.enable_vae_slicing()# Process images in slices
Batch Processing
python
1# Process multiple images efficiently2with torch.no_grad():3 latents = vae.encode(batch_images).latent_dist.sample()
Compile for Speed (PyTorch 2.0+)
vae = torch.compile(vae, mode="reduce-overhead")
Quality Improvements
Always use this VAE with SDXL models for best quality
Particularly improves fine details, textures, and faces
Most noticeable in high-resolution outputs (1024×1024+)
Reduces artifacts and improves color accuracy
Memory Management
VAE decoding is memory-intensive for large batches
Use enable_vae_slicing() for memory-constrained systems
Consider tiled VAE decoding for resolutions >1024×1024
License
MIT License
Copyright (c) 2023 Stability AI
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Citation
If you use this VAE in your research or projects, please cite:
bibtex
1@misc{sdxl-vae-2023,
2 title={SDXL: Improved Variational Autoencoder},
3 author={Stability AI},
4 year={2023},
5 howpublished={\url{https://huggingface.co/stabilityai/sdxl-vae}},
6}
78@article{rombach2022high,
9 title={High-resolution image synthesis with latent diffusion models},
10 author={Rombach, Robin and Blattmann, Andreas and Lorenz, Dominik and Esser, Patrick and Ommer, Bj{\"o}rn},
11 journal={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
12 pages={10684--10695},
13 year={2022}
14}