anapnoe / stable-diffusion-webui-ux

Stable Diffusion web UI UX
GNU Affero General Public License v3.0
989 stars 58 forks source link

[Bug]: Console error once extra models are installed after a clean install. #163

Closed LoveNug closed 1 year ago

LoveNug commented 1 year ago

Is there an existing issue for this?

What happened?

With the latest update, I keep getting this error in the console after I add LoRA, checkpoint or embedding models to their respective directories:

Traceback (most recent call last):
  File "C:\SDWebUI\stable-diffusion-webui-ux\venv\lib\site-packages\gradio\routes.py", line 414, in run_predict
    output = await app.get_blocks().process_api(
  File "C:\SDWebUI\stable-diffusion-webui-ux\venv\lib\site-packages\gradio\blocks.py", line 1323, in process_api
    result = await self.call_function(
  File "C:\SDWebUI\stable-diffusion-webui-ux\venv\lib\site-packages\gradio\blocks.py", line 1051, in call_function
    prediction = await anyio.to_thread.run_sync(
  File "C:\SDWebUI\stable-diffusion-webui-ux\venv\lib\site-packages\anyio\to_thread.py", line 33, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "C:\SDWebUI\stable-diffusion-webui-ux\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 877, in run_sync_in_worker_thread
    return await future
  File "C:\SDWebUI\stable-diffusion-webui-ux\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 807, in run
    result = context.run(func, *args)
  File "C:\SDWebUI\stable-diffusion-webui-ux\modules\ui_extra_networks.py", line 349, in refresh
    ui.pages_contents = [pg.create_html(ui.tabname) for pg in ui.stored_extra_pages]
  File "C:\SDWebUI\stable-diffusion-webui-ux\modules\ui_extra_networks.py", line 349, in <listcomp>
    ui.pages_contents = [pg.create_html(ui.tabname) for pg in ui.stored_extra_pages]
  File "C:\SDWebUI\stable-diffusion-webui-ux\modules\ui_extra_networks.py", line 125, in create_html
    for item in self.list_items():
  File "C:\SDWebUI\stable-diffusion-webui-ux\modules\ui_extra_networks_textual_inversion.py", line 16, in list_items
    for embedding in sd_hijack.model_hijack.embedding_db.word_embeddings.values():
RuntimeError: dictionary changed size during iteration

When I perform a fresh install with no additional extensions, and without adding models beyond the auto-downloaded default SD 1.5 model, no error. It only happens after I start adding my extra models to their folders. Each model is accompanied by a .preview.png (or .jpg) file, all of which worked fine in previous versions of the WebUI-UX. Did something change?

Steps to reproduce the problem

  1. Clean install WebUI-UX
  2. No other extensions yet installed.
  3. Add checkpoint, LoRA or embedding models to their respective directories
  4. Refresh/restart WebUI-UX.
  5. Get error in console
  6. Items in the extra network window are dimmed. Can still be selected though. Just an annoying and unnecessary glitch.

What should have happened?

Models should have loaded without error and not be dimmed in the extra networks side tab.

Commit where the problem happens

9931e861dfb128735c4a928a7beb5b5c0af30593

What Python version are you running on ?

Python 3.10.x

What platforms do you use to access the UI ?

Windows

What device are you running WebUI on?

Nvidia GPUs (RTX 20 above)

What browsers do you use to access the UI ?

Mozilla Firefox, Google Chrome

Command Line Arguments

--opt-split-attention --xformers --ckpt-dir 'D:\stable-diffusion-webui\models\Stable-diffusion' --api --autolaunch

List of extensions

None

Console logs

venv "C:\SDWebUI\stable-diffusion-webui-ux\venv\Scripts\Python.exe"
fatal: No names found, cannot describe anything.
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug  1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]
Version: <none>
Commit hash: 9931e861dfb128735c4a928a7beb5b5c0af30593
Installing requirements
Launching Web UI with arguments: --opt-split-attention --xformers --ckpt-dir D:\stable-diffusion-webui\models\Stable-diffusion --api --autolaunch
Loading weights [6ce0161689] from C:\SDWebUI\stable-diffusion-webui-ux\models\Stable-diffusion\v1-5-pruned-emaonly.safetensors
Creating model from config: C:\SDWebUI\stable-diffusion-webui-ux\configs\v1-inference.yaml
LatentDiffusion: Running in eps-prediction mode
DiffusionWrapper has 859.52 M params.
Applying optimization: xformers... done.
Textual inversion embeddings loaded(22): 512 Paintstyle 3 Llight, angry512, Coloring Book Style, Deep Negative V1_75t, defiance512, easynegative, Greenmageddon, Greenmageddon White, happy512, kidbooks, laugh512, nervous512, photozoov15, Plan It, qualityzoov15, renderzoov15, Robo Faces V2, sad512, shock512, Starhaven Machine Gods, structurezoov15, Vintage Map F
Textual inversion embeddings skipped(17): Chadeisson, Hamunaptra Style SD2, Ink Sketch Colour 1 Subtle, Ink Sketch Colour 1, InkPunk 768, LaxPeint V2, Paintstyle 8, PaintStyle3, Parch Art, RetroFutur, This Honor, UlukInk Sketch 2, photozoov21, qualityzoov21, renderzoov21, structurezoov21, Vintage Helper
Model loaded in 11.2s (load weights from disk: 0.5s, create model: 1.8s, apply weights to model: 2.2s, apply half(): 3.6s, move model to device: 1.2s, load textual inversion embeddings: 1.9s).
Running on local URL:  http://127.0.0.1:7860

To create a public link, set `share=True` in `launch()`.
Startup time: 21.9s (import torch: 2.5s, import gradio: 2.0s, import ldm: 0.9s, other imports: 1.2s, setup codeformer: 0.1s, list SD models: 0.3s, load scripts: 2.2s, create ui: 12.1s, gradio launch: 0.5s, scripts app_started_callback: 0.2s).
Traceback (most recent call last):
  File "C:\SDWebUI\stable-diffusion-webui-ux\venv\lib\site-packages\gradio\routes.py", line 414, in run_predict
    output = await app.get_blocks().process_api(
  File "C:\SDWebUI\stable-diffusion-webui-ux\venv\lib\site-packages\gradio\blocks.py", line 1323, in process_api
    result = await self.call_function(
  File "C:\SDWebUI\stable-diffusion-webui-ux\venv\lib\site-packages\gradio\blocks.py", line 1051, in call_function
    prediction = await anyio.to_thread.run_sync(
  File "C:\SDWebUI\stable-diffusion-webui-ux\venv\lib\site-packages\anyio\to_thread.py", line 33, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "C:\SDWebUI\stable-diffusion-webui-ux\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 877, in run_sync_in_worker_thread
    return await future
  File "C:\SDWebUI\stable-diffusion-webui-ux\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 807, in run
    result = context.run(func, *args)
  File "C:\SDWebUI\stable-diffusion-webui-ux\modules\ui_extra_networks.py", line 349, in refresh
    ui.pages_contents = [pg.create_html(ui.tabname) for pg in ui.stored_extra_pages]
  File "C:\SDWebUI\stable-diffusion-webui-ux\modules\ui_extra_networks.py", line 349, in <listcomp>
    ui.pages_contents = [pg.create_html(ui.tabname) for pg in ui.stored_extra_pages]
  File "C:\SDWebUI\stable-diffusion-webui-ux\modules\ui_extra_networks.py", line 125, in create_html
    for item in self.list_items():
  File "C:\SDWebUI\stable-diffusion-webui-ux\modules\ui_extra_networks_textual_inversion.py", line 16, in list_items
    for embedding in sd_hijack.model_hijack.embedding_db.word_embeddings.values():
RuntimeError: dictionary changed size during iteration

Additional information

No response

anapnoe commented 1 year ago

have you any thoughts why these embeddings are skipped? Textual inversion embeddings skipped(17): Chadeisson, Hamunaptra Style SD2, Ink Sketch Colour 1 Subtle, Ink Sketch Colour 1, InkPunk 768, LaxPeint V2, Paintstyle 8, PaintStyle3, Parch Art, RetroFutur, This Honor, UlukInk Sketch 2, photozoov21, qualityzoov21, renderzoov21, structurezoov21, Vintage Helper maybe try to remove to another folder and see if something has change

if anyone else have an issue I will look further into it

LoveNug commented 1 year ago

Well, embeddings are skipped if the checkpoint version is different than the embedding version. For example, the embeddings skipped in my console log are for SD 2.0/2.1 checkpoints because I have a SD 1.5 checkpoint loaded. If I switch to a 2.x checkpoint, the embeddings for SD 1.5 models are skipped. This has been standard for me and is not an issue.

anapnoe commented 1 year ago

File "C:\SDWebUI\stable-diffusion-webui-ux\modules\ui_extra_networks_textual_inversion.py", line 16, in list_items for embedding in sd_hijack.model_hijack.embedding_db.word_embeddings.values():

can you remove all the embeddings and check if issue is present?

LoveNug commented 1 year ago

Ok. I'm at work now, but I'm tunneled into my home PC. I will try a few things and report back with details when I can.

LoveNug commented 1 year ago

After some testing, I have found that the following actions (separately) produce the error:

  1. Placing LoRA or checkpoint files in any subdirectories within the main directories.
  2. Placing ANY textual embeddings within the embeddings directory.
  3. Adding a launch argument pointing to a checkpoint directory other than the one within the WebUI-UX environment. For example, if I add --ckpt-dir 'D:\stable-diffusion-webui\models\Stable-diffusion' to set COMMANDLINE_ARGS= in webui-user.bat, the error occurs. When I remove it and restart the WebUI, there is no error.

As I mentioned, I tried all of these separately and got the same error. I'm at a loss. This is very confusing. Ultimately, the error does not prevent me from using the extra networks tab, but it's annoying that the images are greyed out.

anapnoe commented 1 year ago

thanks for your detail debugging I will look into it

anapnoe commented 1 year ago

check out the latest version it should be all right now

LoveNug commented 1 year ago

Thank you! Looking forward to the update.