aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2023-05-27 20:11:21 +0300
committerGitHub <noreply@github.com>2023-05-27 20:11:21 +0300
commit9bc037d0450543f36d79a9153122dda0eb961b83 (patch)
tree9f728c8c4e368f67cc12f41f7095b1a4da4f57ef /modules
parentd0e8fa627d139dfe08a084ee021f63ed7c2039ab (diff)
parent1db7d212836e0fd8a4eff6922c13a54a372175b2 (diff)
Merge pull request #10655 from fumitakayano/fumitakayano
Added format to specify VAE filename for generated image filenames
Diffstat (limited to 'modules')
-rw-r--r--modules/images.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/modules/images.py b/modules/images.py
index a162fd98..e21e554c 100644
--- a/modules/images.py
+++ b/modules/images.py
@@ -21,6 +21,8 @@ from modules import sd_samplers, shared, script_callbacks, errors
from modules.paths_internal import roboto_ttf_file
from modules.shared import opts
+import modules.sd_vae as sd_vae
+
LANCZOS = (Image.Resampling.LANCZOS if hasattr(Image, 'Resampling') else Image.LANCZOS)
@@ -336,6 +338,16 @@ def sanitize_filename_part(text, replace_spaces=True):
class FilenameGenerator:
+ def get_vae_filename(self): #get the name of the VAE file.
+ if sd_vae.loaded_vae_file is None:
+ return "NoneType"
+ file_name = os.path.basename(sd_vae.loaded_vae_file)
+ split_file_name = file_name.split('.')
+ if len(split_file_name) > 1 and split_file_name[0] == '':
+ return split_file_name[1] # if the first character of the filename is "." then [1] is obtained.
+ else:
+ return split_file_name[0]
+
replacements = {
'seed': lambda self: self.seed if self.seed is not None else '',
'seed_first': lambda self: self.seed if self.p.batch_size == 1 else self.p.all_seeds[0],
@@ -362,6 +374,8 @@ class FilenameGenerator:
'hasprompt': lambda self, *args: self.hasprompt(*args), # accepts formats:[hasprompt<prompt1|default><prompt2>..]
'clip_skip': lambda self: opts.data["CLIP_stop_at_last_layers"],
'denoising': lambda self: self.p.denoising_strength if self.p and self.p.denoising_strength else NOTHING_AND_SKIP_PREVIOUS_TEXT,
+ 'vae_filename': lambda self: self.get_vae_filename(),
+
}
default_time_format = '%Y%m%d%H%M%S'