aboutsummaryrefslogtreecommitdiffstats
path: root/modules/processing_scripts
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2024-02-11 09:56:53 +0000
committerAUTOMATIC1111 <16777216c@gmail.com>2024-02-11 09:56:53 +0000
commitb7f45e67dcf48914d2f34d4ace977a431a5aa12e (patch)
treeb37f0c45fd54d2b5aab4b4d23ccb6bb3eed48c16 /modules/processing_scripts
parent02ab75b86a91f2ae28edc4ca6ef00c3ab4b51d89 (diff)
downloadstable-diffusion-webui-gfx803-b7f45e67dcf48914d2f34d4ace977a431a5aa12e.tar.gz
stable-diffusion-webui-gfx803-b7f45e67dcf48914d2f34d4ace977a431a5aa12e.tar.bz2
stable-diffusion-webui-gfx803-b7f45e67dcf48914d2f34d4ace977a431a5aa12e.zip
add before_token_counter callback and use it for prompt comments
Diffstat (limited to 'modules/processing_scripts')
-rw-r--r--modules/processing_scripts/comments.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/modules/processing_scripts/comments.py b/modules/processing_scripts/comments.py
index 316356c7..638e39f2 100644
--- a/modules/processing_scripts/comments.py
+++ b/modules/processing_scripts/comments.py
@@ -1,4 +1,4 @@
-from modules import scripts, shared
+from modules import scripts, shared, script_callbacks
import re
@@ -27,6 +27,16 @@ class ScriptStripComments(scripts.Script):
p.main_negative_prompt = strip_comments(p.main_negative_prompt)
+def before_token_counter(params: script_callbacks.BeforeTokenCounterParams):
+ if not shared.opts.enable_prompt_comments:
+ return
+
+ params.prompt = strip_comments(params.prompt)
+
+
+script_callbacks.on_before_token_counter(before_token_counter)
+
+
shared.options_templates.update(shared.options_section(('sd', "Stable Diffusion", "sd"), {
"enable_prompt_comments": shared.OptionInfo(True, "Enable comments").info("Use # anywhere in the prompt to hide the text between # and the end of the line from the generation."),
}))