From 02e351880796422eac3bbaf7aa86332b588651ce Mon Sep 17 00:00:00 2001 From: tqwuliao Date: Sat, 15 Apr 2023 23:20:08 +0800 Subject: Add new FilenameGenerator [hasprompt..] --- modules/images.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'modules/images.py') diff --git a/modules/images.py b/modules/images.py index 2da988ee..cdbb77e1 100644 --- a/modules/images.py +++ b/modules/images.py @@ -349,6 +349,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..] } default_time_format = '%Y%m%d%H%M%S' @@ -357,6 +358,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: -- cgit v1.2.1 From 596556162efd66cca225dffa3765d77cd51f69fe Mon Sep 17 00:00:00 2001 From: File_xor Date: Sun, 16 Apr 2023 16:49:21 +0900 Subject: Add filename pattern for CLIP_stop_at_last_layers. --- modules/images.py | 1 + 1 file changed, 1 insertion(+) (limited to 'modules/images.py') diff --git a/modules/images.py b/modules/images.py index b3535070..6391c34c 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(), + 'clip_skip': lambda: opts.data["CLIP_stop_at_last_layers"], } default_time_format = '%Y%m%d%H%M%S' -- cgit v1.2.1 From acbec225549987297383e3a31290b3f80ed064fd Mon Sep 17 00:00:00 2001 From: File_xor Date: Sun, 16 Apr 2023 17:14:11 +0900 Subject: Add self argument that is mandatory to [clip_skip] filename pattern. --- modules/images.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/images.py') diff --git a/modules/images.py b/modules/images.py index 6391c34c..1a118a69 100644 --- a/modules/images.py +++ b/modules/images.py @@ -352,7 +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(), - 'clip_skip': lambda: opts.data["CLIP_stop_at_last_layers"], + 'clip_skip': lambda self: opts.data["CLIP_stop_at_last_layers"], } default_time_format = '%Y%m%d%H%M%S' -- cgit v1.2.1