aboutsummaryrefslogtreecommitdiff
path: root/scripts/xy_grid.py
diff options
context:
space:
mode:
authoraperullo <18688190+aperullo@users.noreply.github.com>2022-10-11 06:16:57 -0400
committerGitHub <noreply@github.com>2022-10-11 11:16:57 +0100
commit255be75d30f41e089e499ec1c8462d6bf64dec24 (patch)
tree9ecfe083c01239e545ca9a780c62f64680e81da3 /scripts/xy_grid.py
parent948533950c9db5069a874d925fadd50bac00fdb5 (diff)
Error if prompt missing SR token to prevent mis-gens (#2209)
Diffstat (limited to 'scripts/xy_grid.py')
-rw-r--r--scripts/xy_grid.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/scripts/xy_grid.py b/scripts/xy_grid.py
index 42e1489c..10a82dc9 100644
--- a/scripts/xy_grid.py
+++ b/scripts/xy_grid.py
@@ -27,9 +27,16 @@ def apply_field(field):
def apply_prompt(p, x, xs):
+
+ orig_prompt = p.prompt
+ orig_negative_prompt = p.negative_prompt
+
p.prompt = p.prompt.replace(xs[0], x)
p.negative_prompt = p.negative_prompt.replace(xs[0], x)
+ if p.prompt == orig_prompt and p.negative_prompt == orig_negative_prompt:
+ raise RuntimeError(f"Prompt S/R did not find {xs[0]} in prompt or negative prompt. Did you forget to add the token?")
+
def apply_order(p, x, xs):
token_order = []