lllyasviel / lllyasviel/stable-diffusion-webui-forge
[Bug]: Default 'module' for controlnet via API
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 13k
- Forks
- 1.7k
- PR merge metrics
- No merged PRs in 30d
Description
### Checklist
- [X] The issue exists after disabling all extensions
- [X] The issue exists on a clean installation of webui
- [X] The issue is caused by an extension, but I believe it is caused by a bug in the webui
- [X] The issue exists in the current version of the webui
- [X] The issue has not been reported before recently
- [ ] The issue has been reported before but has not been fixed yet
### What happened?
Traced an issue to Forge, that I recently reported here -> Mikubill/sd-webui-controlnet#2679
I've implemented a very basic level of controlnet support in [my discord bot](https://github.com/altoiddealer/ad_discordbot), which currently sends values for: `image`, `model`, `module`, `guidance_end`, `weight`, and `enabled`.
**If I do not send a key for `module` in the payload**, it errors with `AttributeError: 'NoneType' object has no attribute 'slider_resolution'`
I'm calling this a bug, because this does not happen in current A1111.... if I repeat the same test but using A1111's API, it defaults the `module` to 'none'.
### Ideally, I am suggesting as a Feature Enhancement that missing keys may default to an appropriate `module` and/or `model` in the same way that ticking a "Control Type" radio button does in the WebUI. Or perhaps, a new key `control_type` could be introduced which would assert a default `model` and `module` by the same mechanism as the Radio buttons, with any explicitly specified `model` or `module` overriding the aforementioned default.
### Steps to reproduce the problem
1. Launch sd webui Forge using --api --listen
2. Send an image payload including minimum Controlnet keys, except for `module`
### What should have happened?
Default `module` to "none" like A1111, **_or even better, smartly default to an appropriate module_** (!!)
### What browsers do you use to access the UI ?
Google Chrome
### Sysinfo
[sysinfo-2024-03-05-19-32.json](https://github.com/lllyasviel/stable-diffusion-webui-forge/files/14500343/sysinfo-2024-03-05-19-32.json)
### Console logs
```Shell
*** Error running process: C:\0_SD\stable-diffusion-webui-forge\extensions-builtin\sd_forge_controlnet\scripts\controlnet.py
Traceback (most recent call last):
File "C:\0_SD\stable-diffusion-webui-forge\modules\scripts.py", line 803, in process
script.process(p, *script_args)
File "C:\0_SD\stable-diffusion-webui-forge\venv\lib\site-packages\torch\utils\_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
File "C:\0_SD\stable-diffusion-webui-forge\extensions-builtin\sd_forge_controlnet\scripts\controlnet.py", line 546, in process
self.bound_check_params(unit)
File "C:\0_SD\stable-diffusion-webui-forge\extensions-builtin\sd_forge_controlnet\scripts\controlnet.py", line 519, in bound_check_params
unit.processor_res = int(preprocessor.slider_resolution.gradio_update_kwargs.get('value', 512))
AttributeError: 'NoneType' object has no attribute 'slider_resolution'
---
*** Error running process_before_every_sampling: C:\0_SD\stable-diffusion-webui-forge\extensions-builtin\sd_forge_controlnet\scripts\controlnet.py
Traceback (most recent call last):
File "C:\0_SD\stable-diffusion-webui-forge\modules\scripts.py", line 835, in process_before_every_sampling
script.process_before_every_sampling(p, *script_args, **kwargs)
File "C:\0_SD\stable-diffusion-webui-forge\venv\lib\site-packages\torch\utils\_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
File "C:\0_SD\stable-diffusion-webui-forge\extensions-builtin\sd_forge_controlnet\scripts\controlnet.py", line 555, in process_before_every_sampling
self.process_unit_before_every_sampling(p, unit, self.current_params[i], *args, **kwargs)
KeyError: 0
```
### Additional information
_No response_
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with extensions-builtin/sd_forge_controlnet/scripts/controlnet.py, especially bound_check_params at line 519 and process at line 546, then reproduce the API request that omits module. Done means the request handles a missing module like A1111, defaults it to "none" or an appropriate value, and no longer produces the shown AttributeError or KeyError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100