From a126e1c1d791ad3b45009bbedafb89e99ccb54b7 Mon Sep 17 00:00:00 2001 From: Bryce Date: Thu, 23 Nov 2023 12:24:48 -0800 Subject: [PATCH] feature: better error message when file not found --- imaginairy/cli/videogen.py | 33 ++++++++++++++++++--------------- imaginairy/video_sample.py | 3 ++- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/imaginairy/cli/videogen.py b/imaginairy/cli/videogen.py index 38d5dece..1a5700bb 100644 --- a/imaginairy/cli/videogen.py +++ b/imaginairy/cli/videogen.py @@ -74,18 +74,21 @@ def videogen_cmd( configure_logging() output_fps = output_fps or fps - - generate_video( - input_path=start_image, - num_frames=num_frames, - num_steps=steps, - model_name=model, - fps_id=fps, - output_fps=output_fps, - motion_bucket_id=motion_amount, - cond_aug=cond_aug, - seed=seed, - decoding_t=decoding_t, - output_folder=output_folder, - repetitions=repeats, - ) + try: + generate_video( + input_path=start_image, + num_frames=num_frames, + num_steps=steps, + model_name=model, + fps_id=fps, + output_fps=output_fps, + motion_bucket_id=motion_amount, + cond_aug=cond_aug, + seed=seed, + decoding_t=decoding_t, + output_folder=output_folder, + repetitions=repeats, + ) + except FileNotFoundError as e: + logger.error(str(e)) + exit(1) diff --git a/imaginairy/video_sample.py b/imaginairy/video_sample.py index 9fbd5aeb..c7a363b8 100644 --- a/imaginairy/video_sample.py +++ b/imaginairy/video_sample.py @@ -96,7 +96,8 @@ def generate_video( if len(all_img_paths) == 0: raise ValueError("Folder does not contain any images.") else: - raise ValueError + msg = f"Could not find file or folder at {input_path}" + raise FileNotFoundError(msg) expected_size = (1024, 576) for _ in range(repetitions):