stable-diffusion-webui icon indicating copy to clipboard operation
stable-diffusion-webui copied to clipboard

Allow saving of images generated via API

Open vladmandic opened this issue 1 year ago • 2 comments

Allow generated images to be saved locally when triggered via txt2img or img2img API by passing do_not_save=False

This is a common request now that using scripts via API is supported.

Previously images were never saved and only returned via HTTP response. however, this does not work well when API is used with scripts that return multiple interim images (e.g. prompt travel, seed travel, steps travel, etc.).

To avoid runtime errors, images will be saved to opts.outdir_save if not specified in API script request options.

Additionally, allows API requests to set do_not_send=True so HTTP response will not include all generated images. Again, this is required for scripts that generate a large number of images which would overload HTTP response.

No changes to default behavior (which is not to save images).

Closes #3946 (long standing, lots of upvotes) Closes #8276 Closes #7315 Closes https://github.com/yownas/seed_travel/issues/30

vladmandic avatar Mar 03 '23 13:03 vladmandic

This will also close longstanding issue #3946 as I'll be satisfied with this.

Kilvoctu avatar Mar 05 '23 17:03 Kilvoctu

great but why the double-negative "do_not_save=False" and not "save=True"? :)

hananbeer avatar Mar 09 '23 04:03 hananbeer

So this is working fine right now using:

  "send_images": false/true
  "save_images": false/true

But these parameters are not documented in the API documentation (openapi) and I haven't been able to figure out how to add changes myself (via pull request?). I think it would make sense to list them accordingly.

foxytocin avatar Apr 07 '23 10:04 foxytocin