stable-diffusion-webui
stable-diffusion-webui copied to clipboard
[Bug]: API image generation returns errors in console with some alwayson_scripts
Is there an existing issue for this?
- [X] I have searched the existing issues and checked the recent builds/commits
What happened?
webUI's console suddenly started returning errors unexpectedly when using /sdapi/v1/txt2img or ../img2img calls such as the following (for my base install):
API 2023-03-15 16:56:02.038435 200 http/1.1 OPTIONS /sdapi/v1/txt2img 127.0.0.1 0.0
Error running process: E:\storage\stable-diffusion-webui\extensions\stable-diffusion-webui-aesthetic-gradients\scripts\aesthetic.py
Traceback (most recent call last):
File "E:\storage\stable-diffusion-webui\modules\scripts.py", line 409, in process
script.process(p, *script_args)
File "E:\storage\stable-diffusion-webui\extensions\stable-diffusion-webui-aesthetic-gradients\scripts\aesthetic.py", line 36, in process
aesthetic.set_aesthetic_params(p, float(aesthetic_lr), float(aesthetic_weight), int(aesthetic_steps), aesthetic_imgs, aesthetic_slerp, aesthetic_imgs_text, aesthetic_slerp_angle, aesthetic_text_negative)
TypeError: float() argument must be a string or a real number, not 'NoneType'
Error running process: E:\storage\stable-diffusion-webui\extensions\stable-diffusion-webui-conditioning-highres-fix\scripts\conditioning-highres-fix.py
Traceback (most recent call last):
File "E:\storage\stable-diffusion-webui\modules\scripts.py", line 409, in process
script.process(p, *script_args)
File "E:\storage\stable-diffusion-webui\extensions\stable-diffusion-webui-conditioning-highres-fix\scripts\conditioning-highres-fix.py", line 22, in process
if conditioning_highres_fix>0 and p.denoising_strength is not None:
TypeError: '>' not supported between instances of 'NoneType' and 'int'
Error running process: E:\storage\stable-diffusion-webui\extensions\stable-diffusion-webui-daam\scripts\daam_script.py
Traceback (most recent call last):
File "E:\storage\stable-diffusion-webui\modules\scripts.py", line 409, in process
script.process(p, *script_args)
File "E:\storage\stable-diffusion-webui\extensions\stable-diffusion-webui-daam\scripts\daam_script.py", line 99, in process
self.attentions = [s.strip() for s in attention_texts.split(",") if s.strip()]
AttributeError: 'NoneType' object has no attribute 'split'
Data shape for DDIM sampling is (2, 4, 64, 64), eta 0
Running DDIM Sampling with 31 timesteps
DDIM Sampler: 0%| | 0/31 [00:00<?, ?it/s]
i made a few local changes to both modules/api/api.py and modules/scripts.py to determine where this was occurring, and it seems to be scripts.py:409 just simply running every script that has a visible UI element whether or not it was declared by way of adding
else:
print("no alwayson scripts")
in api.py:216-217, as well as a simple print(script) in scripts.py:407
i installed a clean instance of webUI, added --api to commandline args, installed the aesthetic gradients extension, and confirmed via simple http://127.0.0.1:7860/docs POST test to the txt2img endpoint.
reverting to commit 94ffa9fc5386e51f20692ab46906135e8de33110 prevents the issue from occurring
Steps to reproduce the problem
- enable
--apicommandline arg and install aesthetic gradients extension (for example) - Go to local API docs
- Scroll down to
POST sdapi/v1/txt2img, open it, click "try it out" - Paste the following into the input field
{
"batch_size": 1,
"cfg_scale": 7,
"enable_hr": false,
"height": 512,
"n_iter": 1,
"negative_prompt": "test",
"prompt": "test",
"restore_faces": false,
"sampler_index": "DDIM",
"seed": "1",
"steps": 1,
"width": 512
}
- press execute and receive an error most similar to the following in the console
Error running process: E:\storage\webui-clean-2\extensions\stable-diffusion-webui-aesthetic-gradients\scripts\aesthetic.py
Traceback (most recent call last):
File "E:\storage\webui-clean-2\modules\scripts.py", line 386, in process
script.process(p, *script_args)
File "E:\storage\webui-clean-2\extensions\stable-diffusion-webui-aesthetic-gradients\scripts\aesthetic.py", line 36, in process
aesthetic.set_aesthetic_params(p, float(aesthetic_lr), float(aesthetic_weight), int(aesthetic_steps), aesthetic_imgs, aesthetic_slerp, aesthetic_imgs_text, aesthetic_slerp_angle, aesthetic_text_negative)
TypeError: float() argument must be a string or a real number, not 'NoneType'
Data shape for DDIM sampling is (1, 4, 64, 64), eta 0.0
Running DDIM Sampling with 1 timesteps
DDIM Sampler: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 5.56it/s]
What should have happened?
preferably, no errors would be encountered and the console just chugs along without running scripts not defined in the request, but i suppose "always on" might be a hint there
Commit where the problem happens
2174f58daee1e077eec1125e196d34cc93dbaf23
What platforms do you use to access the UI ?
Windows
What browsers do you use to access the UI ?
Mozilla Firefox
Command Line Arguments
--api --ckpt-dir "E:\storage\stable diffusion models" --vae-dir "E:\storage\stable diffusion VAEs"
List of extensions

