ljleb / comfy-mecha

Executable Stable Diffusion merge recipes in comfyui
MIT License
52 stars 3 forks source link

how merge N(N>=2) models from block weights #9

Closed vigee88 closed 3 weeks ago

vigee88 commented 1 month ago

first time to use, the functions are too powerful and complex, and I was a bit at a loss. I hope the author can post MBW workflows,thx very much!

ljleb commented 3 weeks ago

MBW is supported by the nodepack, but is not very accessible as of right now to be honest. It is still a work in progress. The way it works currently is using the "Blocks Hyper" node, which returns a MECHA_HYPER. This is the type the nodes use for communicating block weights for merge method parameters.

You have to manually type in the block weights one by one in a comma-separated list currently. This is what it looks like for weighted sum:

image

For example, with SDXL, you would type 19 numbers in the blocks input, like this:

0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5

If you are missing numbers or have one too many, it will raise an error and tell you how many numbers there are and how many there should have. If you want to specify only the first few blocks, you can uncheck "validate_num_blocks".

The "default" input is base alpha if you select the unet component. You can also use this to MBW the text encoders (the txt component (CLIP L) has 12 blocks, and the txt2 component (CLIP G) has 32)

You can use the blocks node as input to any parameter of any merge method.

I know it's not super convenient but currently this is the way it works.