Mikubill / sd-webui-controlnet

WebUI extension for ControlNet
GNU General Public License v3.0
16.84k stars 1.94k forks source link

[Bug]: ValueError: controlnet is enabled but no input image is given. "batch_images" controlnet setting with API not working #2812

Closed MaggieLxj closed 4 months ago

MaggieLxj commented 4 months ago

Is there an existing issue for this?

What happened?

When I used txt2img with controlnet batch run images in a folder, it went everything OK on WEBUI. But when I tried to use API to get the same results, it went something wrong.

But my params are copied from API payload which generated in last webui operation. This confused me very much. Please help me solve this problem. Thanks a lot.

Steps to reproduce the problem

  1. Use webui to get batch run images with controlnet
  2. Copy API payload
  3. Use the API payload to get the same results

What should have happened?

Get the same results look like use webui

Commit where the problem happens

webui: OK controlnet: wrong

What browsers do you use to access the UI ?

No response

Command Line Arguments

./webui.sh --nowebui

List of enabled extensions

2024-04-26_19-21

Console logs

*** Error running process: /home/lxj/Documents/code/ScenarioTool/stable-diffusion-webui/extensions/sd-webui-controlnet/scripts/controlnet.py
    Traceback (most recent call last):
      File "/home/lxj/Documents/code/ScenarioTool/stable-diffusion-webui/modules/scripts.py", line 784, in process
        script.process(p, *script_args)
      File "/home/lxj/Documents/code/ScenarioTool/stable-diffusion-webui/extensions/sd-webui-controlnet/scripts/controlnet.py", line 1117, in process
        self.controlnet_hack(p)
      File "/home/lxj/Documents/code/ScenarioTool/stable-diffusion-webui/extensions/sd-webui-controlnet/scripts/controlnet.py", line 1102, in controlnet_hack
        self.controlnet_main_entry(p)
      File "/home/lxj/Documents/code/ScenarioTool/stable-diffusion-webui/extensions/sd-webui-controlnet/scripts/controlnet.py", line 896, in controlnet_main_entry
        input_image, resize_mode = Script.choose_input_image(p, unit, idx)
      File "/home/lxj/Documents/code/ScenarioTool/stable-diffusion-webui/extensions/sd-webui-controlnet/scripts/controlnet.py", line 673, in choose_input_image
        raise ValueError("controlnet is enabled but no input image is given")
    ValueError: controlnet is enabled but no input image is given