Console logs
(collected via commit 2174f58daee1e077eec1125e196d34cc93dbaf23)
E:\storage\webui-clean-2>webui-user.bat
venv "E:\storage\webui-clean-2\venv\Scripts\Python.exe"
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug 1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]
Commit hash: 2174f58daee1e077eec1125e196d34cc93dbaf23
Installing requirements for Web UI
Launching Web UI with arguments: --api --ckpt-dir E:\storage\stable diffusion models --vae-dir E:\storage\stable diffusion VAEs
No module 'xformers'. Proceeding without it.
Loading weights [e1441589a6] from E:\storage\stable diffusion models\runwayML-sd-v1-5-pruned.ckpt
Creating model from config: E:\storage\webui-clean-2\configs\v1-inference.yaml
LatentDiffusion: Running in eps-prediction mode
DiffusionWrapper has 859.52 M params.
Applying cross attention optimization (Doggettx).
Textual inversion embeddings loaded(0):
Model loaded in 4.4s (load weights from disk: 1.7s, create model: 0.3s, apply weights to model: 0.5s, apply half(): 0.7s, move model to device: 0.6s, load textual inversion embeddings: 0.7s).
Running on local URL: http://127.0.0.1:7860
To create a public link, set `share=True` in `launch()`.
Error running process: E:\storage\webui-clean-2\extensions\stable-diffusion-webui-aesthetic-gradients\scripts\aesthetic.py
Traceback (most recent call last):
File "E:\storage\webui-clean-2\modules\scripts.py", line 386, in process
script.process(p, *script_args)
File "E:\storage\webui-clean-2\extensions\stable-diffusion-webui-aesthetic-gradients\scripts\aesthetic.py", line 36, in process
aesthetic.set_aesthetic_params(p, float(aesthetic_lr), float(aesthetic_weight), int(aesthetic_steps), aesthetic_imgs, aesthetic_slerp, aesthetic_imgs_text, aesthetic_slerp_angle, aesthetic_text_negative)
TypeError: float() argument must be a string or a real number, not 'NoneType'
Data shape for DDIM sampling is (1, 4, 64, 64), eta 0.0
Running DDIM Sampling with 1 timesteps
DDIM Sampler: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:06<00:00, 6.93s/it]
Error running process: E:\storage\webui-clean-2\extensions\stable-diffusion-webui-aesthetic-gradients\scripts\aesthetic.py | 0/1 [00:00<?, ?it/s]
Traceback (most recent call last):
File "E:\storage\webui-clean-2\modules\scripts.py", line 386, in process
script.process(p, *script_args)
File "E:\storage\webui-clean-2\extensions\stable-diffusion-webui-aesthetic-gradients\scripts\aesthetic.py", line 36, in process
aesthetic.set_aesthetic_params(p, float(aesthetic_lr), float(aesthetic_weight), int(aesthetic_steps), aesthetic_imgs, aesthetic_slerp, aesthetic_imgs_text, aesthetic_slerp_angle, aesthetic_text_negative)
TypeError: float() argument must be a string or a real number, not 'NoneType'
Data shape for DDIM sampling is (1, 4, 64, 64), eta 0.0
Running DDIM Sampling with 1 timesteps
DDIM Sampler: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 3.89it/s]
Error running process: E:\storage\webui-clean-2\extensions\stable-diffusion-webui-aesthetic-gradients\scripts\aesthetic.py
Traceback (most recent call last):
File "E:\storage\webui-clean-2\modules\scripts.py", line 386, in process
script.process(p, *script_args)
File "E:\storage\webui-clean-2\extensions\stable-diffusion-webui-aesthetic-gradients\scripts\aesthetic.py", line 36, in process
aesthetic.set_aesthetic_params(p, float(aesthetic_lr), float(aesthetic_weight), int(aesthetic_steps), aesthetic_imgs, aesthetic_slerp, aesthetic_imgs_text, aesthetic_slerp_angle, aesthetic_text_negative)
TypeError: float() argument must be a string or a real number, not 'NoneType'
Data shape for DDIM sampling is (1, 4, 64, 64), eta 0.0
Running DDIM Sampling with 1 timesteps
DDIM Sampler: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 5.56it/s]
Total progress: 3it [16:03, 283.56s/it]
Additional information
don't mean to be that guy who asks someone specific for help, but @Vespinian? seems you might be the one to pester unfortunately
Yes, it's an unfortunate side effect of initializing script_arg array to None so that I can then insert the args at the correct place. If the extension doesn't handle receiving None in it's arg it will throw an error and extensions that don't take args will run either way. I did attempt to change the scriptrunner to remove from the alwayson_script list the script that were not included with more or less success but I'll give it another shot.
@zero01101 Do you think you could test my tentative fix for this (#8669) to see if the error messages on your end go away while functionality remains? Seems to be working fine on my end.
hey, terribly sorry for the delay and likewise many thanks for your quickness :) can confirm 100% solves the error messages!