This script combines two stable-diffusion models at a user-defined ratio.
The ratio works as follows:
If you are using Windows and Automatics Webui, which I highly recommend, the easiest way to use this script is to use the .bat file.
merge.bat
If you aren't using Automatic's web UI or are comfortable with the command line, you can also run merge.py
directly.
Just like with the .bat method, I'd recommend creating a folder within your stable-diffusion installation's main folder. This script requires torch to be installed, which you most likely will have installed in a venv inside your stable-diffusion webui install.
..\venv\Scripts\activate
conda activate ldm
py merge.py model0 model1 --alpha 0.5 --output merged
--alpha
controls how much weight is put on the second model. Defaults to 0.5, if omitted--output
is the filename of the merged file, without file extension. Defaults to "merged", if omitted--device
is the device that's going to be used to merge the models. Unless you have a ton of VRAM, you should probably just ignore this. Defaults to 'cpu', if omitted.
(size of both models) * 1.15
. Merging 2 models at 3.76GB resulted in rougly 8.6GB of VRAM usage on top of everything else going on.--device "cuda:x"
where x is the card corresponding to the output of nvidia-smi -L
py
with python
, python3
, conda
or something else entirely.merge.bat
from him.merge.py
from this post by r_Sh4d0w, who seems to have gotten it from mlfoundations/wise-ft