add flags

This commit is contained in:
2026-06-09 17:59:28 -07:00
parent a808cd2cc7
commit a8a5c448bf
2 changed files with 32 additions and 7 deletions

View File

@@ -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