AUTOMATIC1111 / stable-diffusion-webui

Stable Diffusion web UI
GNU Affero General Public License v3.0
142.32k stars 26.85k forks source link

[Bug]: TypeError when creating embedding with SDXL selected. #14359

Open AlexanderProd opened 10 months ago

AlexanderProd commented 10 months ago

Checklist

What happened?

bash webui.sh --server-name=t1 --disable-safe-unpickle

When I create an embedding in the train tab and I have SDXL (sd_xl_base_1.0_0.9vae) selected. I'm getting the following error:

Traceback (most recent call last):
  File "/home/alexander/Developer/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/routes.py", line 488, in run_predict
    output = await app.get_blocks().process_api(
  File "/home/alexander/Developer/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/blocks.py", line 1431, in process_api
    result = await self.call_function(
  File "/home/alexander/Developer/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/blocks.py", line 1103, in call_function
    prediction = await anyio.to_thread.run_sync(
  File "/home/alexander/Developer/stable-diffusion-webui/venv/lib/python3.10/site-packages/anyio/to_thread.py", line 33, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "/home/alexander/Developer/stable-diffusion-webui/venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 877, in run_sync_in_worker_thread
    return await future
  File "/home/alexander/Developer/stable-diffusion-webui/venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 807, in run
    result = context.run(func, *args)
  File "/home/alexander/Developer/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/utils.py", line 707, in wrapper
    response = f(*args, **kwargs)
  File "/home/alexander/Developer/stable-diffusion-webui/stable-diffusion-webui/modules/textual_inversion/ui.py", line 10, in create_embedding
    filename = modules.textual_inversion.textual_inversion.create_embedding(name, nvpt, overwrite_old, init_text=initialization_text)
  File "/home/alexander/Developer/stable-diffusion-webui/stable-diffusion-webui/modules/textual_inversion/textual_inversion.py", line 259, in create_embedding
    cond_model([""])  # will send cond model to GPU if lowvram/medvram is active
  File "/home/alexander/Developer/stable-diffusion-webui/venv/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "/home/alexander/Developer/stable-diffusion-webui/venv/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1527, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/alexander/Developer/stable-diffusion-webui/stable-diffusion-webui/repositories/generative-models/sgm/modules/encoders/modules.py", line 141, in forward
    emb_out = embedder(batch[embedder.input_key])
TypeError: list indices must be integers or slices, not str

I have started the web ui like this:

bash webui.sh --server-name=t1 --disable-safe-unpickle

SDXL is downloaded from here

Steps to reproduce the problem

  1. Downlod sd_xl_base_1.0_0.9vae
  2. Put SDXL in the models/Stable-diffusion directory
  3. Select it as Stable Diffusion checkpoint
  4. Create a new embedding in the train tab.

What should have happened?

Embedding should have been created.

What browsers do you use to access the UI ?

Google Chrome

Sysinfo

sysinfo-2023-12-18-15-54.json

Console logs

################################################################
Install script for stable-diffusion + Web UI
Tested on Debian 11 (Bullseye)
################################################################

################################################################
Running on alexander user
################################################################

################################################################
python venv already activate or run without venv: /home/alexander/Developer/stable-diffusion-webui/venv
################################################################

################################################################
Launching launch.py...
################################################################
Cannot locate TCMalloc (improves CPU memory usage)
Python 3.10.7 (main, May 29 2023, 13:51:48) [GCC 12.2.0]
Version: v1.7.0-133-gde03882d
Commit hash: de03882d6ca56bc81058f5120f028678a6a54aaa
Launching Web UI with arguments: --server-name=t1 --disable-safe-unpickle
no module 'xformers'. Processing without...
no module 'xformers'. Processing without...
*** Error running preload() for /home/alexander/Developer/stable-diffusion-webui/stable-diffusion-webui/extensions/stable-diffusion-webui-wd14-tagger/preload.py
    Traceback (most recent call last):
      File "/home/alexander/Developer/stable-diffusion-webui/stable-diffusion-webui/modules/script_loading.py", line 26, in preload_extensions
        module = load_module(preload_script)
      File "/home/alexander/Developer/stable-diffusion-webui/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 "/home/alexander/Developer/stable-diffusion-webui/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) (/home/alexander/Developer/stable-diffusion-webui/stable-diffusion-webui/modules/shared.py)

---
No module 'xformers'. Proceeding without it.
Style database not found: /home/alexander/Developer/stable-diffusion-webui/stable-diffusion-webui/styles.csv
*** Error loading script: tagger.py
    Traceback (most recent call last):
      File "/home/alexander/Developer/stable-diffusion-webui/stable-diffusion-webui/modules/scripts.py", line 515, in load_scripts
        script_module = script_loading.load_module(scriptfile.path)
      File "/home/alexander/Developer/stable-diffusion-webui/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 "/home/alexander/Developer/stable-diffusion-webui/stable-diffusion-webui/extensions/stable-diffusion-webui-wd14-tagger/scripts/tagger.py", line 5, in <module>
        from tagger.ui import on_ui_tabs
      File "/home/alexander/Developer/stable-diffusion-webui/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' (/home/alexander/Developer/stable-diffusion-webui/stable-diffusion-webui/webui.py)

---
Loading weights [e6bb9ea85b] from /home/alexander/Developer/stable-diffusion-webui/stable-diffusion-webui/models/Stable-diffusion/sd_xl_base_1.0_0.9vae.safetensors
Running on local URL:  http://t1:7860

To create a public link, set `share=True` in `launch()`.
Startup time: 3.5s (prepare environment: 0.7s, import torch: 1.1s, import gradio: 0.4s, setup paths: 0.4s, other imports: 0.2s, setup codeformer: 0.1s, load scripts: 0.2s, create ui: 0.2s, gradio launch: 0.1s).
Creating model from config: /home/alexander/Developer/stable-diffusion-webui/stable-diffusion-webui/repositories/generative-models/configs/inference/sd_xl_base.yaml
Applying attention optimization: Doggettx... done.
Model loaded in 2.3s (load weights from disk: 0.8s, create model: 0.4s, apply weights to model: 0.8s, load textual inversion embeddings: 0.1s).
Traceback (most recent call last):
  File "/home/alexander/Developer/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/routes.py", line 488, in run_predict
    output = await app.get_blocks().process_api(
  File "/home/alexander/Developer/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/blocks.py", line 1431, in process_api
    result = await self.call_function(
  File "/home/alexander/Developer/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/blocks.py", line 1103, in call_function
    prediction = await anyio.to_thread.run_sync(
  File "/home/alexander/Developer/stable-diffusion-webui/venv/lib/python3.10/site-packages/anyio/to_thread.py", line 33, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "/home/alexander/Developer/stable-diffusion-webui/venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 877, in run_sync_in_worker_thread
    return await future
  File "/home/alexander/Developer/stable-diffusion-webui/venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 807, in run
    result = context.run(func, *args)
  File "/home/alexander/Developer/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/utils.py", line 707, in wrapper
    response = f(*args, **kwargs)
  File "/home/alexander/Developer/stable-diffusion-webui/stable-diffusion-webui/modules/textual_inversion/ui.py", line 10, in create_embedding
    filename = modules.textual_inversion.textual_inversion.create_embedding(name, nvpt, overwrite_old, init_text=initialization_text)
  File "/home/alexander/Developer/stable-diffusion-webui/stable-diffusion-webui/modules/textual_inversion/textual_inversion.py", line 259, in create_embedding
    cond_model([""])  # will send cond model to GPU if lowvram/medvram is active
  File "/home/alexander/Developer/stable-diffusion-webui/venv/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "/home/alexander/Developer/stable-diffusion-webui/venv/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1527, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/alexander/Developer/stable-diffusion-webui/stable-diffusion-webui/repositories/generative-models/sgm/modules/encoders/modules.py", line 141, in forward
    emb_out = embedder(batch[embedder.input_key])
TypeError: list indices must be integers or slices, not str

Additional information

I've also tried it on the dev branch but the same error ocurred.

chromesun commented 10 months ago

It looks like a1111 webui can't/won't train SDXL: https://github.com/AUTOMATIC1111/stable-diffusion-webui/discussions/11857#discussioncomment-6480804 If that's changed, I don't see any more recent info.