Skip to content

a python script to merge stable diffusion's Unet blocks.

Notifications You must be signed in to change notification settings

idpen/merge_unet_block

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

merge_unet_block

a python script to merge stable diffusion's Unet blocks.
you should run the script with Python3 env.

Install

pip install safetensors
# pip install pytorch

For example

full Unet layer with index and alpha

the alpha value is for "xxx2.safetensors".

python merge_unet_blocks.py xxx1.safetensors xxx2.safetensors \
        --input_blocks "0:0.5, 1:0.5, 2:0.5, 3:0.6, 4:0.5, 5:0.5, 6:0.5, 7:0.5, 8:0.5, 9:0.5, 10:0.5, 11:0.5" \
        --middle_blocks "0:0.5, 1:0.5, 2:0.6" \
        --output_blocks "0:0.5, 1:0.5, 2:0.5, 3:0.6, 4:0.5, 5:0.5, 6:0.5, 7:0.5, 8:0.5, 9:0.5, 10:0.5, 11:0.5" \
        --out "0:0.5, 2:0.3" \
        --time_embed "0:0.5, 2:0.3" \
        --dump_path ./merged.safetensors

or (same as above):

python merge_unet_blocks.py xxx1.safetensors xxx2.ckpt \
        --base_alpha 0.5 \
        --input_blocks "3:0.6" \
        --middle_blocks "2:0.6" \
        --output_blocks "3:0.6," \
        --out "2:0.3" \
        --time_embed "2:0.3" \
        --dump_path ./merged.safetensors

or just (merge all blocks with base_alpha):

python merge_unet_blocks.py xxx1.ckpt xxx2.ckpt \
        --base_alpha 0.5 \
        --dump_path ./merged.ckpt

About

a python script to merge stable diffusion's Unet blocks.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages