aboutsummaryrefslogtreecommitdiffstats
path: root/modules/api/api.py
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2023-03-11 10:03:23 +0000
committerGitHub <noreply@github.com>2023-03-11 10:03:23 +0000
commitbb3ecc32856dc1341f2fb6c41efca8ade0f5217e (patch)
tree6571c30590d5df355e36e02d8e47477617e6aa3b /modules/api/api.py
parentd81c50391823aaa264bf9c0896a1552e5af5fea6 (diff)
parentb012d70f15641d6b85c9257b83cec892e941609c (diff)
downloadstable-diffusion-webui-gfx803-bb3ecc32856dc1341f2fb6c41efca8ade0f5217e.tar.gz
stable-diffusion-webui-gfx803-bb3ecc32856dc1341f2fb6c41efca8ade0f5217e.tar.bz2
stable-diffusion-webui-gfx803-bb3ecc32856dc1341f2fb6c41efca8ade0f5217e.zip
Merge pull request #8287 from vladmandic/save-images
Allow saving of images generated via API
Diffstat (limited to 'modules/api/api.py')
-rw-r--r--modules/api/api.py23
1 files changed, 17 insertions, 6 deletions
diff --git a/modules/api/api.py b/modules/api/api.py
index 5a9ac5f1..a6bb439c 100644
--- a/modules/api/api.py
+++ b/modules/api/api.py
@@ -180,8 +180,8 @@ class Api:
populate = txt2imgreq.copy(update={ # Override __init__ params
"sampler_name": validate_sampler_name(txt2imgreq.sampler_name or txt2imgreq.sampler_index),
- "do_not_save_samples": True,
- "do_not_save_grid": True
+ "do_not_save_samples": txt2imgreq.do_not_save,
+ "do_not_save_grid": txt2imgreq.do_not_save,
}
)
if populate.sampler_name:
@@ -190,6 +190,10 @@ class Api:
args = vars(populate)
args.pop('script_name', None)
+ send_images = True if not 'do_not_send' in args else not args['do_not_send']
+ args.pop('do_not_send', None)
+ args.pop('do_not_save', None)
+
with self.queue_lock:
p = StableDiffusionProcessingTxt2Img(sd_model=shared.sd_model, **args)
@@ -203,7 +207,7 @@ class Api:
processed = process_images(p)
shared.state.end()
- b64images = list(map(encode_pil_to_base64, processed.images))
+ b64images = list(map(encode_pil_to_base64, processed.images)) if send_images else []
return TextToImageResponse(images=b64images, parameters=vars(txt2imgreq), info=processed.js())
@@ -220,8 +224,8 @@ class Api:
populate = img2imgreq.copy(update={ # Override __init__ params
"sampler_name": validate_sampler_name(img2imgreq.sampler_name or img2imgreq.sampler_index),
- "do_not_save_samples": True,
- "do_not_save_grid": True,
+ "do_not_save_samples": img2imgreq.do_not_save,
+ "do_not_save_grid": img2imgreq.do_not_save,
"mask": mask
}
)
@@ -232,6 +236,13 @@ class Api:
args.pop('include_init_images', None) # this is meant to be done by "exclude": True in model, but it's for a reason that I cannot determine.
args.pop('script_name', None)
+ send_images = True if not 'do_not_send' in args else not args['do_not_send']
+ args.pop('do_not_send', None)
+ args.pop('do_not_save', None)
+
+ send_images = True if not 'do_not_send_images' in args else not args['do_not_send_images']
+ args.pop('do_not_send_images', None)
+
with self.queue_lock:
p = StableDiffusionProcessingImg2Img(sd_model=shared.sd_model, **args)
p.init_images = [decode_base64_to_image(x) for x in init_images]
@@ -246,7 +257,7 @@ class Api:
processed = process_images(p)
shared.state.end()
- b64images = list(map(encode_pil_to_base64, processed.images))
+ b64images = list(map(encode_pil_to_base64, processed.images)) if send_images else []
if not img2imgreq.include_init_images:
img2imgreq.init_images = None