fix: Add graceful fallback for unknown models in RESOLUTION_MAP

Wraps RESOLUTION_MAP lookup in try/except to handle local model paths
or unrecognized model names. Provides helpful error message listing
valid model names and falls back to default 480x720 resolution.

Fixes KeyError when using local paths like ./local_models/CogVideoX-5B
This commit is contained in:
Test User 2026-02-19 03:04:39 +00:00
parent 7a1af71545
commit fed94a861e

View File

@ -96,7 +96,17 @@ def generate_video(
video = None
model_name = model_path.split("/")[-1].lower()
desired_resolution = RESOLUTION_MAP[model_name]
try:
desired_resolution = RESOLUTION_MAP[model_name]
except KeyError:
valid_models = ", ".join(RESOLUTION_MAP.keys())
default_resolution = (480, 720)
logging.warning(
f"\033[1;33mModel '{model_name}' not found in resolution map. "
f"Valid models: {valid_models}. "
f"Falling back to default resolution {default_resolution}.\033[0m"
)
desired_resolution = default_resolution
if width is None or height is None:
height, width = desired_resolution
logging.info(