aboutsummaryrefslogtreecommitdiffstats
path: root/modules/images.py
diff options
context:
space:
mode:
authortechneconn <techneconn@gmail.com>2023-02-05 06:48:51 +0000
committertechneconn <techneconn@gmail.com>2023-02-05 06:48:51 +0000
commit5a1b62e9f8048e20a9ff47df73b16f8a0b5e673c (patch)
tree35904a38f191c0f6135164eef9ee8c1c3b8db2c1 /modules/images.py
parent3e0f9a75438fa815429b5530261bcf7d80f3f101 (diff)
downloadstable-diffusion-webui-gfx803-5a1b62e9f8048e20a9ff47df73b16f8a0b5e673c.tar.gz
stable-diffusion-webui-gfx803-5a1b62e9f8048e20a9ff47df73b16f8a0b5e673c.tar.bz2
stable-diffusion-webui-gfx803-5a1b62e9f8048e20a9ff47df73b16f8a0b5e673c.zip
Add prompt_hash option for file/dir name pattern
Diffstat (limited to 'modules/images.py')
-rw-r--r--modules/images.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/modules/images.py b/modules/images.py
index 4bdbd730..f4b20b28 100644
--- a/modules/images.py
+++ b/modules/images.py
@@ -16,6 +16,7 @@ from PIL import Image, ImageFont, ImageDraw, PngImagePlugin
from fonts.ttf import Roboto
import string
import json
+import hashlib
from modules import sd_samplers, shared, script_callbacks
from modules.shared import opts, cmd_opts
@@ -343,6 +344,7 @@ 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': 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),