WebUI提示词反推扩展WD14常见错误及解决

在Stable Diffusion WebUI中,如果我们需要根据图片反推提示词,就需要用到WD14 tag这个扩展插件,但在安装这个插件会遇到些问题,导致无法启用该插件。本文列出WD14这个插件启动错误及解决办法。

错误类型

  1. ImportError: cannot import name ‘wrap_gradio_gpu_call’ from ‘webui’
  2. AttributeError: ‘Namespace’ object has no attribute ‘deepdanbooru_projects_path’
  3. ImportError: cannot import name ‘models_path’ from partially initialized module ‘modules.shared’ (most likely due to a circular import)

解决方法

问题一

ImportError: cannot import name ‘wrap_gradio_gpu_call’ from ‘webui’

当启用插件时,控制台报错:

*** Error loading script: tagger.py
    Traceback (most recent call last):
      File "D:\Program\stable-diffusion-webui\modules\scripts.py", line 382, in load_scripts
        script_module = script_loading.load_module(scriptfile.path)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "D:\Program\stable-diffusion-webui\modules\script_loading.py", line 10, in load_module
        module_spec.loader.exec_module(module)
      File "<frozen importlib._bootstrap_external>", line 940, in exec_module
      File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
      File "D:\Program\stable-diffusion-webui\extensions\stable-diffusion-webui-wd14-tagger\scripts\tagger.py", line 5, in <module>
        from tagger.ui import on_ui_tabs
      File "D:\Program\stable-diffusion-webui\extensions\stable-diffusion-webui-wd14-tagger\tagger\ui.py", line 10, in <module>
        from webui import wrap_gradio_gpu_call
    ImportError: cannot import name 'wrap_gradio_gpu_call' from 'webui' (D:\Program\stable-diffusion-webui\webui.py)

编辑文件

“你的webui目录“\extensions\stable-diffusion-webui-wd14-tagger\tagger\ui.py
修正内容
from webui import wrap_gradio_gpu_call
↓
from modules.call_queue import wrap_gradio_gpu_call

问题二

AttributeError: ‘Namespace’ object has no attribute ‘deepdanbooru_projects_path’

当启用插件时,控制台报错:

*** Error executing callback ui_tabs_callback for D:\Program\stable-diffusion-webui\extensions\stable-diffusion-webui-wd14-tagger\scripts\tagger.py
    Traceback (most recent call last):
      File "D:\Program\stable-diffusion-webui\modules\script_callbacks.py", line 166, in ui_tabs_callback
        res += c.callback() or []
               ^^^^^^^^^^^^
      File "D:\Program\stable-diffusion-webui\extensions\stable-diffusion-webui-wd14-tagger\tagger\ui.py", line 329, in on_ui_tabs
        interrogator_names = utils.refresh_interrogators()
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "D:\Program\stable-diffusion-webui\extensions\stable-diffusion-webui-wd14-tagger\tagger\utils.py", line 70, in refresh_interrogators
        for path in os.scandir(shared.cmd_opts.deepdanbooru_projects_path):
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    AttributeError: 'Namespace' object has no attribute 'deepdanbooru_projects_path'

编辑文件:

“你的webui目录“\extensions\stable-diffusion-webui-wd14-tagger\tagger\utils.py
for path in os.scandir(shared.cmd_opts.deepdanbooru_projects_path):
↓
for path in os.scandir(getattr(shared.cmd_opts, 'deepdanbooru_projects_path', default_ddp_path)):

问题三

ImportError: cannot import name ‘models_path’ from partially initialized module ‘modules.shared’ (most likely due to a circular import)

当启用插件时,控制台报错:

*** Error running preload() for D:\Program\stable-diffusion-webui\extensions\stable-diffusion-webui-wd14-tagger\preload.py
    Traceback (most recent call last):
      File "D:\Program\stable-diffusion-webui\modules\script_loading.py", line 26, in preload_extensions
        module = load_module(preload_script)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "D:\Program\stable-diffusion-webui\modules\script_loading.py", line 10, in load_module
        module_spec.loader.exec_module(module)
      File "<frozen importlib._bootstrap_external>", line 940, in exec_module
      File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
      File "D:\Program\stable-diffusion-webui\extensions\stable-diffusion-webui-wd14-tagger\preload.py", line 4, in <module>
        from modules.shared import models_path
    ImportError: cannot import name 'models_path' from partially initialized module 'modules.shared' (most likely due to a circular import) (D:\Program\stable-diffusion-webui\modules\shared.py)

编辑文件:

“你的webui目录“\extensions\stable-diffusion-webui-wd14-tagger\preload.py
from modules.shared import models_path
↓
from modules.paths_internal import models_path

总结

经我在Windows及Linux系统测试,以上方法即可解决WD14无法启动的问题。

© 版权声明
THE END
若本文对您有帮助,欢迎点赞打赏转发
您的支持将是作者更新最大的动力
点赞49打赏 分享
评论 共1条

请登录后发表评论

    暂无评论内容