mirror of
https://github.com/vladmandic/automatic
synced 2026-09-12 07:58:43 +02:00
add setting for prompt linebreaks
Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
+7
-1
@@ -1,6 +1,6 @@
|
||||
# Change Log for SD.Next
|
||||
|
||||
## Update for 2025-01-31
|
||||
## Update for 2025-02-01
|
||||
|
||||
- **GitHub**
|
||||
- rename core repo from <https://github.com/vladmandic/automatic> to <https://github.com/vladmandic/sdnext>
|
||||
@@ -16,9 +16,15 @@
|
||||
to force torch upgrade, either start with new installation or use `--reinstall` flag
|
||||
- add support for torch **tunable ops**, this can speed up operations by up to *10-30%* on some platforms
|
||||
*set in settings -> backend settings -> torch* and *paths -> tunable ops cache*
|
||||
- add support for stream-loading, this can speed up model loading when models are located on network drives
|
||||
*set in settings -> models & loading -> model load using streams*
|
||||
- enhanced error logging
|
||||
- **Other**:
|
||||
- **Networks**: imporove search/filter and add visual indicators for types
|
||||
- **balanced offload** new defaults: *lowvram/4gb min threshold: 0, medvram/8gb min threshold: 0, default min threshold 0.25*
|
||||
- **prompt parser**: log stats with tokens, sections and min/avg/max weights
|
||||
- **prompt parser**: add setting to ignore line breaks in prompt
|
||||
set in *settings -> prompt settings -> use line breaks*
|
||||
- **Refactor**:
|
||||
- unified trace handler with configurable tracebacks
|
||||
- **Fixes**:
|
||||
|
||||
@@ -326,7 +326,7 @@ def parse_prompt_attention(text):
|
||||
whitespace = ''
|
||||
else:
|
||||
re_attention = re_attention_v1
|
||||
if native:
|
||||
if native and opts.sd_textencder_linebreak:
|
||||
text = text.replace('\n', ' BREAK ')
|
||||
else:
|
||||
text = text.replace('\n', ' ')
|
||||
|
||||
@@ -354,13 +354,28 @@ def get_prompts_with_weights(pipe, prompt: str):
|
||||
if shared.opts.prompt_mean_norm:
|
||||
texts_and_weights = normalize_prompt(texts_and_weights)
|
||||
texts, text_weights = zip(*texts_and_weights)
|
||||
if debug_enabled:
|
||||
avg_weight = 0
|
||||
min_weight = 1
|
||||
max_weight = 0
|
||||
sections = 0
|
||||
|
||||
try:
|
||||
all_tokens = 0
|
||||
for text in texts:
|
||||
for text, weight in zip(texts, text_weights):
|
||||
tokens = get_tokens(pipe, 'section', text)
|
||||
all_tokens += tokens
|
||||
debug(f'Prompt tokenizer: parser={shared.opts.prompt_attention} tokens={all_tokens}')
|
||||
avg_weight += tokens*weight
|
||||
min_weight = min(min_weight, weight)
|
||||
max_weight = max(max_weight, weight)
|
||||
if text != 'BREAK':
|
||||
sections += 1
|
||||
if all_tokens > 0:
|
||||
avg_weight = avg_weight / all_tokens
|
||||
shared.log.debug(f'Prompt tokenizer: parser={shared.opts.prompt_attention} len={len(prompt)} sections={sections} tokens={all_tokens} weights={min_weight:.2f}/{avg_weight:.2f}/{max_weight:.2f}')
|
||||
except Exception:
|
||||
pass
|
||||
debug(f'Prompt: weights={texts_and_weights} time={(time.time() - t0):.3f}')
|
||||
|
||||
return texts, text_weights
|
||||
|
||||
|
||||
|
||||
@@ -499,6 +499,7 @@ options_templates.update(options_section(('text_encoder', "Text Encoder"), {
|
||||
"sd_textencoder_cache": OptionInfo(True, "Cache text encoder results", gr.Checkbox, {"visible": False}),
|
||||
"sd_textencoder_cache_size": OptionInfo(4, "Text encoder cache size", gr.Slider, {"minimum": 0, "maximum": 16, "step": 1}),
|
||||
"comma_padding_backtrack": OptionInfo(20, "Prompt padding", gr.Slider, {"minimum": 0, "maximum": 74, "step": 1, "visible": not native }),
|
||||
"sd_textencder_linebreak": OptionInfo(True, "Use line break as prompt segment marker", gr.Checkbox),
|
||||
"diffusers_zeros_prompt_pad": OptionInfo(False, "Use zeros for prompt padding", gr.Checkbox),
|
||||
"diffusers_pooled": OptionInfo("default", "Diffusers SDXL pooled embeds", gr.Radio, {"choices": ['default', 'weighted']}),
|
||||
}))
|
||||
|
||||
Reference in New Issue
Block a user