diff options
author | w-e-w <40751091+w-e-w@users.noreply.github.com> | 2023-08-18 06:07:40 +0000 |
---|---|---|
committer | w-e-w <40751091+w-e-w@users.noreply.github.com> | 2023-08-18 06:13:12 +0000 |
commit | a81dc43fcd99c8952654ee905f9875cea7ba8613 (patch) | |
tree | 583b54685208d8b79d33308e88c64ad242a644cc /modules/images.py | |
parent | 8a1f32b6a5ce4dd5485fafd174eeeb142a877940 (diff) | |
download | stable-diffusion-webui-gfx803-a81dc43fcd99c8952654ee905f9875cea7ba8613.tar.gz stable-diffusion-webui-gfx803-a81dc43fcd99c8952654ee905f9875cea7ba8613.tar.bz2 stable-diffusion-webui-gfx803-a81dc43fcd99c8952654ee905f9875cea7ba8613.zip |
negative_prompt full_prompt hash
Diffstat (limited to 'modules/images.py')
-rw-r--r-- | modules/images.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/modules/images.py b/modules/images.py index ea5df6dc..a6b4fb1e 100644 --- a/modules/images.py +++ b/modules/images.py @@ -355,7 +355,9 @@ class FilenameGenerator: 'date': lambda self: datetime.datetime.now().strftime('%Y-%m-%d'),
'datetime': lambda self, *args: self.datetime(*args), # accepts formats: [datetime], [datetime<Format>], [datetime<Format><Time Zone>]
'job_timestamp': lambda self: getattr(self.p, "job_timestamp", shared.state.job_timestamp),
- 'prompt_hash': lambda self: hashlib.sha256(self.prompt.encode()).hexdigest()[0:8],
+ 'prompt_hash': lambda self, *args: self.string_hash(self.prompt, *args),
+ 'negative_prompt_hash': lambda self, *args: self.string_hash(self.p.negative_prompt, *args),
+ 'full_prompt_hash': lambda self, *args: self.string_hash(f"{self.p.prompt} {self.p.negative_prompt}", *args), # a space in between to create a unique string
'prompt': lambda self: sanitize_filename_part(self.prompt),
'prompt_no_styles': lambda self: self.prompt_no_style(),
'prompt_spaces': lambda self: sanitize_filename_part(self.prompt, replace_spaces=False),
@@ -453,6 +455,10 @@ class FilenameGenerator: length = int(args[0]) if (args and args[0] != "") else None
return hashlib.sha256(self.image.tobytes()).hexdigest()[0:length]
+ def string_hash(self, text, *args):
+ length = int(args[0]) if (args and args[0] != "") else 8
+ return hashlib.sha256(text.encode()).hexdigest()[0:length]
+
def apply(self, x):
res = ''
|