aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorRnDMonkey <ryandrutledge@gmail.com>2022-09-30 03:01:32 +0000
committerAUTOMATIC1111 <16777216c@gmail.com>2022-09-30 10:00:43 +0000
commitff4df06c573c7054f736e0b5a35c24fad2427ab0 (patch)
tree2e5f6d1ca4fb5151a1227ad5c1bc71288c73d7de /modules
parentd18daafb8b0b0b7c5f8dc179de7cc0717465297b (diff)
downloadstable-diffusion-webui-gfx803-ff4df06c573c7054f736e0b5a35c24fad2427ab0.tar.gz
stable-diffusion-webui-gfx803-ff4df06c573c7054f736e0b5a35c24fad2427ab0.tar.bz2
stable-diffusion-webui-gfx803-ff4df06c573c7054f736e0b5a35c24fad2427ab0.zip
refined [styles] pattern and added [prompt_no_styles]
Diffstat (limited to 'modules')
-rw-r--r--modules/images.py8
-rw-r--r--modules/styles.py6
2 files changed, 13 insertions, 1 deletions
diff --git a/modules/images.py b/modules/images.py
index 2e8305ed..87a4caf6 100644
--- a/modules/images.py
+++ b/modules/images.py
@@ -287,6 +287,12 @@ def apply_filename_pattern(x, p, seed, prompt):
if prompt is not None:
x = x.replace("[prompt]", sanitize_filename_part(prompt))
+ if "[prompt_no_styles]" in x:
+ prompt_no_style = prompt
+ for style in shared.prompt_styles.get_style_prompts(p.styles):
+ prompt_no_style = prompt_no_style.replace(style.replace("{prompt}", ""), "")
+ x = x.replace("[prompt_no_styles]", sanitize_filename_part(prompt_no_style, replace_spaces=False))
+
x = x.replace("[prompt_spaces]", sanitize_filename_part(prompt, replace_spaces=False))
if "[prompt_words]" in x:
words = [x for x in re_nonletters.split(prompt or "") if len(x) > 0]
@@ -299,7 +305,7 @@ def apply_filename_pattern(x, p, seed, prompt):
x = x.replace("[cfg]", str(p.cfg_scale))
x = x.replace("[width]", str(p.width))
x = x.replace("[height]", str(p.height))
- x = x.replace("[styles]", sanitize_filename_part(", ".join(p.styles), replace_spaces=False))
+ x = x.replace("[styles]", sanitize_filename_part(", ".join([x for x in p.styles if not x == "None"]), replace_spaces=False))
x = x.replace("[sampler]", sanitize_filename_part(sd_samplers.samplers[p.sampler_index].name, replace_spaces=False))
x = x.replace("[model_hash]", shared.sd_model.sd_model_hash)
diff --git a/modules/styles.py b/modules/styles.py
index eeedcd08..d44dfc1a 100644
--- a/modules/styles.py
+++ b/modules/styles.py
@@ -53,6 +53,12 @@ class StyleDatabase:
negative_prompt = row.get("negative_prompt", "")
self.styles[row["name"]] = PromptStyle(row["name"], prompt, negative_prompt)
+ def get_style_prompts(self, styles):
+ return [self.styles.get(x, self.no_style).prompt for x in styles]
+
+ def get_negative_style_prompts(self, styles):
+ return [self.styles.get(x, self.no_style).negative_prompt for x in styles]
+
def apply_styles_to_prompt(self, prompt, styles):
return apply_styles_to_prompt(prompt, [self.styles.get(x, self.no_style).prompt for x in styles])