huchenlei / sd-webui-api-payload-display

Display the corresponding API payload after each generation on WebUI
MIT License
160 stars 18 forks source link

init_images is a list of dict instead of a list of base64 in img2img tab #1

Closed speaknowpotato closed 8 months ago

speaknowpotato commented 1 year ago

first, thanks @huchenlei so much for this extension. it is super useful!

It works great in txt2img api, but when i copy the json file in img2img tab,

{"alwayson_scripts": {"API payload": {"args": []}}, "batch_size": 1, "cfg_scale": 7, "denoising_strength": 0.75, "do_not_save_grid": false, "do_not_save_samples": false, "height": 512, "init_images": [{"_category": 0, "_exif": null, "_size": [512, 512], "im": null, "info": {}, "mode": "RGB", "palette": null, "pyaccess": null, "readonly": 0}], "initial_noise_multiplier": 1.0, "inpaint_full_res": 0, "inpaint_full_res_padding": 32, "inpainting_fill": 1, "inpainting_mask_invert": 0, "mask_blur": 4, "n_iter": 1, "negative_prompt": "", "override_settings": {}, "override_settings_restore_afterwards": true, "prompt": "red", "resize_mode": 0, "restore_faces": false, "s_churn": 0.0, "s_min_uncond": 0, "s_noise": 1.0, "s_tmax": null, "s_tmin": 0.0, "sampler_name": "Euler a", "script_args": [], "script_name": null, "seed": -1.0, "seed_enable_extras": false, "seed_resize_from_h": 0, "seed_resize_from_w": 0, "steps": 20, "styles": [], "subseed": -1, "subseed_strength": 0, "tiling": false, "width": 512}

init_images is a list of dict instead of base64 formatted data.

According to the test script in Auto's webui repo https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/master/test/test_img2img.py#L20, it is something like,

"init_images": [img2img_basic_image_base64],

Thanks!

huchenlei commented 1 year ago

When developing the extension I meet some problems with img2img, as the format of image from A1111 is wield:

Error: Cannot convert <ImagingCore object at 0x000002AAEA7B6B30> to JSON compatile format.
Error: Cannot convert b'\x00\x00\x0cHLino\x02\x10\x00\x00mntrRGB XYZ \x07\xce\x00\x02\x00\t\x00\x06\x001\x00\x00acspMSFT\x00\x00\x00\x00IEC sRGB\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf6\xd6\x00\x01\x00\x00\x00\x00\xd3-HP  \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00

For single img2img init_image, there is a ImagingCore object and a piece of byte data. That's how things are passed to ScriptRunner.

Vlad previously suggested replacing all actual images with [base64image goes here] placeholders, as later you probably want to specify other inputs in the payload. WDYT?

huchenlei commented 8 months ago

Fixed in https://github.com/huchenlei/sd-webui-api-payload-display/commit/6e344ad9e3efd6c29d25364ba9fcf8b5de24c20d.