aboutsummaryrefslogtreecommitdiffstats
path: root/modules/ui.py
diff options
context:
space:
mode:
authorjtkelm2 <feryllcuber@gmail.com>2022-09-14 02:11:46 +0000
committerAUTOMATIC1111 <16777216c@gmail.com>2022-09-14 08:27:41 +0000
commit74c5f7974c31730580e51955b2dca921580b89b8 (patch)
tree1d6d67524e30821696c42a9ca78767ea784113a9 /modules/ui.py
parent0cfbd59d6d3642c5625604f1e10eded647c18980 (diff)
downloadstable-diffusion-webui-gfx803-74c5f7974c31730580e51955b2dca921580b89b8.tar.gz
stable-diffusion-webui-gfx803-74c5f7974c31730580e51955b2dca921580b89b8.tar.bz2
stable-diffusion-webui-gfx803-74c5f7974c31730580e51955b2dca921580b89b8.zip
Added selected image saving
Diffstat (limited to 'modules/ui.py')
-rw-r--r--modules/ui.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/modules/ui.py b/modules/ui.py
index d1aa7793..da481fbf 100644
--- a/modules/ui.py
+++ b/modules/ui.py
@@ -79,15 +79,19 @@ def send_gradio_gallery_to_image(x):
return image_from_url_text(x[0])
-
-def save_files(js_data, images):
+def save_files(js_data, images, index):
import csv
+
os.makedirs(opts.outdir_save, exist_ok=True)
filenames = []
data = json.loads(js_data)
+
+ if index > -1 and opts.save_selected_only and len(images) > 1 and (index > 0 or not opts.return_grid): # ensures we are looking at a specific picture, we have save_selected_only, and there's more than a single image (for correct seed logging in case of return_grid)
+ images = [images[index]]
+ data["seed"] += (index - 1 if opts.return_grid else index)
with open(os.path.join(opts.outdir_save, "log.csv"), "a", encoding="utf8", newline='') as file:
at_start = file.tell() == 0
@@ -348,9 +352,11 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo):
save.click(
fn=wrap_gradio_call(save_files),
+ _js = "(x, y, z) => [x, y, selected_gallery_index()]",
inputs=[
generation_info,
txt2img_gallery,
+ html_info
],
outputs=[
html_info,
@@ -568,9 +574,11 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo):
save.click(
fn=wrap_gradio_call(save_files),
+ _js = "(x, y, z) => [x, y, selected_gallery_index()]",
inputs=[
generation_info,
img2img_gallery,
+ html_info
],
outputs=[
html_info,