lllyasviel / lllyasviel/stable-diffusion-webui-forge

[Bug]: API ControlNet is not working, Working in webui

Open
#627 6 comments 0 reactions 0 assignees View on GitHub

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
- [ ] 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?

ControlNet API is not working, but in webui ControlNet is working properly.

### Steps to reproduce the problem

Go to http://127.0.0.1:7860/docs#/default/img2imgapi_sdapi_v1_img2img_post

{
"alwayson_scripts": {
"API payload": {
"args": []
},
"Comments": {
"args": []
},
"ControlNet": {
"args": [
{
"batch_image_dir": "",
"batch_input_gallery": [],
"batch_mask_dir": "",
"batch_mask_gallery": [],
"control_mode": "Balanced",
"enabled": true,
"generated_image": null,
"guidance_end": 1,
"guidance_start": 0,
"hr_option": "Both",
"image": null,
"input_mode": "simple",
"mask_image": null,
"model": "diffusion_pytorch_model [458b7f40]",
"module": "openpose_full",
"pixel_perfect": true,
"processor_res": 512,
"resize_mode": "Crop and Resize",
"save_detected_map": true,
"threshold_a": 0.5,
"threshold_b": 0.5,
"use_preview_as_input": false,
"weight": 1
},
{
"batch_image_dir": "",
"batch_input_gallery": [],
"batch_mask_dir": "",
"batch_mask_gallery": [],
"control_mode": "Balanced",
"enabled": false,
"generated_image": null,
"guidance_end": 1,
"guidance_start": 0,
"hr_option": "Both",
"image": null,
"input_mode": "simple",
"mask_image": null,
"model": "None",
"module": "None",
"pixel_perfect": false,
"processor_res": -1,
"resize_mode": "Crop and Resize",
"save_detected_map": true,
"threshold_a": -1,
"threshold_b": -1,
"use_preview_as_input": false,
"weight": 1
},
{
"batch_image_dir": "",
"batch_input_gallery": [],
"batch_mask_dir": "",
"batch_mask_gallery": [],
"control_mode": "Balanced",
"enabled": false,
"generated_image": null,
"guidance_end": 1,
"guidance_start": 0,
"hr_option": "Both",
"image": null,
"input_mode": "simple",
"mask_image": null,
"model": "None",
"module": "None",
"pixel_perfect": false,
"processor_res": -1,
"resize_mode": "Crop and Resize",
"save_detected_map": true,
"threshold_a": -1,
"threshold_b": -1,
"use_preview_as_input": false,
"weight": 1
}
]
},
"DynamicThresholding (CFG-Fix) Integrated": {
"args": [
false,
7,
1,
"Constant",
0,
"Constant",
0,
1,
"enable",
"MEAN",
"AD",
1
]
},
"Extra options": {
"args": []
},
"FreeU Integrated": {
"args": [
false,
1.01,
1.02,
0.99,
0.95
]
},
"HyperTile Integrated": {
"args": [
false,
256,
2,
0,
false
]
},
"Kohya HRFix Integrated": {
"args": [
false,
3,
2,
0,
0.35,
true,
"bicubic",
"bicubic"
]
},
"LatentModifier Integrated": {
"args": [
false,
0,
"anisotropic",
0,
"reinhard",
100,
0,
"subtract",
0,
0,
"gaussian",
"add",
0,
100,
127,
0,
"hard_clamp",
5,
0,
"None",
"None"
]
},
"MultiDiffusion Integrated": {
"args": [
false,
"MultiDiffusion",
768,
768,
64,
4
]
},
"Never OOM Integrated": {
"args": [
false,
false
]
},
"Refiner": {
"args": [
false,
"",
0.8
]
},
"Seed": {
"args": [
1102242279,
false,
-1,
0,
0,
0
]
},
"Segment Anything": {
"args": [
false,
false,
0,
null,
[],
0,
false,
[],
[],
false,
0,
1,
false,
false,
0,
null,
[],
-2,
false,
[],
false,
0,
null,
null
]
},
"SelfAttentionGuidance Integrated": {
"args": [
false,
0.5,
2
]
},
"Soft Inpainting": {
"args": [
false,
1,
0.5,
4,
0,
0.5,
2
]
},
"StyleAlign Integrated": {
"args": [
false
]
}
},
"batch_size": 1,
"cfg_scale": 7,
"comments": {},
"denoising_strength": 0.75,
"disable_extra_networks": false,
"do_not_save_grid": false,
"do_not_save_samples": false,
"height": 683,
"image_cfg_scale": 1.5,
"init_images": [
"base64image placeholder"
],
"initial_noise_multiplier": 1,
"inpaint_full_res": 0,
"inpaint_full_res_padding": 32,
"inpainting_fill": 1,
"inpainting_mask_invert": 0,
"mask_blur": "base64image placeholder",
"mask_blur": 4,
"mask_blur_x": 4,
"mask_blur_y": 4,
"mask_round": true,
"n_iter": 1,
"negative_prompt": "ugly, deformed, noisy, blurry, distorted, nude, nsfw, out of focus, bad anatomy, extra limbs, poorly drawn face, poorly drawn hands, missing fingers, disfigured, ugly, bad, immature, cartoon, anime, 3d, painting, b&w",
"override_settings": {},
"override_settings_restore_afterwards": true,
"prompt": "group of people waring military costume, masterpiece hyper realism 8k, HDR, highly detailed, sharp focus, looking at the camera",
"resize_mode": 0,
"restore_faces": false,
"s_churn": 0,
"s_min_uncond": 0,
"s_noise": 1,
"s_tmax": null,
"s_tmin": 0,
"sampler_name": "Euler a",
"script_args": [],
"script_name": null,
"seed": 1102242279,
"seed_enable_extras": true,
"seed_resize_from_h": -1,
"seed_resize_from_w": -1,
"steps": 30,
"styles": [],
"subseed": -1,
"subseed_strength": 0,
"tiling": false,
"width": 1024
}

### What should have happened?

ControlNet API is not working

### What browsers do you use to access the UI ?

Google Chrome

### Sysinfo

-

### Console logs

```Shell
ControlNet openpose is working fine with webui, but when I try from API same model and setting it is giving following error.

*** Error running postprocess_batch_list: D:\Forge\webui\extensions-builtin\sd_forge_controlnet\scripts\controlnet.pys]
Traceback (most recent call last):
File "D:\Forge\webui\modules\scripts.py", line 859, in postprocess_batch_list
script.postprocess_batch_list(p, pp, *script_args, **kwargs)
File "D:\Forge\system\python\lib\site-packages\torch\utils\_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
File "D:\Forge\webui\extensions-builtin\sd_forge_controlnet\scripts\controlnet.py", line 561, in postprocess_batch_list
self.process_unit_after_every_sampling(p, unit, self.current_params[i], pp, *args, **kwargs)
KeyError: 0

---
Total progress: 100%|██████████████████████████████████████████████████████████████████| 23/23 [00:05<00:00, 4.51it/s]
Total progress: 100%|██████████████████████████████████████████████████████████████████| 23/23 [00:05<00:00, 4.63it/s]
```

### Additional information

-

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the img2img API endpoint in the issue and reproduce the request with the supplied ControlNet payload. Trace the failure from modules/scripts.py:859 into extensions-builtin/sd_forge_controlnet/scripts/controlnet.py:561, where postprocess_batch_list raises KeyError: 0. Done means the same ControlNet configuration works through the API without this error, while webui behavior remains unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.