mirror of
https://github.com/lllyasviel/stable-diffusion-webui-forge.git
synced 2026-04-20 14:29:14 +00:00
Apply emphasis mode changes immediately (#2423)
Previously emphasis mode changes applied only on model load. Also added handling for mode 'None' (literal interpretation), which previously gave results identical to mode 'Ignore'.
This commit is contained in:
@@ -6,6 +6,8 @@ from backend.text_processing import parsing, emphasis
|
||||
from backend.text_processing.textual_inversion import EmbeddingDatabase
|
||||
from backend import memory_management
|
||||
|
||||
from modules.shared import opts
|
||||
|
||||
|
||||
PromptChunkFix = namedtuple('PromptChunkFix', ['offset', 'embedding'])
|
||||
last_extra_generation_params = {}
|
||||
@@ -67,7 +69,7 @@ class ClassicTextProcessingEngine:
|
||||
self.text_encoder = text_encoder
|
||||
self.tokenizer = tokenizer
|
||||
|
||||
self.emphasis = emphasis.get_current_option(emphasis_name)()
|
||||
self.emphasis = emphasis.get_current_option(opts.emphasis)()
|
||||
self.text_projection = text_projection
|
||||
self.minimal_clip_skip = minimal_clip_skip
|
||||
self.clip_skip = clip_skip
|
||||
@@ -146,7 +148,7 @@ class ClassicTextProcessingEngine:
|
||||
return z
|
||||
|
||||
def tokenize_line(self, line):
|
||||
parsed = parsing.parse_prompt_attention(line)
|
||||
parsed = parsing.parse_prompt_attention(line, self.emphasis.name)
|
||||
|
||||
tokenized = self.tokenize([text for text, _ in parsed])
|
||||
|
||||
@@ -248,6 +250,8 @@ class ClassicTextProcessingEngine:
|
||||
return batch_chunks, token_count
|
||||
|
||||
def __call__(self, texts):
|
||||
self.emphasis = emphasis.get_current_option(opts.emphasis)()
|
||||
|
||||
batch_chunks, token_count = self.process_texts(texts)
|
||||
|
||||
used_embeddings = {}
|
||||
|
||||
Reference in New Issue
Block a user