fix missing infotext cased by conda cache
some generation params such as TI hashes or Emphasis is added in sd_hijack / sd_hijack_clip if conda are fetche from cache sd_hijack_clip will not be executed and it won't have a chance to to add generation params the generation params will also be missing if in non low-vram mode because the hijack.extra_generation_params was never read after calculate_hr_conds
This commit is contained in:
@@ -3,7 +3,7 @@ from collections import namedtuple
|
||||
|
||||
import torch
|
||||
|
||||
from modules import prompt_parser, devices, sd_hijack, sd_emphasis
|
||||
from modules import prompt_parser, devices, sd_hijack, sd_emphasis, util
|
||||
from modules.shared import opts
|
||||
|
||||
|
||||
@@ -27,6 +27,30 @@ chunk. Those objects are found in PromptChunk.fixes and, are placed into FrozenC
|
||||
are applied by sd_hijack.EmbeddingsWithFixes's forward function."""
|
||||
|
||||
|
||||
class EmphasisMode(util.GenerationParametersList):
|
||||
def __init__(self, emphasis_mode:str = None):
|
||||
super().__init__()
|
||||
self.emphasis_mode = emphasis_mode
|
||||
|
||||
def __call__(self, *args, **kwargs):
|
||||
return self.emphasis_mode
|
||||
|
||||
def __add__(self, other):
|
||||
if isinstance(other, EmphasisMode):
|
||||
return self if self.emphasis_mode else other
|
||||
elif isinstance(other, str):
|
||||
return self.__str__() + other
|
||||
return NotImplemented
|
||||
|
||||
def __radd__(self, other):
|
||||
if isinstance(other, str):
|
||||
return other + self.__str__()
|
||||
return NotImplemented
|
||||
|
||||
def __str__(self):
|
||||
return self.emphasis_mode if self.emphasis_mode else ''
|
||||
|
||||
|
||||
class TextConditionalModel(torch.nn.Module):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
@@ -238,12 +262,10 @@ class TextConditionalModel(torch.nn.Module):
|
||||
hashes.append(f"{name}: {shorthash}")
|
||||
|
||||
if hashes:
|
||||
if self.hijack.extra_generation_params.get("TI hashes"):
|
||||
hashes.append(self.hijack.extra_generation_params.get("TI hashes"))
|
||||
self.hijack.extra_generation_params["TI hashes"] = ", ".join(hashes)
|
||||
self.hijack.extra_generation_params["TI hashes"] = util.GenerationParametersList(hashes)
|
||||
|
||||
if any(x for x in texts if "(" in x or "[" in x) and opts.emphasis != "Original":
|
||||
self.hijack.extra_generation_params["Emphasis"] = opts.emphasis
|
||||
if opts.emphasis != 'Original' and any(x for x in texts if '(' in x or '[' in x):
|
||||
self.hijack.extra_generation_params["Emphasis"] = EmphasisMode(opts.emphasis)
|
||||
|
||||
if self.return_pooled:
|
||||
return torch.hstack(zs), zs[0].pooled
|
||||
|
||||
Reference in New Issue
Block a user