mcmonkeyprojects / sd-dynamic-thresholding

Dynamic Thresholding (CFG Scale Fix) for Stable Diffusion (eSwarmUI, ComfyUI, and Auto WebUI)
MIT License
1.1k stars 103 forks source link

Very poor IMG2IMG outputs on latest version of SD.Next #83

Closed a2ZxgdqHeSs8F51cIyuK closed 9 months ago

a2ZxgdqHeSs8F51cIyuK commented 10 months ago

Hello, issue has been documented over on SD.Next's repository: vladmandic/automatic#2457 Could you kindly take a look at it and see if you can solve it or help Vlad with it? If you need more information or want me to run some tests let me know.

KerfuffleV2 commented 9 months ago

Just curious, does this branch fix anything for you? https://github.com/KerfuffleV2/sd-dynamic-thresholding/tree/fix-steps

I noticed that the max steps calculation wasn't working (at least with the devel version of sd-web-ui). The number of steps didn't match what it expected (seems like it was usually double) so you might set steps 30, and then the sampler got called with step 55 (real max steps would be ~60) and scale the CFG based on max steps 30 but step 50 which produced really absurd values, especially in the last few steps.

I don't really know what I'm doing with SD script stuff, but the results I'm getting with this change seem much improved. (Also contains a minor tweak to make the config options be visible by default).

mcmonkey4eva commented 9 months ago

(Also contains a minor tweak to make the config options be visible by default). those are hidden if you're using a scheduler that doesn't use them, and visible if you use a scheduler that does have them.

I'm not sure why you did the - 2 change.

The total_steps part, uh, shouldn't be needed in theory unless SDNext is doing something weird - but assuming perhaps it is, if your change worked it'd be from that part, so I've gone ahead and imported just that bit

KerfuffleV2 commented 9 months ago

@mcmonkey4eva Sorry for the confusion and thanks for the reply, my post wasn't clear. I'm actually not using SDNext, just the devel branch of normal webUI. I was just asking the other person if my changes helped with their issue (since I thought it could possibly be related to the step count thing).

I don't actually know what I'm doing, basically I added a bunch of debug output to the script and looked at the values. - 2 there is what resulted in it hitting the scale I expected on the last step.

those are hidden if you're using a scheduler that doesn't use them, and visible if you use a scheduler that does have them.

They got hidden every time the page reloaded for me and the only way to see them would be to toggle the script to disabled then back to enabled and then go and change type to a different value and then back again (so the limits would show up).

Possibly it's related to using the dev version of webui rather than the main one. Anyway, you probably shouldn't make changes based on what I said unless you can verify it's actually correct. :) All I can really say is I get better results with those changes with my current set up.

a2ZxgdqHeSs8F51cIyuK commented 9 months ago

I haven't tested that yet, but if you look at the late replies on the issue I linked, it seems it was just an issue with two settings not showing up and since they defaulted to the minimum value they gave terrible results. The two settings show up by fiddling a bit with other menus and once they're set to appropriate values the outputs are good again.

mcmonkey4eva commented 9 months ago

Wait, what do you mean "when the page reloaded" and all? Auto webui doesn't persist params at all, so the fields are hidden again after a reload because they're no longer relevant (back to Constant)

a2ZxgdqHeSs8F51cIyuK commented 9 months ago

I'm using the state extension to maintain values, so once I have set it up how I like it, it keeps the settings. But SD Next had just had a big update, so I had to reset all the settings. I configured all the options I could see, but those two settings were hidden and had defaulted to minimum leading to bad outputs. So it's really just a small issue that those two settings start out completely hidden unless other settings are touched, the extension itself seems to work fine once it is set up correctly.

mcmonkey4eva commented 9 months ago

I think that's technically an issue with the state extension then - it should be triggering the change event if it's altering param values

KerfuffleV2 commented 9 months ago

@mcmonkey4eva

Wait, what do you mean "when the page reloaded" and all? Auto webui doesn't persist params at all

It actually can, you can save the state as defaults: Settings -> Other -> Defaults. In that case, it'll load with dynamic thresholding enabled but you can't see the settings until you follow the process I described before: toggle it off then on again to be able see any configuration options and then change the the scaling types to something else then back again to actually see stuff like the minimums. That's a built in feature, not an addon as far as I know (pretty sure it's also not only in the devel branch).

mcmonkey4eva commented 9 months ago

Ehhh screw it I'm not up for a fight with gradio's broken software, I went ahead and just made all params always visible. Another bit of nicer-UI lost to gradio being too buggy to reliably have niceness :(

KerfuffleV2 commented 9 months ago

Ehhh screw it I'm not up for a fight with gradio's broken software, I went ahead and just made all params always visible.

I think that's fine. :) The dynamic cfg thing can be collapsed so it won't really hurt if all the options are visible, they don't need to take up space. Also, I wouldn't install the addon if I didn't want to use it so making that more convenient seems good to me!

Maybe it's a workaround for broken Gradio stuff but... at least one person thinks we still have niceness.