From fb7614414c8178385bbd617ca5935a158e37eb48 Mon Sep 17 00:00:00 2001 From: Shanoah Alkire Date: Sun, 2 Nov 2025 18:55:55 -0800 Subject: [PATCH] Fix bug where it would apply each lora to the base model and clip, not the one just modified. --- nodes/loader.py | 3 +++ utils/helpers_graph.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/nodes/loader.py b/nodes/loader.py index a8d22d2..eb45bd7 100644 --- a/nodes/loader.py +++ b/nodes/loader.py @@ -402,11 +402,13 @@ class Sage_ModelLoraStackLoader(Sage_LoadModelFromInfo): # If there is one lora, it will be a list with one tuple. if lora_stack is not None and len(lora_stack) == 1: + print("Unwrapping single-item lora_stack") lora_stack = lora_stack[0] # If lora_stack was [None], it will now be None. if lora_stack is not None and len(lora_stack) > 0: if len(lora_stack) == 1 and isinstance(lora_stack[0], list): + print("Unwrapping single-item lora_stack inside lora_stack") lora_stack = lora_stack[0] logging.info(f"Applying LoRA stack: {lora_stack}") @@ -416,6 +418,7 @@ class Sage_ModelLoraStackLoader(Sage_LoadModelFromInfo): unet_out, clip_out = create_lora_nodes_v2(graph, unet_out, clip_out, lora_stack) keywords = get_lora_stack_keywords(lora_stack) + print(f"Graph after LoRA application: {graph}") return { "result": (unet_out, clip_out, vae_out, lora_stack, keywords), diff --git a/utils/helpers_graph.py b/utils/helpers_graph.py index a084242..239b0f8 100644 --- a/utils/helpers_graph.py +++ b/utils/helpers_graph.py @@ -112,7 +112,7 @@ def create_lora_nodes_v2(graph: GraphBuilder, unet_in, clip_in, lora_stack=None) return unet_out, clip_out for lora in lora_stack: - lora_node = graph.node("LoraLoader", model=unet_in, clip=clip_in, lora_name=lora[0], strength_model=lora[1], strength_clip=lora[2]) + lora_node = graph.node("LoraLoader", model=unet_out, clip=clip_out, lora_name=lora[0], strength_model=lora[1], strength_clip=lora[2]) unet_out = lora_node.out(0) clip_out = lora_node.out(1) return unet_out, clip_out