AUTOMATIC1111 / stable-diffusion-webui

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

[Bug]: When I call the api, what I return is a blurred picture, not the result of the final picture #8825

Open ZIYOU2222 opened 1 year ago

ZIYOU2222 commented 1 year ago

Is there an existing issue for this?

What happened?

When I call the api, what I return is a blurred picture, not the result of the final picture

url = "http://127.0.0.1:7860"

payload = { "prompt": "puppy dog", "steps": 5 }

response = requests.post(url=f'{url}/sdapi/v1/txt2img', json=payload)

r = response.json()

for i in r['images']: image = Image.open(io.BytesIO(base64.b64decode(i.split(",",1)[0])))

png_payload = {
    "image": "data:image/png;base64," + i
}
response2 = requests.post(url=f'{url}/sdapi/v1/png-info', json=png_payload)

pnginfo = PngImagePlugin.PngInfo()
pnginfo.add_text("parameters", response2.json().get("info"))
image.save('output.png', pnginfo=pnginfo)

image

Steps to reproduce the problem

Call the API to generate the image

What should have happened?

Returns the final image

Commit where the problem happens

no

What platforms do you use to access the UI ?

Windows

What browsers do you use to access the UI ?

Google Chrome

Command Line Arguments

No

List of extensions

no

Console logs

no

Additional information

No response

Loadus commented 1 year ago

That looks like the live preview image. The final image is probably stored in the output folders.

neight-allen commented 1 year ago

At 5 steps, that might be the final image. What happens when you increase the steps to 10 or 20?

GoZippy commented 1 year ago

you need more steps more than likely

aryswisnu commented 1 year ago

Hello, any update on this? I tried with img2img it's the same. Here's my config (without "init image"): "seed": -1, "subseed": -1, "subseed_strength": 0, "seed_resize_from_h": -1, "seed_resize_from_w": -1, "sampler_name": "", "batch_size": 1, "n_iter": 1, "steps": 30, "cfg_scale": 7, "width": 512, "height": 512, "restore_faces": false, "tiling": false, "do_not_save_samples": false, "do_not_save_grid": false, "eta": 0, "s_min_uncond": 0, "s_churn": 0, "s_tmax": 0, "s_tmin": 0, "s_noise": 1, "override_settings": {}, "override_settings_restore_afterwards": true, "script_args": [], "sampler_index": "Euler a", "include_init_images": false, "script_name": "", "send_images": true, "save_images": true, "alwayson_scripts": {}