picobyte / stable-diffusion-webui-wd14-tagger

Labeling extension for Automatic1111's Web UI
580 stars 70 forks source link

Models path can't be imported #44

Closed catboxanon closed 1 year ago

catboxanon commented 1 year ago

Related to the dev branch of the webui, specifically this recent PR: https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/12426

one possible problem is that if a script imports shared in preload.py -- which it should not do -- it will see empty values instead of what should be there after initialization; this likely will not be fixed

This causes this extension to not load and throw an error to the console, as shared is attempted to be imported here. https://github.com/picobyte/stable-diffusion-webui-wd14-tagger/blob/61d1498165814c00b00f38500fe06ccfab427d96/preload.py#L5

*** Error running preload() for Q:\AI\git\stable-diffusion-webui\extensions\stable-diffusion-webui-wd14-tagger\preload.py
    Traceback (most recent call last):
      File "Q:\AI\git\stable-diffusion-webui\modules\script_loading.py", line 26, in preload_extensions
        module = load_module(preload_script)
      File "Q:\AI\git\stable-diffusion-webui\modules\script_loading.py", line 10, in load_module
        module_spec.loader.exec_module(module)
      File "<frozen importlib._bootstrap_external>", line 883, in exec_module
      File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
      File "Q:\AI\git\stable-diffusion-webui\extensions\stable-diffusion-webui-wd14-tagger\preload.py", line 5, in <module>
        from modules.shared import models_path  # pylint: disable=import-error
    ImportError: cannot import name 'models_path' from partially initialized module 'modules.shared' (most likely due to a circular import) (Q:\AI\git\stable-diffusion-webui\modules\shared.py)
picobyte commented 1 year ago

This occurs here, so if I understand correctly the defaults turn out to be empty, but is this really a problem? Why would anyone use these flags to rely on the default? Maybe to make it more explicit the default and module imports should just go.

Fixed with e3215e8d291891ec189a663a2026807855ff3ecd and 8579b172a0ef42101b77b34377fba169b2656ee0