Fix Wan2.2 I2V LoRA adapter detection and base model suffix

- Add model ID check for I2V detection (not just tags)
- Add -Diffusers suffix when extracting base model from tags
- Add runtime validation for Wan LoRA base model against tags
parent 410f97e9
......@@ -1254,6 +1254,9 @@ def validate_hf_model(model_id, hf_token=None, debug=False):
for tag in tags:
if tag.startswith("base_model:"):
base_model_from_tags = tag.replace("base_model:", "")
# Add -Diffusers suffix if not present (required for HuggingFace model IDs)
if base_model_from_tags and not base_model_from_tags.endswith("-Diffusers"):
base_model_from_tags = f"{base_model_from_tags}-Diffusers"
if debug:
print(f" [DEBUG] Found base model in tags: {base_model_from_tags}")
break
......@@ -2006,8 +2009,8 @@ def search_hf_models(query, limit=20, hf_token=None):
model_id = m.get("id", "")
tags = m.get("tags", [])
# Determine type
is_i2v = any(t in tags for t in ["image-to-video", "i2v"])
model_name_lower = model_id.lower()
is_i2v = any(t in tags for t in ["image-to-video", "i2v"]) or "i2v" in model_name_lower
is_video = "video" in tags or "text-to-video" in tags
is_image = "text-to-image" in tags
......@@ -8654,15 +8657,22 @@ def main(args):
if is_lora:
lora_id = m_info["id"]
# For Wan LoRA adapters, don't use stored base_model as it may be incorrect
# Instead, always infer from LoRA ID (check for i2v vs t2v)
lora_id_lower = lora_id.lower()
if "wan" in lora_id_lower:
# Skip reading from config - infer from LoRA ID instead
base_model_id = None
else:
# First, try to use stored base_model from config
base_model_id = m_info.get("base_model")
# For Wan LoRA adapters, validate stored base_model against tags
# The stored config may have incorrect base_model (T2V instead of I2V)
if "wan" in lora_id.lower() and base_model_id:
# Check tags for correct base model
tags = m_info.get("tags", [])
tags_str = " ".join(tags).lower() if tags else ""
# If stored base_model is T2V but tags show I2V, we need to fix
if "t2v" in base_model_id.lower() and "i2v" in tags_str:
print(f" ⚠️ Stored base_model appears incorrect (T2V), checking tags...")
base_model_id = None # Force fallback to inference
# Allow manual override via --base-model
if args.base_model:
base_model_id = args.base_model
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment