diff options
author | JustAnOkapi <justanokapi@gmail.com> | 2022-09-13 15:28:03 -0500 |
---|---|---|
committer | AUTOMATIC1111 <16777216c@gmail.com> | 2022-09-14 08:58:13 +0300 |
commit | f9f9d04b5fa9ffb6e0462fa691aee8fcc1bb733c (patch) | |
tree | 264af5b87eddb113871f3938f876d2b897db4bd0 /modules | |
parent | e73e2ce2fd8f5ae86d965d94f39087bd09f0b690 (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
Diffstat (limited to 'modules')
-rw-r--r-- | modules/extras.py | 2 | ||||
-rw-r--r-- | modules/images.py | 7 | ||||
-rw-r--r-- | modules/img2img.py | 2 | ||||
-rw-r--r-- | modules/processing.py | 2 |
4 files changed, 5 insertions, 8 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())
|