From decbbe81f5f92bbb4f5613bc78396b7f03eb26a3 Mon Sep 17 00:00:00 2001 From: AUTOMATIC <16777216c@gmail.com> Date: Sat, 10 Sep 2022 13:36:16 +0300 Subject: [PATCH] separated options for sample and grid dir saving for #222 --- modules/images.py | 7 ++++++- modules/shared.py | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/images.py b/modules/images.py index cfe88fa46..d8e74533c 100644 --- a/modules/images.py +++ b/modules/images.py @@ -244,6 +244,9 @@ def sanitize_filename_part(text): def save_image(image, path, basename, seed=None, prompt=None, extension='png', info=None, short_filename=False, no_prompt=False): + # would be better to add this as an argument in future, but will do for now + is_a_grid = basename != "" + if short_filename or prompt is None or seed is None: file_decoration = "" elif opts.save_to_dirs: @@ -257,7 +260,9 @@ def save_image(image, path, basename, seed=None, prompt=None, extension='png', i else: pnginfo = None - if opts.save_to_dirs and not no_prompt: + save_to_dirs = (is_a_grid and opts.grid_save_to_dirs) or (not is_a_grid and opts.save_to_dirs) + + if save_to_dirs and not no_prompt: words = re_nonletters.split(prompt or "") if len(words[0]) == 0: words = ["empty"] diff --git a/modules/shared.py b/modules/shared.py index 6a61fb861..50c091874 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -98,7 +98,8 @@ class Options: "outdir_grids": OptionInfo("", "Output directory for grids; if empty, defaults to two directories below"), "outdir_txt2img_grids": OptionInfo("outputs/txt2img-grids", 'Output directory for txt2img grids'), "outdir_img2img_grids": OptionInfo("outputs/img2img-grids", 'Output directory for img2img grids'), - "save_to_dirs": OptionInfo(False, "When writing images/grids, create a directory with name derived from the prompt"), + "save_to_dirs": OptionInfo(False, "When writing images, create a directory with name derived from the prompt"), + "grid_save_to_dirs": OptionInfo(False, "When writing grids, create a directory with name derived from the prompt"), "save_to_dirs_prompt_len": OptionInfo(10, "When using above, how many words from prompt to put into directory name", gr.Slider, {"minimum": 1, "maximum": 32, "step": 1}), "outdir_save": OptionInfo("log/images", "Directory for saving images using the Save button"), "samples_save": OptionInfo(True, "Save indiviual samples"),