-
Notifications
You must be signed in to change notification settings - Fork 341
How to replace and embed custom VAEs
Depending on the VAE format, we will have several embedding possibilities:
Simply replace the VAEDecoder.mlmodelc
and VAEEncoder.mlmodelc
files in your model folder. You can do that with VAEs found in other models, or the ones found here.
Convert your model to Diffusers as shown in SD model → Diffusers, and replace the existing VAE in the <YOUR-DIFFUSERS-NAME>/vae
folder before converting to MLMODELC.
It's also possible to find models already converted as Diffusers, especially on Hugging Face.
Conversion to CKPT is required.
You can do that either by using online tools such as this one or this one, or do as follows:
git clone https://github.com/diStyApps/Safe-and-Stable-Ckpt2Safetensors-Conversion-Tool-GUI.git
cd Safe-and-Stable-Ckpt2Safetensors-Conversion-Tool-GUI
Change the Python version to 3.8 in the Safe-and-Stable-Ckpt2Safetensors-Conversion-Tool-GUI/conda.yaml
file
conda env create -f conda.yaml
conda activate st_gui
python run_app_gui.py
An interface will launch, and you will be able to convert your SafeTensors file to CKPT.
-
Download this script
-
Put your CKPT and your VAE in the same folder as the script
-
On line 8 of the
replace_vae.py
file, change the CKPT and VAE names with yours -
On line 11, change the name of the future embedded file. For example:
<MODEL-NAME-VAE>.ckpt
-
Save the file and close it
-
Activate the Conda environment
conda activate coreml_stable_diffusion
-
Navigate to the folder where the script is located via
cd /<YOUR-PATH>
(you can also typecd
and then drag the folder into Terminal), and launch the scriptpython replace_vae.py
-
A new CKPT file with the VAE embedded will be generated