lshqqytiger / stable-diffusion-webui-amdgpu

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

[Bug]: KeyError: everchanging value #153

Open robonxt opened 1 year ago

robonxt commented 1 year ago

Is there an existing issue for this?

What happened?

EDIT: it seems like I've found two bugs instead of just one.

The first one is the known issue with the optimizer, where in line 431 of modules/shared.py needs to change from "s_min_uncond": OptionInfo(0, ... to: "s_min_uncond": OptionInfo(0.0, ...

The second bug I haven't found it yet, so I might post in automatic1111's repo, as that should be affected as well. Basically the bug that this report is about is when I hide the img2img tab using the available hide options in settings, I get these KeyErrors. The only fix I found so far is to keep the img2img tab enabled.

At first I'm getting this error when I change options in the UI, it points to a float value of 0.3 when it is expecting a int() value. I've pinpointed to the Token merge feature, where I set it to 0.3 from the default of 0.

Here is the error I'm getting on the console:

....
Traceback (most recent call last):
  File "D:\AI\systems\stable-diffusion-webui-directml\venv\lib\site-packages\gradio\routes.py", line 414, in run_predict
    output = await app.get_blocks().process_api(
  File "D:\AI\systems\stable-diffusion-webui-directml\venv\lib\site-packages\gradio\blocks.py", line 1323, in process_api
    result = await self.call_function(
  File "D:\AI\systems\stable-diffusion-webui-directml\venv\lib\site-packages\gradio\blocks.py", line 1051, in call_function
    prediction = await anyio.to_thread.run_sync(
  File "D:\AI\systems\stable-diffusion-webui-directml\venv\lib\site-packages\anyio\to_thread.py", line 33, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "D:\AI\systems\stable-diffusion-webui-directml\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 877, in run_sync_in_worker_thread
    return await future
  File "D:\AI\systems\stable-diffusion-webui-directml\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 807, in run
    result = context.run(func, *args)
  File "D:\AI\systems\stable-diffusion-webui-directml\modules\generation_parameters_copypaste.py", line 379, in paste_func
    v = key(params)
  File "D:\AI\systems\stable-diffusion-webui-directml\modules\generation_parameters_copypaste.py", line 414, in paste_settings
    v = shared.opts.cast_value(setting_name, v)
  File "D:\AI\systems\stable-diffusion-webui-directml\modules\shared.py", line 697, in cast_value
    value = expected_type(value)
ValueError: invalid literal for int() with base 10: '0.3'
...

EDIT: the fix is the link below for this perticular problem I saw https://github.com/AUTOMATIC1111/stable-diffusion-webui/commit/c3a61425b8a0d9b836558ab381d9760ef0bca797 and tried updating modules/shared.py, the ValueError: invalid literal for int() with base 10: '0.3' error no longer happens, so I thought it was ok.

However, I now keep getting this and similar errors:

Traceback (most recent call last):
  File "D:\AI\systems\stable-diffusion-webui-directml\venv\lib\site-packages\gradio\routes.py", line 414, in run_predict
    output = await app.get_blocks().process_api(
  File "D:\AI\systems\stable-diffusion-webui-directml\venv\lib\site-packages\gradio\blocks.py", line 1326, in process_api
    data = self.postprocess_data(fn_index, result["prediction"], state)
  File "D:\AI\systems\stable-diffusion-webui-directml\venv\lib\site-packages\gradio\blocks.py", line 1242, in postprocess_data
    block = self.blocks[output_id]
KeyError: 11523

I get KeyErrors of 10386, 11523, and lots of 9249. I am also unable to control the UI when these errors show up, I have to reload or refresh the UI to make any of the buttons work again.

Steps to reproduce the problem

Not quite sure if I can replicate it again, but:

  1. Go to settings tab
  2. Change Token Merge to 0.3
  3. Save settings and reload
  4. Go to settings tab
  5. Click around the settings, save them, and press Show all pages. It won't load all the settings anymore.
  6. Check console.

What should have happened?

UI working normally, no errors being thrown.

Commit where the problem happens

8fd5b18bbebfed024b7051bc7704c760b8eb53cae783431c7c3e96531805ee0d

What Python version are you running on ?

Python 3.10.x

What platforms do you use to access the UI ?

Windows, Android

What device are you running WebUI on?

AMD GPUs (RX 6000 above)

What browsers do you use to access the UI ?

Google Chrome

Command Line Arguments

set SAFETENSORS_FAST_GPU=1
set GIT_SSL_NO_VERIFY=true
set COMMANDLINE_ARGS=--backend directml --always-batch-cond-uncond --max-batch-count 4 --disable-nan-check --enable-insecure-extension-access --no-half --precision full --upcast-sampling  --sub-quad-q-chunk-size 512 --sub-quad-kv-chunk-size 512 --sub-quad-chunk-threshold 80 --listen --medvram --no-download-sd-model --update-all-extensions --opt-split-attention --update-check --use-cpu CLIP BLIP interrogate gfpgan bsrgan esrgan scunet codeformer

List of extensions

I have all extensions disabled when trying to debug this, but here are the installed extensions:

Stable-Diffusion-Webui-Civitai-Helper | https://github.com/butaixianran/Stable-Diffusion-Webui-Civitai-Helper.git | main | 920ca326 | Tue May 23 11:53:22 2023 | unknown a1111-sd-webui-tagcomplete | https://github.com/DominikDoom/a1111-sd-webui-tagcomplete.git | main | 1cb4fc8f | Fri May 26 21:45:19 2023 | unknown model_preset_manager | https://github.com/rifeWithKaiju/model_preset_manager.git | main | 4e25eebd | Tue May 30 15:07:37 2023 | unknown sd-webui-ar | https://github.com/alemelis/sd-webui-ar.git | main | 9df49dc2 | Wed Apr 12 09:23:17 2023 | unknown stable-diffusion-webui-images-browser | https://github.com/AlUlkesh/stable-diffusion-webui-images-browser.git | main | b051835f | Sun Jun 4 23:33:13 2023 | unknown ultimate-upscale-for-automatic1111 | https://github.com/Coyote-A/ultimate-upscale-for-automatic1111.git | master | 756bb505 | Fri May 5 00:22:21 2023 | unknown

Console logs

PS D:\AI\systems\stable-diffusion-webui-directml> .\webui-user.bat
venv "D:\AI\systems\stable-diffusion-webui-directml\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: ebf229bd1727a0f8f0d149829ce82e2012ba7318
Installing requirements

You are up to date with the most recent release.
Pulled changes for repository in 'D:\AI\systems\stable-diffusion-webui-directml\extensions\a1111-sd-webui-tagcomplete':
Already up to date.

Pulled changes for repository in 'D:\AI\systems\stable-diffusion-webui-directml\extensions\model_preset_manager':
Already up to date.

Pulled changes for repository in 'D:\AI\systems\stable-diffusion-webui-directml\extensions\sd-webui-ar':
Already up to date.

Pulled changes for repository in 'D:\AI\systems\stable-diffusion-webui-directml\extensions\Stable-Diffusion-Webui-Civitai-Helper':
Already up to date.

Pulled changes for repository in 'D:\AI\systems\stable-diffusion-webui-directml\extensions\stable-diffusion-webui-images-browser':
Already up to date.

Pulled changes for repository in 'D:\AI\systems\stable-diffusion-webui-directml\extensions\ultimate-upscale-for-automatic1111':
Already up to date.

Launching Web UI with arguments: --backend directml --always-batch-cond-uncond --max-batch-count 4 --disable-nan-check --enable-insecure-extension-access --no-half --precision full --upcast-sampling --sub-quad-q-chunk-size 512 --sub-quad-kv-chunk-size 512 --sub-quad-chunk-threshold 80 --listen --medvram --no-download-sd-model --update-all-extensions --opt-split-attention --update-check --use-cpu CLIP BLIP interrogate gfpgan bsrgan esrgan scunet codeformer
No module 'xformers'. Proceeding without it.
Warning: caught exception 'Torch not compiled with CUDA enabled', memory monitor disabled
Civitai Helper: Get Custom Model Folder
Civitai Helper: Load setting from: D:\AI\systems\stable-diffusion-webui-directml\extensions\Stable-Diffusion-Webui-Civitai-Helper\setting.json
Civitai Helper: No setting file, use default
Loading weights [b644d850c9] from D:\AI\systems\stable-diffusion-webui-directml\models\Stable-diffusion\abyssorangemix2SFW.safetensors
Creating model from config: D:\AI\systems\stable-diffusion-webui-directml\configs\v1-inference.yaml
LatentDiffusion: Running in eps-prediction mode
DiffusionWrapper has 859.52 M params.
Applying optimization: Doggettx... done.
Textual inversion embeddings loaded(9): 7dirtywords, bad-hands-5, bad-image-v2-39000, badhandv4, easynegative, negative_hand-neg, ng_deepnegative_v1_75t, verybadimagenegative_v1.3, was-gunpla
Model loaded in 1.6s (load weights from disk: 0.4s, create model: 0.6s, apply weights to model: 0.4s).
Running on local URL:  http://0.0.0.0:7860
Startup time: 10.0s (import torch: 1.1s, import gradio: 0.9s, import ldm: 0.4s, other imports: 0.8s, opts onchange: 0.5s, load scripts: 1.0s, create ui: 1.0s, gradio launch: 4.1s).
Traceback (most recent call last):
  File "D:\AI\systems\stable-diffusion-webui-directml\venv\lib\site-packages\gradio\routes.py", line 414, in run_predict
    output = await app.get_blocks().process_api(
  File "D:\AI\systems\stable-diffusion-webui-directml\venv\lib\site-packages\gradio\blocks.py", line 1326, in process_api
    data = self.postprocess_data(fn_index, result["prediction"], state)
  File "D:\AI\systems\stable-diffusion-webui-directml\venv\lib\site-packages\gradio\blocks.py", line 1242, in postprocess_data
    block = self.blocks[output_id]
KeyError: 396
Restarting UI...
Closing server running on port: 7860
Civitai Helper: Get Custom Model Folder
Civitai Helper: Load setting from: D:\AI\systems\stable-diffusion-webui-directml\extensions\Stable-Diffusion-Webui-Civitai-Helper\setting.json
Civitai Helper: No setting file, use default
Running on local URL:  http://0.0.0.0:7860
Startup time: 5.0s (load scripts: 0.2s, create ui: 0.6s, gradio launch: 4.1s).
Traceback (most recent call last):
  File "D:\AI\systems\stable-diffusion-webui-directml\venv\lib\site-packages\gradio\routes.py", line 414, in run_predict
    output = await app.get_blocks().process_api(
  File "D:\AI\systems\stable-diffusion-webui-directml\venv\lib\site-packages\gradio\blocks.py", line 1326, in process_api
    data = self.postprocess_data(fn_index, result["prediction"], state)
  File "D:\AI\systems\stable-diffusion-webui-directml\venv\lib\site-packages\gradio\blocks.py", line 1242, in postprocess_data
    block = self.blocks[output_id]
KeyError: 3364
Restarting UI...
Closing server running on port: 7860
Civitai Helper: Get Custom Model Folder
Civitai Helper: Load setting from: D:\AI\systems\stable-diffusion-webui-directml\extensions\Stable-Diffusion-Webui-Civitai-Helper\setting.json
Civitai Helper: No setting file, use default
Running on local URL:  http://0.0.0.0:7860
Startup time: 5.1s (load scripts: 0.2s, create ui: 0.7s, gradio launch: 4.1s).
Restarting UI...
Closing server running on port: 7860
*** "Disable all extensions" option was set, will not load any extensions ***
Running on local URL:  http://0.0.0.0:7860
Startup time: 4.6s (create ui: 0.4s, gradio launch: 4.1s).
Traceback (most recent call last):
  File "D:\AI\systems\stable-diffusion-webui-directml\venv\lib\site-packages\gradio\routes.py", line 414, in run_predict
    output = await app.get_blocks().process_api(
  File "D:\AI\systems\stable-diffusion-webui-directml\venv\lib\site-packages\gradio\blocks.py", line 1326, in process_api
    data = self.postprocess_data(fn_index, result["prediction"], state)
  File "D:\AI\systems\stable-diffusion-webui-directml\venv\lib\site-packages\gradio\blocks.py", line 1242, in postprocess_data
    block = self.blocks[output_id]
KeyError: 9249
Traceback (most recent call last):
  File "D:\AI\systems\stable-diffusion-webui-directml\venv\lib\site-packages\gradio\routes.py", line 414, in run_predict
    output = await app.get_blocks().process_api(
  File "D:\AI\systems\stable-diffusion-webui-directml\venv\lib\site-packages\gradio\blocks.py", line 1326, in process_api
    data = self.postprocess_data(fn_index, result["prediction"], state)
  File "D:\AI\systems\stable-diffusion-webui-directml\venv\lib\site-packages\gradio\blocks.py", line 1242, in postprocess_data
    block = self.blocks[output_id]
KeyError: 9249
Restarting UI...
Closing server running on port: 7860
*** "Disable all extensions" option was set, will not load any extensions ***
Running on local URL:  http://0.0.0.0:7860
Startup time: 4.3s (create ui: 0.2s, gradio launch: 4.1s).
Traceback (most recent call last):
  File "D:\AI\systems\stable-diffusion-webui-directml\venv\lib\site-packages\gradio\routes.py", line 414, in run_predict
    output = await app.get_blocks().process_api(
  File "D:\AI\systems\stable-diffusion-webui-directml\venv\lib\site-packages\gradio\blocks.py", line 1326, in process_api
    data = self.postprocess_data(fn_index, result["prediction"], state)
  File "D:\AI\systems\stable-diffusion-webui-directml\venv\lib\site-packages\gradio\blocks.py", line 1242, in postprocess_data
    block = self.blocks[output_id]
KeyError: 10386
Restarting UI...
Closing server running on port: 7860
*** "Disable all extensions" option was set, will not load any extensions ***
Running on local URL:  http://0.0.0.0:7860
Startup time: 4.6s (create ui: 0.5s, gradio launch: 4.1s).
Calculating sha256 for D:\AI\systems\stable-diffusion-webui-directml\models\Stable-diffusion\bloodorangemixSFWSoft.safetensors: 8fd5b18bbebfed024b7051bc7704c760b8eb53cae783431c7c3e96531805ee0d
Loading weights [8fd5b18bbe] from D:\AI\systems\stable-diffusion-webui-directml\models\Stable-diffusion\bloodorangemixSFWSoft.safetensors
Applying optimization: Doggettx... done.
Weights loaded in 5.2s (calculate hash: 4.7s, load weights from disk: 0.2s, apply weights to model: 0.4s).
Traceback (most recent call last):
  File "D:\AI\systems\stable-diffusion-webui-directml\venv\lib\site-packages\gradio\routes.py", line 414, in run_predict
    output = await app.get_blocks().process_api(
  File "D:\AI\systems\stable-diffusion-webui-directml\venv\lib\site-packages\gradio\blocks.py", line 1326, in process_api
    data = self.postprocess_data(fn_index, result["prediction"], state)
  File "D:\AI\systems\stable-diffusion-webui-directml\venv\lib\site-packages\gradio\blocks.py", line 1242, in postprocess_data
    block = self.blocks[output_id]
KeyError: 11523

Additional information

I was wondering if this had to do with the all-in-one prompt extension, I've uninstalled it yesterday because it bugged out the UI and made it basically unusable.

songib commented 1 year ago

I've got weird stuff today with (Emphasis:1.3) didn't react at all. idk how to fix this stuff, seems like the bug occurs when trying new stuff on "Optimization" settings or the sd_Dynamic_Prompts or anything else idk.

robonxt commented 1 year ago

Hmm... I've just fresh cloned SD again, and it seems like if I hide the "img2img" tab using the option in settings, I get the errors. I guess this is more of a gradio problem?