Fix component-only model loading for LTX-Video fine-tunes

- Set pipeline_loaded_successfully=True when component loading succeeds
- Fix indentation for LoRA and offloading code blocks
- Define 'off' variable inside the correct scope
- This fixes loading models like Muinez/ltxvideo-2b-nsfw which are
  fine-tuned transformer weights without a full pipeline
parent 4bdfc1ed
......@@ -8576,6 +8576,7 @@ def main(args):
)
print(f" ✅ Fine-tuned transformer loaded successfully!")
loaded_with_base = True
pipeline_loaded_successfully = True
elif class_name == "AutoencoderKLLTXVideo":
from diffusers import AutoencoderKLLTXVideo
print(f" Loading fine-tuned VAE...")
......@@ -8586,6 +8587,7 @@ def main(args):
)
print(f" ✅ Fine-tuned VAE loaded successfully!")
loaded_with_base = True
pipeline_loaded_successfully = True
except Exception as component_e:
if debug:
print(f" [DEBUG] Component detection failed: {component_e}")
......@@ -8692,16 +8694,19 @@ def main(args):
if components_loaded:
print(f" ✅ Loaded components: {components_loaded}")
loaded_with_base = True
pipeline_loaded_successfully = True
else:
print(f" ⚠️ No components could be loaded from fine-tuned model")
print(f" Using base model: {base_model}")
loaded_with_base = True # Still use base model
pipeline_loaded_successfully = True
except Exception as ft_e:
if debug:
print(f" [DEBUG] Fine-tuned loading failed: {ft_e}")
print(f" Using base model: {base_model}")
loaded_with_base = True
pipeline_loaded_successfully = True
break
except Exception as base_e:
if debug:
......@@ -8717,6 +8722,7 @@ def main(args):
print(f" ✅ Successfully loaded I2V model with DiffusionPipeline")
PipelineClass = DiffusionPipeline
loaded_with_base = True
pipeline_loaded_successfully = True
except Exception as generic_e:
if debug:
print(f" [DEBUG] Generic loader also failed: {generic_e}")
......@@ -8730,7 +8736,7 @@ def main(args):
raise e # Re-raise for non-404 errors
# Apply LoRA if this is a LoRA model
if is_lora and lora_id:
if is_lora and lora_id and pipeline_loaded_successfully:
print(f" Loading LoRA adapter: {lora_id}")
try:
pipe.load_lora_weights(lora_id)
......@@ -8739,10 +8745,13 @@ def main(args):
print(f" ⚠️ LoRA loading failed: {lora_e}")
print(f" Continuing with base model...")
# Apply safety checker and offloading only if pipeline loaded successfully
if pipeline_loaded_successfully:
if args.no_filter and hasattr(pipe, "safety_checker"):
pipe.safety_checker = None
# Re-apply offloading strategy
# Offloading
off = args.offload_strategy
if off == "auto_map":
pipe.enable_model_cpu_offload()
elif off == "sequential":
......
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