Fix pipeline component mismatch fallback and indentation

- Add fallback mechanism for models with incorrect model_index.json
- Detect pipeline class from model ID patterns when component mismatch occurs
- Fix indentation error in auto mode retry logic block
- Properly handle Wan2.2-I2V models with misconfigured pipeline class
parent 4668132a
Pipeline #230 canceled with stages
......@@ -3518,6 +3518,57 @@ def main(args):
print(f" [DEBUG] Response: {e.response}")
print()
# Check if this is a pipeline component mismatch error
# This happens when the model_index.json has the wrong _class_name
is_component_mismatch = "expected" in error_str and "but only" in error_str and "were passed" in error_str
if is_component_mismatch:
# Try to re-detect the correct pipeline class from model ID pattern
detected_class = None
model_id_lower = model_id_to_load.lower()
# Force detection based on model ID patterns (most reliable for misconfigured models)
if "wan2.1" in model_id_lower or "wan2.2" in model_id_lower or "wan2" in model_id_lower:
detected_class = "WanPipeline"
elif "svd" in model_id_lower or "stable-video-diffusion" in model_id_lower:
detected_class = "StableVideoDiffusionPipeline"
elif "ltx" in model_id_lower:
detected_class = "LTXVideoPipeline"
elif "mochi" in model_id_lower:
detected_class = "MochiPipeline"
elif "cogvideo" in model_id_lower:
detected_class = "CogVideoXPipeline"
elif "flux" in model_id_lower:
detected_class = "FluxPipeline"
if detected_class and detected_class != m_info["class"]:
print(f"\n⚠️ Pipeline component mismatch detected!")
print(f" Configured class: {m_info['class']}")
print(f" Detected class: {detected_class}")
print(f" The model's model_index.json may have an incorrect _class_name.")
print(f" Retrying with detected pipeline class: {detected_class}")
# Get the correct pipeline class
CorrectPipelineClass = get_pipeline_class(detected_class)
if CorrectPipelineClass:
try:
pipe = CorrectPipelineClass.from_pretrained(model_id_to_load, **pipe_kwargs)
# Success! Update the model info for future runs
print(f" ✅ Successfully loaded with {detected_class}")
# Continue with the loaded pipeline
timing.end_step() # model_loading
# Update PipelineClass for the rest of the code
PipelineClass = CorrectPipelineClass
# Skip to after the error handling
goto_after_loading = True
except Exception as retry_e:
print(f" ❌ Retry with {detected_class} also failed: {retry_e}")
# Continue with normal error handling
is_component_mismatch = False # Don't retry again below
error_str = str(retry_e)
# If we successfully loaded with the corrected pipeline, skip error handling
if not locals().get('goto_after_loading', False):
# Check if we should retry with an alternative model (auto mode)
# This applies to ALL error types - we try alternatives before giving up
if getattr(args, '_auto_mode', False):
......
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