Mikubill / sd-webui-controlnet

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

[Bug]: pose recognition results should be without resize #2885

Closed zhzLuke96 closed 1 month ago

zhzLuke96 commented 1 month ago

Is there an existing issue for this?

What happened?

When calling the preprocessing model using the detect interface, the pose data returned by openpose recognition is based on the coordinates of the canvas after resize/pad, which does not match the original image's position.

Steps to reproduce the problem

Using any image request API /controlnet/detect that is not likely to result in a resize

What should have happened?

Phenomenon

Detection image size is 600x700 photo_2024-05-12_21-25-23

The overlay on the left, superimposed on the original image, is the recognized images returned by the interface, while the small image drawn on the right is rendered based on the pose data returned by the response.

Returned results:

{
    "images": [...],
    "info": "Success",
    "poses": [
        {
            "animals": [],
            "canvas_width": 512,
            "canvas_height": 640,
            "people": [...]
        }
    ]
}

The data in people are calculated based on the canvas (after resize/pad to 640*512), which does not correspond to the original image.

Expectation

Preferably, the coordinates before the resize/pad should be directly returned.

Commit where the problem happens

webui: 1.8.0 controlnet: eb451a00

What browsers do you use to access the UI ?

Google Chrome

Command Line Arguments

--no-gradio-queue --api --api --cors-allow-origins=* --listen --disable-safe-unpickle --xformers --opt-split-attention --theme dark

List of enabled extensions

none

Console logs

none

Additional information

No response

huchenlei commented 1 month ago

You can set controlnet_processor_res in /detect endpoint to solve this issue. The default value for resolution is 512. That is why you see the result is resized to 640 x 512. See https://github.com/Mikubill/sd-webui-controlnet/blob/3b4eedd90fe8ebcac5363f586157d36dcd9a513f/scripts/api.py#L103-L105.