Kosinkadink / ComfyUI-Advanced-ControlNet

ControlNet scheduling and masking nodes with sliding context support
GNU General Public License v3.0
615 stars 61 forks source link

Different results on old and new version #199

Closed curlysasha closed 2 days ago

curlysasha commented 2 days ago

first screenshot commit 949843e2c007d0c947b0ad10ad8900a5df359aa7 second screenshot newest commit, and newest comfyui (old not working) workflows is same very bad stylization on new version, mayber problem not in newest commit, i dont test all previous versions

image image

curlysasha commented 2 days ago

i found when its change! commit 49609d318f5df3baec1e4a9b92a0e8aded81fc38 how to make generations great again?)

Refactored cn weights to separate out input, middle, and output blocks, improved soft weight behavior to generalize math to be architecture agnostic (for the most part)

Kosinkadink commented 2 days ago

Was just about to tell you it's that exact commit lol, here is the explanation:

When I first coded scaled soft weights almost a year and a half ago, I wrongly hardcoded the math to expect 13 layers, which is what SD1.5 controlnets have (where 12 layers are the output, 1 layer is the middle). The middle layer was intended to stay at 1.0, with only the output layers getting scaled downwards, the last output layer being scaled to the base_multiplier (0.825 by default), and the others getting lower with a formula based on the total amount of output layers.

However, classic SDXL controlnets have 10 layers (9 output, 1 middle). But, the code was using the bad 13 layer code, and since the layers are counted from the end, the value obtained by the default 0.825 were actually much lower, AND the middle block, was given one of those values instead of just 1.0.

Two ways to replicate the effect of old code: 1) Just make the base_multiplier lower, basically almost half the value, and the results will become close. 2) SDXL seems quite responsive to lowering the middle weight, so I plan to add the middle weight multiplier to the Soft Scaled Weights soon. In the meantime, you can get identical results by using the Control Soft Weights [SD1.5] node, and make the middle_0 weight equal to the output_9 value. These are the exact values the screwed up code used to give with the default base_multiplier 0.825 - as you can see, output_9 through output_11 are actually ignored SDXL does not have those layers. So, the topmost output layer for SDXL was actually being given the low value of 0.463, half of the desired amount. That goes back to Point 1, where the old results were using basically half the base_multiplier than intended.

TL;DR if you want exact results as before, load up Control Soft Weights [SD1.5] and give middle_0 the number that's in output_9 to reproduce the erroneous code from before (only works with base_multiplier was set to 0.825 in old gens). image

curlysasha commented 2 days ago

thank you, 99.9% same result now

image

now i have to fix a lot of worflows )