aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustAnOkapi <justanokapi@gmail.com>2022-09-13 15:28:03 -0500
committerAUTOMATIC1111 <16777216c@gmail.com>2022-09-14 08:58:13 +0300
commitf9f9d04b5fa9ffb6e0462fa691aee8fcc1bb733c (patch)
tree264af5b87eddb113871f3938f876d2b897db4bd0
parente73e2ce2fd8f5ae86d965d94f39087bd09f0b690 (diff)
prevent extras from saving in dir
Extras have none of the vars used in dir names, so they cant be saved into dirs. +grid code cleanup
-rw-r--r--modules/extras.py2
-rw-r--r--modules/images.py7
-rw-r--r--modules/img2img.py2
-rw-r--r--modules/processing.py2
-rw-r--r--scripts/prompt_matrix.py2
-rw-r--r--scripts/xy_grid.py2
6 files changed, 7 insertions, 10 deletions
diff --git a/modules/extras.py b/modules/extras.py
index cb083544..55a782c7 100644
--- a/modules/extras.py
+++ b/modules/extras.py
@@ -69,7 +69,7 @@ def run_extras(image, gfpgan_visibility, codeformer_visibility, codeformer_weigh
while len(cached_images) > 2:
del cached_images[next(iter(cached_images.keys()))]
- images.save_image(image, outpath, "", None, info=info, extension=opts.samples_format, short_filename=True, no_prompt=True, pnginfo_section_name="extras", existing_info=existing_pnginfo)
+ images.save_image(image, path=outpath, basename="", seed=None, prompt=None, extension=opts.samples_format, info=info, short_filename=True, no_prompt=True, grid=False, pnginfo_section_name="extras", existing_info=existing_pnginfo)
return image, plaintext_to_html(info), ''
diff --git a/modules/images.py b/modules/images.py
index 702c5609..d48a8ab2 100644
--- a/modules/images.py
+++ b/modules/images.py
@@ -280,10 +280,7 @@ def apply_filename_pattern(x, p, seed, prompt):
return x
-def save_image(image, path, basename, seed=None, prompt=None, extension='png', info=None, short_filename=False, no_prompt=False, pnginfo_section_name='parameters', p=None, existing_info=None):
- # would be better to add this as an argument in future, but will do for now
- is_a_grid = basename != ""
-
+def save_image(image, path, basename, seed=None, prompt=None, extension='png', info=None, short_filename=False, no_prompt=False, grid=False, pnginfo_section_name='parameters', p=None, existing_info=None):
if short_filename or prompt is None or seed is None:
file_decoration = ""
elif opts.save_to_dirs:
@@ -307,7 +304,7 @@ def save_image(image, path, basename, seed=None, prompt=None, extension='png', i
else:
pnginfo = None
- save_to_dirs = (is_a_grid and opts.grid_save_to_dirs) or (not is_a_grid and opts.save_to_dirs)
+ save_to_dirs = (grid and opts.grid_save_to_dirs) or (not grid and opts.save_to_dirs and not no_prompt)
if save_to_dirs:
dirname = apply_filename_pattern(opts.directories_filename_pattern or "[prompt_words]", p, seed, prompt)
diff --git a/modules/img2img.py b/modules/img2img.py
index 70c99e33..08e15911 100644
--- a/modules/img2img.py
+++ b/modules/img2img.py
@@ -96,7 +96,7 @@ def img2img(prompt: str, negative_prompt: str, prompt_style: str, init_img, init
grid = images.image_grid(history, batch_size, rows=1)
- images.save_image(grid, p.outpath_grids, "grid", initial_seed, prompt, opts.grid_format, info=info, short_filename=not opts.grid_extended_filename, p=p)
+ images.save_image(grid, p.outpath_grids, "grid", initial_seed, prompt, opts.grid_format, info=info, short_filename=not opts.grid_extended_filename, grid=True, p=p)
processed = Processed(p, history, initial_seed, initial_info)
diff --git a/modules/processing.py b/modules/processing.py
index f33560ee..ef25d43d 100644
--- a/modules/processing.py
+++ b/modules/processing.py
@@ -321,7 +321,7 @@ def process_images(p: StableDiffusionProcessing) -> Processed:
output_images.insert(0, grid)
if opts.grid_save:
- images.save_image(grid, p.outpath_grids, "grid", all_seeds[0], all_prompts[0], opts.grid_format, info=infotext(), short_filename=not opts.grid_extended_filename, p=p)
+ images.save_image(grid, p.outpath_grids, "grid", all_seeds[0], all_prompts[0], opts.grid_format, info=infotext(), short_filename=not opts.grid_extended_filename, grid=True, p=p)
devices.torch_gc()
return Processed(p, output_images, all_seeds[0], infotext())
diff --git a/scripts/prompt_matrix.py b/scripts/prompt_matrix.py
index aaece054..e49c9b20 100644
--- a/scripts/prompt_matrix.py
+++ b/scripts/prompt_matrix.py
@@ -82,6 +82,6 @@ class Script(scripts.Script):
processed.images.insert(0, grid)
if opts.grid_save:
- images.save_image(processed.images[0], p.outpath_grids, "prompt_matrix", prompt=original_prompt, seed=processed.seed, p=p)
+ images.save_image(processed.images[0], p.outpath_grids, "prompt_matrix", prompt=original_prompt, seed=processed.seed, grid=True, p=p)
return processed
diff --git a/scripts/xy_grid.py b/scripts/xy_grid.py
index dd6db81c..c459c264 100644
--- a/scripts/xy_grid.py
+++ b/scripts/xy_grid.py
@@ -192,6 +192,6 @@ class Script(scripts.Script):
)
if opts.grid_save:
- images.save_image(processed.images[0], p.outpath_grids, "xy_grid", prompt=p.prompt, seed=processed.seed, p=p)
+ images.save_image(processed.images[0], p.outpath_grids, "xy_grid", prompt=p.prompt, seed=processed.seed, grid=True, p=p)
return processed