diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2023-04-29 10:10:51 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-29 10:10:51 +0000 |
commit | 43925add0afbe5b8e717ce62d8d69154e97efc04 (patch) | |
tree | 89c7f9ac26ae637f22f2db1efe69fb4aa51e9c70 /modules/images.py | |
parent | 1ffb44b0b2c9cb5fb379274515772741a9c1dbaf (diff) | |
parent | 87535fcf292af8890520e7f346df0f41dd74353a (diff) | |
download | stable-diffusion-webui-gfx803-43925add0afbe5b8e717ce62d8d69154e97efc04.tar.gz stable-diffusion-webui-gfx803-43925add0afbe5b8e717ce62d8d69154e97efc04.tar.bz2 stable-diffusion-webui-gfx803-43925add0afbe5b8e717ce62d8d69154e97efc04.zip |
Merge pull request #9643 from tqwuliao/Branch_AddNewFilenameGen
Add new FilenameGenerator replacements [hasprompt<prompt1|default><prompt2>..]
Diffstat (limited to 'modules/images.py')
-rw-r--r-- | modules/images.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/modules/images.py b/modules/images.py index 1a118a69..559de810 100644 --- a/modules/images.py +++ b/modules/images.py @@ -352,6 +352,7 @@ class FilenameGenerator: 'prompt_no_styles': lambda self: self.prompt_no_style(),
'prompt_spaces': lambda self: sanitize_filename_part(self.prompt, replace_spaces=False),
'prompt_words': lambda self: self.prompt_words(),
+ 'hasprompt': lambda self, *args: self.hasprompt(*args), #accept formats:[hasprompt<prompt1|default><prompt2>..]
'clip_skip': lambda self: opts.data["CLIP_stop_at_last_layers"],
}
default_time_format = '%Y%m%d%H%M%S'
@@ -361,6 +362,22 @@ class FilenameGenerator: self.seed = seed
self.prompt = prompt
self.image = image
+
+ def hasprompt(self, *args):
+ lower = self.prompt.lower()
+ if self.p is None or self.prompt is None:
+ return None
+ outres = ""
+ for arg in args:
+ if arg != "":
+ division = arg.split("|")
+ expected = division[0].lower()
+ default = division[1] if len(division) > 1 else ""
+ if lower.find(expected) >= 0:
+ outres = f'{outres}{expected}'
+ else:
+ outres = outres if default == "" else f'{outres}{default}'
+ return sanitize_filename_part(outres)
def prompt_no_style(self):
if self.p is None or self.prompt is None:
|