How to Install VAE Models in ComfyUI
Principles of VAE Models
VAE (Variational AutoEncoder) is an important generative model. Imagine VAE as a very clever painter:
-
Encoder: First, this painter carefully observes a painting and memorizes the key features. This is like compressing a complex painting into simple key points.
-
Latent Space: These key points memorized by the painter form an imaginative space. In this space, the painter can freely combine these features.
-
Decoder: Then, based on these key points in mind, the painter can recreate a similar but not identical painting. This is like restoring simple key points back into a complex artwork.
The role of VAE models in AI painting is to help the model better understand and generate image details, especially when dealing with complex visual elements.
Functions of VAE Models
In AI painting models like Stable Diffusion, VAE is mainly responsible for:
-
Image Compression and Reconstruction: Compressing input images into latent space and then reconstructing them, helping the model learn essential image features.
-
Improving Image Quality: Particularly in handling facial details, lighting effects, etc., generating more realistic and high-quality images.
-
Style Consistency: Helping maintain the overall style and visual effect consistency of generated images.
-
Reducing Computational Complexity: By operating in compressed latent space, it can reduce computational complexity.
Where Can I Download VAE Models?
VAE models can typically be obtained from the following sources:
- Civitai: https://civitai.com
- Hugging Face: https://huggingface.co/
- Official websites or GitHub repositories of model publishers
On these platforms, you can search for “VAE” or “Stable Diffusion VAE” to find suitable models. For example, on Civitai, you can easily find corresponding VAE models by filtering Model types for VAE in the model library.
How to Install VAE Models?
Download VAE Model Files
Download VAE model files from the above sources, usually with extensions .pt
or .safetensors
.
Place Model Files
Put the downloaded VAE model files into the specified directory of ComfyUI:
ComfyUI_windows_portable\ComfyUI\models\vae
For better model management, it’s recommended to create subfolders in the vae directory and organize VAE model files by large model versions or other classification methods. This is because VAE models for different types of drawing models, such as different versions of Stable Diffusion models and Flux drawing models, may not be universally compatible. For example:
ComfyUI_windows_portable\ComfyUI\models\vae\SD1.5\your_vae_model.safetensors
Restart or Refresh ComfyUI
After placing the model files, restart ComfyUI or refresh the web interface to ensure the newly added VAE models are correctly loaded.
If you share model files with other AI painting software, please refer to the instructions on sharing models in Installing ComfyUI to copy or link VAE model files to the corresponding folder.
How to Use VAE Models in ComfyUI?
In ComfyUI, VAE models are mainly used through the following nodes:
- VAE Decode: Used to decode latent representations into images.
- VAE Encode: Used to encode images into latent representations.
- Load VAE: Used to load specific VAE models.
Usage steps:
- Add a “Load VAE” node and select the VAE model you want to use.
- Connect the “Load VAE” node to other nodes that need to use VAE (such as VAE Decode or VAE Encode).
- Configure other related nodes according to your workflow needs.
Some checkpoint models may already include a default VAE. If you want to use a custom VAE, make sure to explicitly load and use your chosen VAE model in the workflow.
- Related ComfyUI nodes:
Recommended VAE Models
Here are some commonly used VAE model recommendations:
-
vae-ft-mse-840000-ema-pruned: A widely used VAE model suitable for various versions of Stable Diffusion. Download Link
-
kl-f8-anime2: A VAE model optimized for anime-style images. Download Link
-
sdxl_vae.safetensors: A VAE model specifically designed for SDXL (Stable Diffusion XL). Download Link
-
orangemix.vae.pt: A VAE widely used in Anything V3 and V4 models, suitable for generating anime-style images. Download Link
-
clearvae_v2.2.safetensors: A VAE model aimed at improving image clarity. Download Link
You can try different VAE models to see which one brings the best results for your specific use case. Remember, the choice of VAE can affect the quality and style of the final generated image, so it’s worth spending time experimenting with different options.
Please note that some links may require you to log in to the respective platforms (such as Hugging Face or Civitai) to download model files. Additionally, when using these models, make sure to comply with relevant usage licenses and terms.