From 496117e0049c4851bba982b39a4a2b34ee57f5f0 Mon Sep 17 00:00:00 2001 From: Antonio Cordero Balcazar Date: Sat, 14 Oct 2023 13:51:09 +0200 Subject: [PATCH] * Fix processing with A1111 hires fix. * Remove version from title. --- scripts/extension.py | 8 +++++++- sendtonegative.py | 8 ++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/scripts/extension.py b/scripts/extension.py index a58ee1e..54d49be 100644 --- a/scripts/extension.py +++ b/scripts/extension.py @@ -25,7 +25,7 @@ class SendToNegativeScript(scripts.Script): self.callbacks_added = True def title(self): - return f"{SendToNegative.NAME} v{SendToNegative.VERSION}" + return SendToNegative.NAME def show(self, is_img2img): return scripts.AlwaysVisible @@ -36,6 +36,12 @@ class SendToNegativeScript(scripts.Script): p.all_prompts[i], p.all_negative_prompts[i] = stn.process_prompt( p.all_prompts[i], p.all_negative_prompts[i] ) + # make it compatible with A1111 hires fix + if hasattr(p, "all_hr_prompts") and hasattr(p, "all_hr_negative_prompts"): + for i in range(len(p.all_hr_prompts)): # pylint: disable=consider-using-enumerate + p.all_hr_prompts[i], p.all_hr_negative_prompts[i] = stn.process_prompt( + p.all_hr_prompts[i], p.all_hr_negative_prompts[i] + ) def __on_ui_settings(self): section = ("send-to-negative", SendToNegative.NAME) diff --git a/sendtonegative.py b/sendtonegative.py index f689ac7..75b9233 100644 --- a/sendtonegative.py +++ b/sendtonegative.py @@ -6,7 +6,7 @@ import lark class SendToNegative: # pylint: disable=too-few-public-methods NAME = "Send to Negative" - VERSION = "2.1.3" + VERSION = "2.1.4" DEFAULT_SEPARATOR = ", " @@ -163,7 +163,11 @@ class SendToNegative: # pylint: disable=too-few-public-methods parameters = negtagparameters.children[0].value if negtagparameters is not None else "" rest = [] for x in tree.children[1::]: - rest.append(self.__prompt[x.meta.start_pos : x.meta.end_pos] if hasattr(x, "meta") and not x.meta.empty else x.value) + rest.append( + self.__prompt[x.meta.start_pos : x.meta.end_pos] + if hasattr(x, "meta") and not x.meta.empty + else x.value + ) content = "".join(rest) self.__negtags.append( self.NegTag(tree.meta.start_pos, tree.meta.end_pos, content, parameters, self.__shell.copy())