add flags
This commit is contained in:
@@ -18,6 +18,17 @@ except ImportError:
|
||||
IMAGE_EXTS = {".png", ".jpg", ".jpeg", ".webp"}
|
||||
|
||||
|
||||
def is_lora_connected(node_id, data):
|
||||
"""Check if a LoRA node's output is consumed by any downstream node."""
|
||||
for nid, node in data.items():
|
||||
if nid == node_id:
|
||||
continue
|
||||
for val in node.get("inputs", {}).values():
|
||||
if isinstance(val, list) and len(val) == 2 and str(val[0]) == str(node_id):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def extract_ai_meta(filepath):
|
||||
"""Return (model, loras) or (None, []) if no ComfyUI metadata found."""
|
||||
try:
|
||||
@@ -36,7 +47,7 @@ def extract_ai_meta(filepath):
|
||||
model = None
|
||||
loras = []
|
||||
|
||||
for node in data.values():
|
||||
for nid, node in data.items():
|
||||
cls = node.get("class_type", "")
|
||||
inputs = node.get("inputs", {})
|
||||
|
||||
@@ -48,7 +59,9 @@ def extract_ai_meta(filepath):
|
||||
if "lora" in cls.lower():
|
||||
lora = inputs.get("lora_name", "")
|
||||
if lora:
|
||||
loras.append(lora.rsplit(".", 1)[0])
|
||||
# Only include LoRAs whose output is actually consumed
|
||||
if is_lora_connected(nid, data):
|
||||
loras.append(lora.rsplit(".", 1)[0])
|
||||
|
||||
loras.sort()
|
||||
return model, loras
|
||||
|
||||
Reference in New Issue
Block a user