mcmonkeyprojects / sd-dynamic-thresholding

Dynamic Thresholding (CFG Scale Fix) for Stable Diffusion (SwarmUI, ComfyUI, and Auto WebUI)
MIT License
1.12k stars 108 forks source link

Remove HiRes fix warning for UniPC #36

Closed horribleCodes closed 1 year ago

horribleCodes commented 1 year ago

Copying straight from https://github.com/vladmandic/automatic/issues/641:

In text2img, when using UniPC with HiRes fix enabled, you still get the following warning:

╭───────────────────────────────────────── Traceback (most recent call last) ──────────────────────────────────────────╮
│ C:\Users\source\repos\automatic\modules\scripts.py:372 in process_batch                                        │
│                                                                                                                      │
│   371 │   │   │   │   args = p.per_script_args.get(script.title(), p.script_args[script.args_f                       │
│ ❱ 372 │   │   │   │   script.process_batch(p, *args, **kwargs)                                                       │
│   373 │   │   │   except Exception as e:                                                                             │
│                                                                                                                      │
│ C:\Users\source\repos\automatic\extensions-builtin\sd-dynamic-thresholding\scripts\dynamic_thresholding.py:80  │
│ in process_batch                                                                                                     │
│                                                                                                                      │
│    79 │   │   if p.sampler_name == 'UniPC' and p.enable_hr:                                                          │
│ ❱  80 │   │   │   raise RuntimeError(f"UniPC does not support Hires Fix. Auto WebUI silently s                       │
│    81 │   │   mimic_scale = getattr(p, 'dynthres_mimic_scale', mimic_scale)                                          │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
RuntimeError: UniPC does not support Hires Fix. Auto WebUI silently swaps to DDIM for this, which DynThresh does not
support. Please swap to a sampler capable of img2img processing for HR Fix to work.

However, at this point, UniPC is already a valid img2img sampler, and as of https://github.com/vladmandic/automatic/commit/ba50dbbdbf946d3b724c84e5c711caddfc8c4770, a given secondary sampler that is capable of img2img shouldn't cause this error in the first place.

So in my case, there are two reasons why this error is inapproriate:

1) The extension warns about switching to DDIM even though UniPC is capable of img2img. 2) The sampler used for the hires pass, in my case, isn't DDIM, but rather one that does support dynamic thresholding.

I can see where the error is coming from, due to multiple different separate modules coming in conflict with each other, and it's unrealistic to expect support for different forks, but maybe it's possible to call this error only once the webui selected a sampler incompatible with this extension.

mcmonkey4eva commented 1 year ago

This extension primarily supports Automatic1111's main repo, forks that have improved things should PR upstream to Auto. It's not easy to catch the error in a more dynamic way. If you want for temporary personal usage until it's PR'd upstream, you can go find the lines it shows (79/80 in dynamic_thresholding.py) and add # in front of each line (to disable the error check).