sd-webui-controlnet
sd-webui-controlnet copied to clipboard
API call to `/controlnet/*2img` does not fill script arguments
I'm not sure why no args are passed to scripts when calling controlnet using the API. I encountered this while testing the /controlnet/txt2img
route. Not passing expected script args breaks other scripts, like the model-keyword extension:
Error running process: D:\src\stable-diffusion-webui\extensions\model-keyword\scripts\model_keyword.py
Traceback (most recent call last):
File "D:\src\stable-diffusion-webui\modules\scripts.py", line 386, in process
script.process(p, *script_args)
TypeError: Script.process() missing 5 required positional arguments: 'is_enabled', 'keyword_placement', 'multiple_keywords', 'ti_keywords', and 'keyword_order'
If there is a way, I think it should be considered to fill all scripts run
and postprocess
args with their expected values instead of monkey-patching StableDiffusionProcessing
objects.
Having 2 concurrent calling strategies for all scripts increases code complexity and will lead to other extensions not working. I think we should avoid it where possible.
https://github.com/Mikubill/sd-webui-controlnet/blob/ef126e8b2eebe1cb7d0d24c813b954e704dd4685/scripts/api.py#L183 Remove this should help, not sure if it works.
I checked and the default value for p.script_args
is None
. I'll look into how the ui calls the code for its own /*2img
routes.
The original txt2img route does not call any script, except for the one explicitly specified in the body of requests. I'll try to see whether it's possible to only load both the requested script and controlnet at the same time.