stable-diffusion-webui
stable-diffusion-webui copied to clipboard
using API's "script_name" throws and error only :(
Is there an existing issue for this?
- [X] I have searched the existing issues and checked the recent builds/commits
What happened?
Hey guys, I am pretty stuck with this :( > I am building a custom plugin for Automatic1111 API to Unity/C# using mainly the img2img section. By default, everything works fine - now, if I try to call an extension script via API - for example "script_name": "Depth aware img2img mask" - to get a quick depthmap - I constanty recieve an 500 Error ( "Invalid encoded image" ) - If I comment the "script_name" element out of the JSON, everything works fine. What did I miss?
Is there any documentation or help? - I hope you guy could give me a kickstart for this! I would really apreciate!!!
Steps to reproduce the problem
- Call API with img2img section with base64 image attached
- Add "script_name" element
- 500 error return :/
What should have happened?
The API should return the prompted image + a depthmap
Commit where the problem happens
python: 3.10.9 • torch: 1.12.1+cu113 • xformers: N/A • gradio: 3.16.2 • commit: ea9bd9fc • checkpoint: fe4efff1e1
What platforms do you use to access the UI ?
Windows
What browsers do you use to access the UI ?
Mozilla Firefox
Command Line Arguments
@echo off
set PYTHON=
set GIT=
set VENV_DIR=
set COMMANDLINE_ARGS= --api --listen --cors-allow-origins=*
call webui.bat
List of extensions
Depth aware img2img mask
Console logs
File "C:\Users\SimonOakey\stable-diffusion-webui\venv\lib\site-packages\anyio\streams\memory.py", line 94, in receive
return self.receive_nowait()
File "C:\Users\SimonOakey\stable-diffusion-webui\venv\lib\site-packages\anyio\streams\memory.py", line 89, in receive_nowait
raise WouldBlock
anyio.WouldBlock
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\SimonOakey\stable-diffusion-webui\venv\lib\site-packages\starlette\middleware\base.py", line 77, in call_next
message = await recv_stream.receive()
File "C:\Users\SimonOakey\stable-diffusion-webui\venv\lib\site-packages\anyio\streams\memory.py", line 114, in receive raise EndOfStream
anyio.EndOfStream
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\SimonOakey\stable-diffusion-webui\venv\lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 407, in run_asgi
result = await app( # type: ignore[func-returns-value]
File "C:\Users\SimonOakey\stable-diffusion-webui\venv\lib\site-packages\uvicorn\middleware\proxy_headers.py", line 78, in __call__
return await self.app(scope, receive, send)
File "C:\Users\SimonOakey\stable-diffusion-webui\venv\lib\site-packages\fastapi\applications.py", line 270, in __call__
await super().__call__(scope, receive, send)
File "C:\Users\SimonOakey\stable-diffusion-webui\venv\lib\site-packages\starlette\applications.py", line 124, in __call__
await self.middleware_stack(scope, receive, send)
File "C:\Users\SimonOakey\stable-diffusion-webui\venv\lib\site-packages\starlette\middleware\errors.py", line 184, in __call__
raise exc
File "C:\Users\SimonOakey\stable-diffusion-webui\venv\lib\site-packages\starlette\middleware\errors.py", line 162, in __call__
await self.app(scope, receive, _send)
File "C:\Users\SimonOakey\stable-diffusion-webui\venv\lib\site-packages\starlette\middleware\base.py", line 106, in __call__
response = await self.dispatch_func(request, call_next)
File "C:\Users\SimonOakey\stable-diffusion-webui\modules\api\api.py", line 96, in log_and_time
res: Response = await call_next(req)
File "C:\Users\SimonOakey\stable-diffusion-webui\venv\lib\site-packages\starlette\middleware\base.py", line 80, in call_next
raise app_exc
File "C:\Users\SimonOakey\stable-diffusion-webui\venv\lib\site-packages\starlette\middleware\base.py", line 69, in coro
await self.app(scope, receive_or_disconnect, send_no_error)
File "C:\Users\SimonOakey\stable-diffusion-webui\venv\lib\site-packages\starlette\middleware\gzip.py", line 24, in __call__
await responder(scope, receive, send)
File "C:\Users\SimonOakey\stable-diffusion-webui\venv\lib\site-packages\starlette\middleware\gzip.py", line 43, in __call__
await self.app(scope, receive, self.send_with_gzip)
File "C:\Users\SimonOakey\stable-diffusion-webui\venv\lib\site-packages\starlette\middleware\cors.py", line 84, in __call__
await self.app(scope, receive, send)
File "C:\Users\SimonOakey\stable-diffusion-webui\venv\lib\site-packages\starlette\middleware\exceptions.py", line 79, in __call__
raise exc
File "C:\Users\SimonOakey\stable-diffusion-webui\venv\lib\site-packages\starlette\middleware\exceptions.py", line 68, in __call__
await self.app(scope, receive, sender)
File "C:\Users\SimonOakey\stable-diffusion-webui\venv\lib\site-packages\fastapi\middleware\asyncexitstack.py", line 21, in __call__
raise e
File "C:\Users\SimonOakey\stable-diffusion-webui\venv\lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__
await self.app(scope, receive, send)
File "C:\Users\SimonOakey\stable-diffusion-webui\venv\lib\site-packages\starlette\routing.py", line 706, in __call__
await route.handle(scope, receive, send)
File "C:\Users\SimonOakey\stable-diffusion-webui\venv\lib\site-packages\starlette\routing.py", line 276, in handle
await self.app(scope, receive, send)
File "C:\Users\SimonOakey\stable-diffusion-webui\venv\lib\site-packages\starlette\routing.py", line 66, in app
response = await func(request)
File "C:\Users\SimonOakey\stable-diffusion-webui\venv\lib\site-packages\fastapi\routing.py", line 235, in app
raw_response = await run_endpoint_function(
File "C:\Users\SimonOakey\stable-diffusion-webui\venv\lib\site-packages\fastapi\routing.py", line 163, in run_endpoint_function
return await run_in_threadpool(dependant.call, **values)
File "C:\Users\SimonOakey\stable-diffusion-webui\venv\lib\site-packages\starlette\concurrency.py", line 41, in run_in_threadpool
return await anyio.to_thread.run_sync(func, *args)
File "C:\Users\SimonOakey\stable-diffusion-webui\venv\lib\site-packages\anyio\to_thread.py", line 31, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
File "C:\Users\SimonOakey\stable-diffusion-webui\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 937, in run_sync_in_worker_thread
return await future
File "C:\Users\SimonOakey\stable-diffusion-webui\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 867, in run result = context.run(func, *args)
File "C:\Users\SimonOakey\stable-diffusion-webui\modules\api\api.py", line 244, in img2imgapi
processed = scripts.scripts_img2img.run(p, *p.script_args)
File "C:\Users\SimonOakey\stable-diffusion-webui\modules\scripts.py", line 376, in run
processed = script.run(p, *script_args)
TypeError: Script.run() missing 11 required positional arguments: 'save_depthmap', 'treshold', 'match_size', 'net_width', 'net_height', 'invert_depth', 'model_type', 'override_mask_blur', 'override_fill', 'clean_cut', and 'save_alpha_crop'
Additional information
No response
Did you end up solving this? did you just have to pass all of the arguments?
TypeError: Script.run() missing 11 required positional arguments: 'save_depthmap', 'treshold', 'match_size', 'net_width', 'net_height', 'invert_depth', 'model_type', 'override_mask_blur', 'override_fill', 'clean_cut', and 'save_alpha_crop'
@crypticsymmetry - Unfortunately no. Actually I passed all those parameters in an updated version. But with no sucess eigher :/ - Don't know what I am missing.
i got it working for 'Ultimate SD upscale', this is what the script_args looks like if it helps.
const imageData = await response.json();
const imageBase64 = imageData.images[0];
script_name: script,
script_args: [
imageBase64, 608, 608, 8, 32, 64, 0.35, 16,
3, 'True', 1, "False", 4,
0, "From img2img2 settings", 1512, 1512, 2
],
my error:
TypeError: Script.run() missing 18 required positional arguments: '_', 'tile_width', 'tile_height', 'mask_blur', 'padding', 'seams_fix_width', 'seams_fix_denoise', 'seams_fix_padding', 'upscaler_index', 'save_upscaled_image', 'redraw_mode', 'save_seams_fix_image', 'seams_fix_mask_blur', 'seams_fix_type', 'target_size_type', 'custom_width', 'custom_height', and 'custom_scale'
I just fix the bug by update the newest code of api.py If you passed "alwayson_scripts",sd may produced TypeError: Script.run() missing xx required positional arguments. hopes this commit can help you Changed behavior that puts the args from alwayson_script request in t…
my ultimate upscaler suddenly unable to use.
TypeError: Script.run() missing 18 required positional arguments: '_', 'tile_width', 'tile_height', 'mask_blur', 'padding', 'seams_fix_width', 'seams_fix_denoise', 'seams_fix_padding', 'upscaler_index', 'save_upscaled_image', 'redraw_mode', 'save_seams_fix_image', 'seams_fix_mask_blur', 'seams_fix_type', 'target_size_type', 'custom_width', 'custom_height', and 'custom_scale'
anyone have the same issue?
Did you end up solving this? did you just have to pass all of the arguments?
TypeError: Script.run() missing 11 required positional arguments: 'save_depthmap', 'treshold', 'match_size', 'net_width', 'net_height', 'invert_depth', 'model_type', 'override_mask_blur', 'override_fill', 'clean_cut', and 'save_alpha_crop'
Good news I figured this one out :) Turns out the model_type is not a string. It's a integer index for this array found in "\extensions\depthmap2mask\scripts\depthmap_for_depth2img.py":
models = ["dpt_beit_large_512",
"dpt_beit_large_384",
"dpt_beit_base_384",
"dpt_swin2_large_384",
"dpt_swin2_base_384",
"dpt_swin2_tiny_256",
"dpt_swin_large_384",
"dpt_next_vit_large_384",
"dpt_levit_224",
"dpt_large_384",
"dpt_hybrid_384",
"midas_v21_384",
"midas_v21_small_256",
# "openvino_midas_v21_small_256"
]
I'm using PHP here, not python, but this now working for me:
"script_name" => "Depth aware img2img mask",
"script_args" => [
# 'save_depthmap', 'treshold', 'match_size', 'net_width', 'net_height', 'invert_depth', 'model_type', 'override_mask_blur', 'override_fill', 'clean_cut', and 'save_alpha_crop'
true,0.5,true,200,200,false,11,false,false,false,false
],
Hope it helps you