Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ Note, you can right-click on a bunch of the rgthree-comfy nodes and select `🛟
> - from the properties, change the `Show Strengths` to choose between showing a single, simple
> strength value (which will be used for both model and clip), or a more advanced view with
> both model and clip strengths being modifiable.
> - Now includes an `lora_info_text` output port that provides a formatted string listing all enabled Loras with their filenames and strengths.
> Example output format:
> ```
> FLUX_test1.safetensors: 0.83
> FLUX_test2.safetensors: 0.46
> FLUX_test3.safetensors: 0.74
> FLUX_test4-000016.safetensors: 0.48
> ```
> </details>


Expand Down
21 changes: 17 additions & 4 deletions py/power_lora_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,15 @@ def INPUT_TYPES(cls): # pylint: disable = invalid-name, missing-function-docstr
"hidden": {},
}

RETURN_TYPES = ("MODEL", "CLIP")
RETURN_NAMES = ("MODEL", "CLIP")
RETURN_TYPES = ("MODEL", "CLIP", "STRING")
RETURN_NAMES = ("MODEL", "CLIP", "lora_info_text")
FUNCTION = "load_loras"

def load_loras(self, model=None, clip=None, **kwargs):
"""Loops over the provided loras in kwargs and applies valid ones."""
lora_info_text = ""
lora_lines = []

for key, value in kwargs.items():
key = key.upper()
if key.startswith('LORA_') and 'on' in value and 'lora' in value and 'strength' in value:
Expand All @@ -55,8 +58,18 @@ def load_loras(self, model=None, clip=None, **kwargs):
lora = get_lora_by_filename(value['lora'], log_node=self.NAME)
if model is not None and lora is not None:
model, clip = LoraLoader().load_lora(model, clip, lora, strength_model, strength_clip)

return (model, clip)

# 收集Lora信息用于输出文本
lora_filename = value['lora']
# 对于大多数情况,使用模型强度作为显示强度
display_strength = strength_model
lora_lines.append(f"{lora_filename}: {display_strength:.2f}")

# 将收集的Lora信息格式化为文本
if lora_lines:
lora_info_text = "\n".join(lora_lines)

return (model, clip, lora_info_text)

@classmethod
def get_enabled_loras_from_prompt_node(cls,
Expand Down