diff options
author | AUTOMATIC <16777216c@gmail.com> | 2022-09-11 20:25:35 +0000 |
---|---|---|
committer | AUTOMATIC <16777216c@gmail.com> | 2022-09-11 20:25:35 +0000 |
commit | 81d91cea29b8246ad0151fa89e37d6ef719b8b51 (patch) | |
tree | 58a1e16c73bc68245f895fbe42eb10cfb5c0cda1 /modules/images.py | |
parent | 8fb9c57ed62dcef721d50c1eeb9c20f65c509215 (diff) | |
parent | 4535239d8a2541171efe0af4bc55476e119f205e (diff) | |
download | stable-diffusion-webui-gfx803-81d91cea29b8246ad0151fa89e37d6ef719b8b51.tar.gz stable-diffusion-webui-gfx803-81d91cea29b8246ad0151fa89e37d6ef719b8b51.tar.bz2 stable-diffusion-webui-gfx803-81d91cea29b8246ad0151fa89e37d6ef719b8b51.zip |
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'modules/images.py')
-rw-r--r-- | modules/images.py | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/modules/images.py b/modules/images.py index 26c399b6..69d149f5 100644 --- a/modules/images.py +++ b/modules/images.py @@ -243,16 +243,32 @@ def sanitize_filename_part(text): return text.replace(' ', '_').translate({ord(x): '' for x in invalid_filename_chars})[:128]
-def save_image(image, path, basename, seed=None, prompt=None, extension='png', info=None, short_filename=False, no_prompt=False, pnginfo_section_name='parameters'):
+def save_image(image, path, basename, seed=None, prompt=None, extension='png', info=None, short_filename=False, no_prompt=False, pnginfo_section_name='parameters', process_info=None):
# 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:
- file_decoration = f"-{seed}"
+ file_decoration = opts.samples_filename_format or "[SEED]"
else:
- file_decoration = f"-{seed}-{sanitize_filename_part(prompt)[:128]}"
+ file_decoration = opts.samples_filename_format or "[SEED]-[PROMPT]"
+ #file_decoration = f"-{seed}-{sanitize_filename_part(prompt)[:128]}"
+
+ #Add new filenames tags here
+ file_decoration = "-" + file_decoration
+ if seed is not None:
+ file_decoration = file_decoration.replace("[SEED]", str(seed))
+ if prompt is not None:
+ file_decoration = file_decoration.replace("[PROMPT]", sanitize_filename_part(prompt)[:128])
+ file_decoration = file_decoration.replace("[PROMPT_SPACES]", prompt.translate({ord(x): '' for x in invalid_filename_chars})[:128])
+ if process_info is not None:
+ file_decoration = file_decoration.replace("[STEPS]", str(process_info.steps))
+ file_decoration = file_decoration.replace("[CFG]", str(process_info.cfg_scale))
+ file_decoration = file_decoration.replace("[WIDTH]", str(process_info.width))
+ file_decoration = file_decoration.replace("[HEIGHT]", str(process_info.height))
+ file_decoration = file_decoration.replace("[SAMPLER]", str(process_info.sampler))
+
if extension == 'png' and opts.enable_pnginfo and info is not None:
pnginfo = PngImagePlugin.PngInfo()
|