diff --git a/__init__.py b/__init__.py index 47d6f36..741c278 100644 --- a/__init__.py +++ b/__init__.py @@ -181,7 +181,6 @@ NODE_CLASS_MAPPINGS = { "ImpactWildcardProcessor": ImpactWildcardProcessor, "ImpactWildcardEncode": ImpactWildcardEncode, - "ImpactLogger": ImpactLogger, "SEGSDetailer": SEGSDetailer, "SEGSPaste": SEGSPaste, @@ -221,6 +220,9 @@ NODE_CLASS_MAPPINGS = { "ImpactNeg": ImpactNeg, "ImpactConditionalStopIteration": ImpactConditionalStopIteration, "ImpactStringSelector": StringSelector, + + "ImpactLogger": ImpactLogger, + "ImpactDummyInput": ImpactDummyInput, } diff --git a/js/impact-pack.js b/js/impact-pack.js index 9be8879..435122e 100644 --- a/js/impact-pack.js +++ b/js/impact-pack.js @@ -258,14 +258,43 @@ app.registerExtension({ node.widgets_values[1] = node.widgets[1].value; } - this._value = value; + node._value = value; }, get: () => { - return this._value; + return node._value; } }); } + if(node.comfyClass == "ImpactWildcardEncode") { + node._value = "Select the LoRA to add to the text"; + + Object.defineProperty(node.widgets[3], "value", { + set: (value) => { + const stackTrace = new Error().stack; + if(stackTrace.includes('inner_value_change')) { + if(value != "Select the LoRA to add to the text") { + let lora_name = value; + if (lora_name.endsWith('.safetensors')) { + lora_name = lora_name.slice(0, -12); + } + + node.widgets[0].value += ``; + node.widgets_values[0] = node.widgets[0].value; + } + } + + node._value = value; + }, + get: () => { + return node._value; + } + }); + + // Preventing validation errors from occurring in any situation. + node.widgets[3].serializeValue = () => { return "Select the LoRA to add to the text"; } + } + if(node.comfyClass == "ImpactWildcardProcessor" || node.comfyClass == "ImpactWildcardEncode") { node.widgets[0].inputEl.placeholder = "Wildcard Prompt (User input)"; node.widgets[1].inputEl.placeholder = "Populated Prompt (Will be generated automatically)"; diff --git a/modules/impact/config.py b/modules/impact/config.py index ce0ff33..4d6a53d 100644 --- a/modules/impact/config.py +++ b/modules/impact/config.py @@ -2,7 +2,7 @@ import configparser import os -version = "V3.16" +version = "V3.16.2" dependency_version = 9 diff --git a/modules/impact/impact_pack.py b/modules/impact/impact_pack.py index f5064de..a5d1664 100644 --- a/modules/impact/impact_pack.py +++ b/modules/impact/impact_pack.py @@ -2480,6 +2480,7 @@ class ImpactWildcardEncode: "wildcard_text": ("STRING", {"multiline": True}), "populated_text": ("STRING", {"multiline": True}), "mode": ("BOOLEAN", {"default": True, "label_on": "Populate", "label_off": "Fixed"}), + "Select to add LoRA": (["Select the LoRA to add to the text"] + folder_paths.get_filename_list("loras"), ), }, } @@ -2488,8 +2489,8 @@ class ImpactWildcardEncode: RETURN_TYPES = ("MODEL", "CLIP", "CONDITIONING", ) FUNCTION = "doit" - def doit(self, model, clip, wildcard_text, populated_text, mode): - model, clip, conditioning = impact.wildcards.process_with_loras(populated_text, model, clip) + def doit(self, *args, **kwargs): + model, clip, conditioning = impact.wildcards.process_with_loras(kwargs['populated_text'], kwargs['model'], kwargs['clip']) return (model, clip, conditioning) @@ -2609,44 +2610,6 @@ class KSamplerAdvancedBasicPipe: return (basic_pipe, latent, vae) -from impact.logics import AnyType - -class ImpactLogger: - @classmethod - def INPUT_TYPES(s): - return {"required": { - "data": (AnyType("*"), ""), - }, - "hidden": {"prompt": "PROMPT", "extra_pnginfo": "EXTRA_PNGINFO"}, - } - - CATEGORY = "ImpactPack/Debug" - - OUTPUT_NODE = True - - RETURN_TYPES = () - FUNCTION = "doit" - - def doit(self, data, prompt, extra_pnginfo): - shape = "" - if hasattr(data, "shape"): - shape = f"{data.shape} / " - - print(f"[IMPACT LOGGER]: {shape}{data}") - - print(f" PROMPT: {prompt}") - - # for x in prompt: - # if 'inputs' in x and 'populated_text' in x['inputs']: - # print(f"PROMP: {x['10']['inputs']['populated_text']}") - # - # for x in extra_pnginfo['workflow']['nodes']: - # if x['type'] == 'ImpactWildcardProcessor': - # print(f" WV : {x['widgets_values'][1]}\n") - - return {} - - class ImageBatchToImageList: @classmethod def INPUT_TYPES(s): @@ -2729,3 +2692,55 @@ class StringSelector: selected = lines[select % len(lines)] return (selected, ) + + +from impact.logics import AnyType + +class ImpactLogger: + @classmethod + def INPUT_TYPES(s): + return {"required": { + "data": (AnyType("*"), ""), + }, + "hidden": {"prompt": "PROMPT", "extra_pnginfo": "EXTRA_PNGINFO"}, + } + + CATEGORY = "ImpactPack/Debug" + + OUTPUT_NODE = True + + RETURN_TYPES = () + FUNCTION = "doit" + + def doit(self, data, prompt, extra_pnginfo): + shape = "" + if hasattr(data, "shape"): + shape = f"{data.shape} / " + + print(f"[IMPACT LOGGER]: {shape}{data}") + + print(f" PROMPT: {prompt}") + + # for x in prompt: + # if 'inputs' in x and 'populated_text' in x['inputs']: + # print(f"PROMP: {x['10']['inputs']['populated_text']}") + # + # for x in extra_pnginfo['workflow']['nodes']: + # if x['type'] == 'ImpactWildcardProcessor': + # print(f" WV : {x['widgets_values'][1]}\n") + + return {} + + +class ImpactDummyInput: + @classmethod + def INPUT_TYPES(s): + return {"required": {}} + + CATEGORY = "ImpactPack/Debug" + + RETURN_TYPES = (AnyType("*"),) + FUNCTION = "doit" + + def doit(self): + return ("DUMMY",)