mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2025-12-06 10:31:17 -08:00
add before_token_counter callback and use it for prompt comments
This commit is contained in:
parent
02ab75b86a
commit
b7f45e67dc
3 changed files with 43 additions and 1 deletions
|
|
@ -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."),
|
||||
}))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue