From fed94a861eb0430ad65d13c925cc323ee9d1da2c Mon Sep 17 00:00:00 2001 From: Test User Date: Thu, 19 Feb 2026 03:04:39 +0000 Subject: [PATCH] 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 --- inference/cli_demo.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/inference/cli_demo.py b/inference/cli_demo.py index 2e28165..9cfc211 100644 --- a/inference/cli_demo.py +++ b/inference/cli_demo.py @@ -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(