Add handling for missing VAE files

When a model has a VAE configured but the VAE files don't exist in
the repository, try loading with the default VAE instead.
parent 8b05676e
...@@ -8253,6 +8253,25 @@ def main(args): ...@@ -8253,6 +8253,25 @@ def main(args):
# Some models have files in subdirectories (e.g., diffusers/) or use different structures # Some models have files in subdirectories (e.g., diffusers/) or use different structures
is_404_error = "404" in error_str or "Entry Not Found" in error_str or "not found" in error_str.lower() is_404_error = "404" in error_str or "Entry Not Found" in error_str or "not found" in error_str.lower()
# Check if this is a VAE file not found error
is_vae_error = "diffusion_pytorch_model" in error_str and "vae" in error_str.lower()
if is_vae_error:
print(f"\n⚠️ VAE file not found in model repository")
print(f" Attempting to load without custom VAE (using default)...")
# Try loading with default VAE by removing any custom VAE
vae_pipe_kwargs = pipe_kwargs.copy()
if "vae" in vae_pipe_kwargs:
del vae_pipe_kwargs["vae"]
try:
pipe = PipelineClass.from_pretrained(model_id_to_load, **vae_pipe_kwargs)
print(f" ✅ Successfully loaded with default VAE")
pipeline_loaded_successfully = True
except Exception as vae_e:
print(f" ❌ Also failed with default VAE: {vae_e}")
error_str = str(vae_e)
is_404_error = "404" in error_str or "Entry Not Found" in error_str or "not found" in error_str.lower()
if is_404_error and "model_index.json" in error_str: if is_404_error and "model_index.json" in error_str:
print(f"\n⚠️ model_index.json not found at root level") print(f"\n⚠️ model_index.json not found at root level")
print(f" Attempting alternative loading strategies...") print(f" Attempting alternative loading strategies...")
......
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