---
100%|██████████████| 20/20 [00:03<00:00,  6.12it/s]
tiled upscale: 100%|█| 18/18 [00:01<00:00, 10.60it/
100%|██████████████| 20/20 [00:32<00:00,  1.65s/it]
Total progress: 100%|█| 40/40 [00:39<00:00,  1.01it
INFO:     127.0.0.1:60270 - "POST /sdapi/v1/txt2img HTTP/1.1" 200 OK

Additional information

The API params looks like as below:

{ "alwayson_scripts": { "API payload": { "args": [] }, "Comments": { "args": [] }, "ControlNet": { "args": [ { "advanced_weighting": null, "batch_images": "/My/images/directory", "control_mode": "Balanced", "enabled": true, "guidance_end": 9, "guidance_start": 0, "hr_option": "Both", "image": null, "inpaint_crop_input_image": false, "input_mode": "batch", "is_ui": true, "loopback": false, "low_vram": false, "model": "control_v11p_sd15_lineart [43d4be0d]", "module": "lineart_realistic", "output_dir": "", "pixel_perfect": true, "processor_res": 512, "resize_mode": "Crop and Resize", "save_detected_map": true, "threshold_a": -1, "threshold_b": -1, "weight": 1.1 }, { "advanced_weighting": null, "batch_images": "/My/images/directory", "control_mode": "Balanced", "enabled": true, "guidance_end": 1, "guidance_start": 0, "hr_option": "Both", "image": null, "inpaint_crop_input_image": false, "input_mode": "batch", "is_ui": true, "loopback": false, "low_vram": false, "model": "control_v11p_sd15_seg [e1f51eb9]", "module": "seg_ofade20k", "output_dir": "", "pixel_perfect": true, "processor_res": 512, "resize_mode": "Crop and Resize", "save_detected_map": true, "threshold_a": -1, "threshold_b": -1, "weight": 1 }, { "advanced_weighting": null, "batch_images": "", "control_mode": "Balanced", "enabled": false, "guidance_end": 1, "guidance_start": 0, "hr_option": "Both", "image": null, "inpaint_crop_input_image": false, "input_mode": "simple", "is_ui": true, "loopback": false, "low_vram": false, "model": "None", "module": "none", "output_dir": "", "pixel_perfect": false, "processor_res": -1, "resize_mode": "Crop and Resize", "save_detected_map": true, "threshold_a": -1, "threshold_b": -1, "weight": 1 } ] }, "Extra options": { "args": [] }, "Hypertile": { "args": [] }, "Refiner": { "args": [ false, "", 0.8 ] }, "Seed": { "args": [ 1739178872, 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 ] }, "Tiled Diffusion": { "args": [ false, "MultiDiffusion", false, true, 1024, 1024, 96, 96, 48, 4, "None", 2, false, 10, 1, 1, 64, false, false, false, false, false, 0.4, 0.4, 0.2, 0.2, "", "", "Background", 0.2, -1.0, false, 0.4, 0.4, 0.2, 0.2, "", "", "Background", 0.2, -1.0, false, 0.4, 0.4, 0.2, 0.2, "", "", "Background", 0.2, -1.0, false, 0.4, 0.4, 0.2, 0.2, "", "", "Background", 0.2, -1.0, false, 0.4, 0.4, 0.2, 0.2, "", "", "Background", 0.2, -1.0, false, 0.4, 0.4, 0.2, 0.2, "", "", "Background", 0.2, -1.0, false, 0.4, 0.4, 0.2, 0.2, "", "", "Background", 0.2, -1.0, false, 0.4, 0.4, 0.2, 0.2, "", "", "Background", 0.2, -1.0 ] }, "Tiled VAE": { "args": [ false, 3072, 192, true, true, true, false ] }, "demofusion": { "args": [ false, "DemoFusion", false, 128, 64, 4, 2, false, 10, 1, 1, 64, false, true, 3, 1, 1, true, 0.85, 0.6, 4, false ] } }, "batch_size": 1, "cfg_scale": 7, "comments": {}, "denoising_strength": 0.7, "disable_extra_networks": false, "do_not_save_grid": true, "do_not_save_samples": false, "enable_hr": true, "height": 540, "hr_negative_prompt": "(text:1.2), sun, wired_shapes_cars, overhead_view, distortion_shapes, bad_anatomy, error, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry,(drawing:1.1), (painting:1.1), virtual", "hr_prompt": "cars driving on the road, (rainy:1.2), tree, detailed_cars break sky break people break street break road_sign break white_lanes break traffic_light, random scenery, (highly detailed), (high fidelity), masterpiece, best quality, realistic, high quality", "hr_resize_x": 0, "hr_resize_y": 0, "hr_scale": 2, "hr_second_pass_steps": 0, "hr_upscaler": "ESRGAN_4x", "n_iter": 1, "negative_prompt": "(text:1.2), sun, wired_shapes_cars, overhead_view, distortion_shapes, bad_anatomy, error, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry,(drawing:1.1), (painting:1.1), virtual", "override_settings": {}, "override_settings_restore_afterwards": true, "prompt": "cars driving on the road, (rainy:1.2), tree, detailed_cars break sky break people break street break road_sign break white_lanes break traffic_light, random scenery, (highly detailed), (high fidelity), masterpiece, best quality, realistic, high quality", "restore_faces": false, "s_churn": 0.0, "s_min_uncond": 0.0, "s_noise": 1.0, "s_tmax": null, "s_tmin": 0.0, "sampler_name": "DPM++ 2M Karras", "script_args": [], "script_name": null, "seed": 1739178872, "seed_enable_extras": true, "seed_resize_from_h": -1, "seed_resize_from_w": -1, "steps": 20, "styles": [], "subseed": 2841292808, "subseed_strength": 0, "tiling": false, "width": 960 }

huchenlei commented 4 months ago

"batch_images" is an UI only field.

huchenlei commented 4 months ago

I am going to add explicit warning using UI-only field in API

MaggieLxj commented 4 months ago

Got it, thank you.

---- Replied Message ---- | From | Chenlei @.> | | Date | 04/27/2024 02:13 | | To | @.> | | Cc | @.>@.> | | Subject | Re: [Mikubill/sd-webui-controlnet] [Bug]: ValueError: controlnet is enabled but no input image is given. "batch_images" controlnet setting with API not working (Issue #2812) |

I am going to add explicit warning using UI-only field in API

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>