diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2023-04-29 13:41:01 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-29 13:41:01 +0000 |
commit | e7d624574d476e008d8c148ba5b74bf13b5834de (patch) | |
tree | 9c5740d1f43eb0963914df50a2457237243031c5 /modules/images.py | |
parent | d609f6030ec464b371a899ced366c62bbd9a4a91 (diff) | |
parent | 7428fb5176ccfd203bddcfa30d75c8df5a772cb4 (diff) | |
download | stable-diffusion-webui-gfx803-e7d624574d476e008d8c148ba5b74bf13b5834de.tar.gz stable-diffusion-webui-gfx803-e7d624574d476e008d8c148ba5b74bf13b5834de.tar.bz2 stable-diffusion-webui-gfx803-e7d624574d476e008d8c148ba5b74bf13b5834de.zip |
Merge branch 'dev' into master
Diffstat (limited to 'modules/images.py')
-rw-r--r-- | modules/images.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/modules/images.py b/modules/images.py index 5c0cf1d8..9cd17ddd 100644 --- a/modules/images.py +++ b/modules/images.py @@ -354,6 +354,8 @@ class FilenameGenerator: 'prompt_words': lambda self: self.prompt_words(),
'batch_number': lambda self: self.p.batch_index + 1,
'generation_number': lambda self: self.p.iteration * self.p.batch_size + self.p.batch_index + 1,
+ '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'
@@ -362,6 +364,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:
|