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

SD.Next refactor of modules breaks UniPC support #78

Closed sullenfish closed 10 months ago

sullenfish commented 10 months ago

SD.Next project refactored modules, removing models and thus impacting the import of modules.models.diffusion.uni_pc in dynthres_unipc.py.

Cheap solution:

Replace

from modules.models.diffusion import uni_pc

With

try:
    from modules.models.diffusion import uni_pc
except Exception as e:
    try:
        from modules.unipc import sampler
        class SDNextUniPC(object):
            def __init__(self):
                self.sampler = sampler
                self.uni_pc = sampler
        uni_pc = SDNextUniPC()
    except Exception as ex:
        print(f"\n\n======\nError! WebUI and SD.Next UniPC sampler support failed to load.\n(Errors: {e}, {ex})\n======")

I can draft a PR if that's an acceptable approach.

mcmonkey4eva commented 10 months ago

Thank you for the report & PR

After looking at vlad's source https://github.com/vladmandic/automatic/blob/master/modules/unipc/uni_pc.py it seems from modules import unipc as uni_pc should suffice to import as expected, rather than the middle module. Rather annoying to randomly refactor that, but vlad doesn't seem overly concerned with compatibility. Let me know if the simplified import doesn't work

sullenfish commented 10 months ago

Working as designed. Thank you!