Introduction to VAE in Stable Diffusion



on · 4 min read

Introduction to use VAE (Variational Autoencoder)

Are you interested in using VAE (Variational Autoencoder) to create smooth and consistent movement? In this tutorial, we'll walk you through the process of using VAE, without using complex technical terminology. We'll use clear and concise language, visual aids, and examples to help you understand how VAE works and how you can use it to create smooth and consistent movement.

What is VAE?

VAE is a type of neural network that learns to generate data by modeling the probability distribution of the data. In simpler terms, it's a way to create smooth and consistent movement in your projects.

VAE Example

VAE difference showing 3 images, left: eyes fixed, middle: eyes fixed a little differently, right: eyes corrupted

How to use VAE with Automatic1111 Stable Diffusion Web UI

Note: There is a default VAE already included with Stable Diffusion Versions v1 and v2 that is fairly good as is. The below are enhanced versions if you are after optimized results

Currently Stability AI has released two different VAE's for use that are available for download here:

Download VAE

Download Stability AI's EMA VAE

  • Produces sharper images

Download Stability AI's MSE VAE

  • Similar to EMA(above), but optimizes for smoothness

Install to Automatic1111 Web UI

Place downloaded VAE's into folder:


Apply VAE in Automatic1111 Web UI

To use VAE in your Automatic1111 Web UI, navigate to:

  • "Settings" Tab > Select "Stable Diffusion" on the left sidebar
  • Click on the dropdown selector title "SD VAE" and select your VAE
  • Click "Apply Settings" button located at the top of the page
Settings page on Automatic1111 showing a dropdown for SD VAE

Pro tip: provided by Stability AI regarding their enhanced VAE's

How to train your own custom VAE

Here are the steps you can follow to use VAE:

Install the Required Libraries

Before you can use VAE, you'll need to install some required libraries, such as Tensorflow and Keras. These libraries provide the tools you'll need to build and run your VAE model.

Define Your VAE Model

Once you have the required libraries installed, you can define your VAE model. This involves setting the input and output layers, defining the architecture of the encoder and decoder networks, and setting the loss function.

Train Your VAE Model

Once you've defined your VAE model, you can train it on your data. This involves feeding your data into the model, adjusting the weights of the network to minimize the loss function, and repeating this process until the model produces satisfactory results.

Generate New Data

Once your VAE model is trained, you can use it to generate new data that is similar to your original data. This can be useful for creating smooth and consistent movement in your projects.

Tips for using VAE

Here are some tips for using VAE effectively:

  • Keep your data consistent: To get the best results from your VAE model, make sure your data is consistent and of high quality.
  • Experiment with different architectures: Try experimenting with different architectures for your encoder and decoder networks to see which works best for your data.
  • Use visual aids: Visual aids like diagrams and charts can help you better understand how VAE works and how to use it effectively.
  • Don't be afraid to ask for help: If you're having trouble with VAE, don't be afraid to ask for help from online forums or communities. There are many resources available to help you get started with VAE and troubleshoot any issues you encounter.


In conclusion, VAE is a powerful tool for creating smooth and consistent movement in your projects. By following the steps outlined in this tutorial and keeping the tips in mind, you can effectively use VAE to achieve your goals.


About Alpaca

Hey there! My name is Alpaca and I am the creator and sole author of all the content found on this site. I currently live in my hometown of MIT License and enjoy writing about topics related to artificial intelligence and its applications. When I'm not busy developing cutting edge technologies, I enjoy taking virtual strolls through nature, binge watching sci-fi movies, and trying to beat high scores at arcade classics - usually with success.

Copyright © 2024