AUTOMATIC1111 / stable-diffusion-webui

Stable Diffusion web UI
GNU Affero General Public License v3.0
140.57k stars 26.6k forks source link

[Bug]: Incorrect upscaler behavior in the API. #9676

Open monopolly opened 1 year ago

monopolly commented 1 year ago

Is there an existing issue for this?

What happened?

I'm trying to enlarge the picture through the api. But regardless of the configuration api removes the backgroud of the picture.

Request http://127.0.0.1:7860/sdapi/v1/extra-single-image

{
    "resize_mode": 0,
    "show_extras_results": true,
    "gfpgan_visibility": 0,
    "codeformer_visibility": 0,
    "codeformer_weight": 0,
    "upscaling_resize": 4,
    "upscaling_resize_w": 512,
    "upscaling_resize_h": 512,
    "upscaling_crop": false,
    "upscaler_1": "R-ESRGAN 4x+",
    "upscaler_2": "None",
    "extras_upscaler_2_visibility": 0,
    "upscale_first": false,
    "remove_background": "None",
        "image": "..."
    }

I tried adding Remove Background : "None" but no effect. What can you tell me about it?

Steps to reproduce the problem

  1. send request to API
  2. look at the result

What should have happened?

The picture should just enlarge. The background should remain untouched.

Commit where the problem happens

https://github.com/AUTOMATIC1111/stable-diffusion-webui/commit/a9fed7c364061ae6efb37f797b6b522cb3cf7aa2

What platforms do you use to access the UI ?

MacOS

What browsers do you use to access the UI ?

Apple Safari

Command Line Arguments

Launching Web UI with arguments: 
--api --upcast-sampling --no-half-vae --use-cpu interrogate

List of extensions

No

Console logs

No

Additional information

No response

georgzoeller commented 1 year ago

This is related to the sd-webui-rembg extension. It doesn't seem to interact well with the API, always defaulting to remove background. Removing the extension fixes it but of course fixing it would be better.

LLLYF commented 1 year ago

Sry to bother you ! Could you please tell me what kind of type of "image" ? When I tried to upscale the picture by extra-single-image API but the terminal showed that : Traceback (most recent call last): File "d:\stable-diffusion-webui\forapi\extral-single-image.py", line 52, in for i in r['images']: KeyError: 'images'

The image type as the input str in img2img API is right type...