Fix bug where it would apply each lora to the base model and clip, not the one just modified.
This commit is contained in:
@@ -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),
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user