vladmandic / automatic

SD.Next: Advanced Implementation of Stable Diffusion and other Diffusion-based generative image models
https://github.com/vladmandic/automatic
GNU Affero General Public License v3.0
5.68k stars 421 forks source link

[Issue]: Unable to load sd-webui-additional-networks extension #297

Closed CKwasd closed 1 year ago

CKwasd commented 1 year ago

Issue Description

Installing extension: https://github.com/kohya-ss/sd-webui-additional-networks.git into
E:\automatic\extensions\sd-webui-additional-networks
Traceback (most recent call last):
  File "E:\automatic\venv\lib\site-packages\gradio\routes.py", line 394, in run_predict
    output = await app.get_blocks().process_api(
  File "E:\automatic\venv\lib\site-packages\gradio\blocks.py", line 1075, in process_api
    result = await self.call_function(
  File "E:\automatic\venv\lib\site-packages\gradio\blocks.py", line 884, in call_function
    prediction = await anyio.to_thread.run_sync(
  File "E:\automatic\venv\lib\site-packages\anyio\to_thread.py", line 31, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "E:\automatic\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 937, in run_sync_in_worker_thread
    return await future
asyncio.exceptions.CancelledError
WebSocket closed (ignore asyncio.exceptions.CancelledError)
Server shutdown
Server restart
Available models: E:\automatic\models\Stable-diffusion 3
ControlNet preprocessor location: E:\automatic\extensions-builtin\sd-webui-controlnet\annotator\downloads
[AddNet] Updating model hashes...
0it [00:00, ?it/s]
Module load: E:\automatic\extensions\sd-webui-additional-networks\scripts\additional_networks.py: AttributeError
╭───────────────────────────────────────── Traceback (most recent call last) ─────────────────────────────────────────╮
│ E:\automatic\modules\script_loading.py:10 in load_module                                                            │
│                                                                                                                     │
│    9 │   try:                                                                                                       │
│ ❱ 10 │   │   module_spec.loader.exec_module(module)                                                                 │
│   11 │   except Exception as e:                                                                                     │
│ in exec_module:883                                                                                                  │
│ in _call_with_frames_removed:241                                                                                    │
│                                                                                                                     │
│ E:\automatic\extensions\sd-webui-additional-networks\scripts\additional_networks.py:392 in <module>                 │
│                                                                                                                     │
│   391                                                                                                               │
│ ❱ 392 xyz_grid_support.initialize(Script)                                                                           │
│   393                                                                                                               │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
AttributeError: module 'scripts.xyz_grid_support' has no attribute 'initialize'

Version Platform Description

00:23:28-929531 INFO     Python 3.10.0 on Windows
00:23:29-025530 INFO     No changes detected: quick launch active
00:23:29-026530 INFO     Setting environment tuning
00:23:30-331529 INFO     Torch 2.0.0+cu118
00:23:30-364530 INFO     Torch backend: nVidia CUDA 11.8 cuDNN 8700
00:23:30-365531 INFO     Torch detected GPU: NVIDIA GeForce RTX 3080 VRAM 10240 Arch (8, 6) Cores 68
00:23:30-366530 INFO     Server arguments: ['--medvram']

Already run --upgrade image

vladmandic commented 1 year ago

yeah, just saw that. its there but fails due to silly python handling of module paths. i'll figure it out, but not even sure what changed to cause this.

Panchovix commented 1 year ago

I noticed that moving the additional networks extensions to the extensions-builtin folder fixes it, not sure why though.

EDIT: it seems some extensions are broken if they're on the extensions folder, moving them to extensions-builtin folder fixes them.

vladmandic commented 1 year ago

the problem is that some extensions have conflicting code. by moving it to extensions-builtin, you've increased priority of loading that extension. so whatever other extension was causing the conflict gets loaded after instead of before. moving everything to extensions-builtin is not a solution. i'm keeping this issue open.

vladmandic commented 1 year ago

i've been fumbling around this, but i cant find solution. problem is if two different extensions have exactly the same internal folders/files.

for example, both controlnet and kohya additional networks perform same import

from scripts import xyz_grid_support

those are different files that are local to each extension. but python loader in its wisdom decides that module is already loaded so what ends up is that whatever extension loads second will try to use module from first loaded extension - and that will of course fail.

i'm really out of ideas. easy solution would be to have both extensions have unique module names, but i'd love to solve this in core.

anyone with ideas?

Woisek commented 1 year ago

After an update, this error still comes up:

remote: Enumerating objects: 44, done. remote: Counting objects: 100% (37/37), done. remote: Compressing objects: 100% (14/14), done. remote: Total 44 (delta 23), reused 33 (delta 23), pack-reused 7 Unpacking objects: 100% (44/44), 49.57 KiB | 474.00 KiB/s, done. From https://github.com/vladmandic/automatic 752b91d3..2ddbb667 master -> origin/master Updating 752b91d3..2ddbb667 Fast-forward TODO.md | 5 ++++- extensions-builtin/sd-webui-controlnet | 2 +- launch.py | 5 ++++- modules/devices.py | 12 ++++++++--- modules/paths_internal.py | 5 +++-- modules/processing.py | 2 +- modules/script_loading.py | 2 -- modules/sd_models.py | 5 ++++- modules/sd_vae.py | 31 +++++++++++++-------------- modules/shared.py | 5 +---- modules/xlmr.py | 11 +++++----- requirements.txt | 4 ++-- setup.py | 39 ++++++++++++++++++---------------- 13 files changed, 70 insertions(+), 58 deletions(-) venv "I:\Super SD 2.0\automatic\venv\Scripts\Python.exe" 10:54:37-074924 INFO Python 3.10.6 on Windows 10:54:37-663550 INFO Running setup 10:54:37-704419 INFO Version: 2ddbb667 Fri Apr 21 00:07:38 2023 -0400 10:54:38-400976 INFO Updating Wiki 10:54:41-538640 INFO Installing package: torch torchaudio torchvision --index-url https://download.pytorch.org/whl/cu118 10:54:47-888997 INFO Torch 2.0.0+cu118 10:54:47-906949 INFO Torch backend: nVidia CUDA 11.8 cuDNN 8700 10:54:47-909941 INFO Torch detected GPU: NVIDIA GeForce RTX 2070 SUPER VRAM 8192 Arch (7, 5) Cores 40 10:54:47-910939 INFO Installing requirements 10:54:47-928917 INFO Installing packages 10:54:47-931882 INFO Installing repositories 10:54:48-092488 INFO Installing submodules 10:54:51-619369 INFO Updating submodules 10:55:07-803450 INFO Extensions enabled: ['clip-interrogator-ext', 'LDSR', 'Lora', 'multidiffusion-upscaler-for-automatic1111', 'prompt-bracket-checker', 'ScuNET', 'sd-extension-aesthetic-scorer', 'sd-webui-controlnet', 'sd-webui-model-converter', 'seed_travel', 'stable-diffusion-webui-images-browser', 'SwinIR'] 10:55:26-862820 INFO Extensions enabled: ['a1111-sd-webui-tagcomplete', 'Auto-Photoshop-StableDiffusion-Plugin', 'batch-face-swap', 'multidiffusion-upscaler-for-automatic1111', 'OneButtonPrompt', 'openpose-editor', 'sd-dynamic-prompts', 'sd-model-preview-xd', 'sd-webui-additional-networks', 'sd-webui-ar', 'sd_web_ui_preset_utils', 'stable-diffusion-webui-model-toolkit', 'stable-diffusion-webui-promptgen'] 10:55:45-250170 INFO Setting environment tuning 10:55:45-252195 INFO Server arguments: [] Available models: I:\Super SD 2.0\automatic\models\Stable-diffusion 169 ControlNet preprocessor location: I:\Super SD 2.0\automatic\extensions-builtin\sd-webui-controlnet\annotator\downloads ControlNet preprocessor location: I:\Super SD 2.0\automatic\extensions-builtin\sd-webui-controlnet\annotator\downloads python_server_full_path: I:\Super SD 2.0\automatic\extensions\Auto-Photoshop-StableDiffusion-Plugin\server/python_server [AddNet] Updating model hashes... 100%|███████████████████████████████████████████████████████████████████████████████| 86/86 [00:00<00:00, 43105.90it/s] Module load: I:\Super SD 2.0\automatic\extensions\sd-webui-additional-networks\scripts\additional_networks.py: AttributeError ┌───────────────────────────────────────── Traceback (most recent call last) ─────────────────────────────────────────┐ │ I:\Super SD 2.0\automatic\modules\script_loading.py:10 in load_module │ │ │ │ 9 │ try: │ │ > 10 │ │ module_spec.loader.exec_module(module) │ │ 11 │ except Exception as e: │ │ in exec_module:883 │ │ in _call_with_frames_removed:241 │ │ │ │ I:\Super SD 2.0\automatic\extensions\sd-webui-additional-networks\scripts\additional_networks.py:392 in │ │ │ │ 391 │ │ > 392 xyz_grid_support.initialize(Script) │ │ 393 │ └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ AttributeError: module 'scripts.xyz_grid_support' has no attribute 'initialize' [AddNet] Updating model hashes... 100%|███████████████████████████████████████████████████████████████████████████████| 86/86 [00:00<00:00, 86232.40it/s] Loading theme: black-orange [AddNet] Updating model hashes... 100%|█████████████████████████████████████████████████████████████████████████████| 172/172 [00:00<00:00, 28742.99it/s] [AddNet] Updating model hashes... 100%|█████████████████████████████████████████████████████████████████████████████| 172/172 [00:00<00:00, 85965.24it/s] Running on local URL: http://127.0.0.1:7860

CKwasd commented 1 year ago

After an update, this error still comes up:

remote: Enumerating objects: 44, done. remote: Counting objects: 100% (37/37), done. remote: Compressing objects: 100% (14/14), done. remote: Total 44 (delta 23), reused 33 (delta 23), pack-reused 7 Unpacking objects: 100% (44/44), 49.57 KiB | 474.00 KiB/s, done. From https://github.com/vladmandic/automatic 752b91d..2ddbb66 master -> origin/master Updating 752b91d..2ddbb66 Fast-forward TODO.md | 5 ++++- extensions-builtin/sd-webui-controlnet | 2 +- launch.py | 5 ++++- modules/devices.py | 12 ++++++++--- modules/paths_internal.py | 5 +++-- modules/processing.py | 2 +- modules/script_loading.py | 2 -- modules/sd_models.py | 5 ++++- modules/sd_vae.py | 31 +++++++++++++-------------- modules/shared.py | 5 +---- modules/xlmr.py | 11 +++++----- requirements.txt | 4 ++-- setup.py | 39 ++++++++++++++++++---------------- 13 files changed, 70 insertions(+), 58 deletions(-) venv "I:\Super SD 2.0\automatic\venv\Scripts\Python.exe" 10:54:37-074924 INFO Python 3.10.6 on Windows 10:54:37-663550 INFO Running setup 10:54:37-704419 INFO Version: 2ddbb66 Fri Apr 21 00:07:38 2023 -0400 10:54:38-400976 INFO Updating Wiki 10:54:41-538640 INFO Installing package: torch torchaudio torchvision --index-url https://download.pytorch.org/whl/cu118 10:54:47-888997 INFO Torch 2.0.0+cu118 10:54:47-906949 INFO Torch backend: nVidia CUDA 11.8 cuDNN 8700 10:54:47-909941 INFO Torch detected GPU: NVIDIA GeForce RTX 2070 SUPER VRAM 8192 Arch (7, 5) Cores 40 10:54:47-910939 INFO Installing requirements 10:54:47-928917 INFO Installing packages 10:54:47-931882 INFO Installing repositories 10:54:48-092488 INFO Installing submodules 10:54:51-619369 INFO Updating submodules 10:55:07-803450 INFO Extensions enabled: ['clip-interrogator-ext', 'LDSR', 'Lora', 'multidiffusion-upscaler-for-automatic1111', 'prompt-bracket-checker', 'ScuNET', 'sd-extension-aesthetic-scorer', 'sd-webui-controlnet', 'sd-webui-model-converter', 'seed_travel', 'stable-diffusion-webui-images-browser', 'SwinIR'] 10:55:26-862820 INFO Extensions enabled: ['a1111-sd-webui-tagcomplete', 'Auto-Photoshop-StableDiffusion-Plugin', 'batch-face-swap', 'multidiffusion-upscaler-for-automatic1111', 'OneButtonPrompt', 'openpose-editor', 'sd-dynamic-prompts', 'sd-model-preview-xd', 'sd-webui-additional-networks', 'sd-webui-ar', 'sd_web_ui_preset_utils', 'stable-diffusion-webui-model-toolkit', 'stable-diffusion-webui-promptgen'] 10:55:45-250170 INFO Setting environment tuning 10:55:45-252195 INFO Server arguments: [] Available models: I:\Super SD 2.0\automatic\models\Stable-diffusion 169 ControlNet preprocessor location: I:\Super SD 2.0\automatic\extensions-builtin\sd-webui-controlnet\annotator\downloads ControlNet preprocessor location: I:\Super SD 2.0\automatic\extensions-builtin\sd-webui-controlnet\annotator\downloads python_server_full_path: I:\Super SD 2.0\automatic\extensions\Auto-Photoshop-StableDiffusion-Plugin\server/python_server [AddNet] Updating model hashes... 100%|███████████████████████████████████████████████████████████████████████████████| 86/86 [00:00<00:00, 43105.90it/s] Module load: I:\Super SD 2.0\automatic\extensions\sd-webui-additional-networks\scripts\additional_networks.py: AttributeError ┌───────────────────────────────────────── Traceback (most recent call last) ─────────────────────────────────────────┐ │ I:\Super SD 2.0\automatic\modules\script_loading.py:10 in load_module │ │ │ │ 9 │ try: │ │ > 10 │ │ module_spec.loader.exec_module(module) │ │ 11 │ except Exception as e: │ │ in exec_module:883 │ │ in _call_with_frames_removed:241 │ │ │ │ I:\Super SD 2.0\automatic\extensions\sd-webui-additional-networks\scripts\additional_networks.py:392 in │ │ │ │ 391 │ │ > 392 xyz_grid_support.initialize(Script) │ │ 393 │ └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ AttributeError: module 'scripts.xyz_grid_support' has no attribute 'initialize' [AddNet] Updating model hashes... 100%|███████████████████████████████████████████████████████████████████████████████| 86/86 [00:00<00:00, 86232.40it/s] Loading theme: black-orange [AddNet] Updating model hashes... 100%|█████████████████████████████████████████████████████████████████████████████| 172/172 [00:00<00:00, 28742.99it/s] [AddNet] Updating model hashes... 100%|█████████████████████████████████████████████████████████████████████████████| 172/172 [00:00<00:00, 85965.24it/s] Running on local URL: http://127.0.0.1:7860

Still, couldnt find a way to fix

vladmandic commented 1 year ago

i have an open ask to both controlnet and additional network extension authors to rename their module to something unique as i cannot find a way to fix it from core repo.

Woisek commented 1 year ago

I tried to put it into the internal extension folder and that seems had fixed it ... 🤪

vladmandic commented 1 year ago

I tried to put it into the internal extension folder and that seems had fixed it ... 🤪

like i said, thats not a fix.

Woisek commented 1 year ago

Yes, I know, but at least no errors came up and it's also displayed in the GUI and useable. 🙂 Till you know what's the problem is with it, I'm good with that.

vladmandic commented 1 year ago

authors of extensions with issues have been kind enough to modify their code, issue is resolved with latest update.

CKwasd commented 1 year ago

ty for your work