From c1aaebec7bfcd72972ed0a1c27b770f92e1ee653 Mon Sep 17 00:00:00 2001 From: Juan Cobos Date: Sat, 6 Dec 2025 12:51:43 +0100 Subject: [PATCH] Avoid redundant superanimal colormap calls and unnecessary output path creation when create_labeled_video=False --- .../pose_estimation_pytorch/modelzoo/inference.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/deeplabcut/pose_estimation_pytorch/modelzoo/inference.py b/deeplabcut/pose_estimation_pytorch/modelzoo/inference.py index fda4f9b91f..24ac0caeb6 100644 --- a/deeplabcut/pose_estimation_pytorch/modelzoo/inference.py +++ b/deeplabcut/pose_estimation_pytorch/modelzoo/inference.py @@ -149,6 +149,10 @@ def _video_inference_superanimal( if not os.path.exists(dest_folder): os.makedirs(dest_folder) + if create_labeled_video: + superanimal_colormaps = get_superanimal_colormaps() + colormap = superanimal_colormaps[superanimal_name] + for video_path in video_paths: print(f"Processing video {video_path}") @@ -199,14 +203,13 @@ def _video_inference_superanimal( with open(output_json, "w") as f: json.dump(predictions, f, cls=NumpyEncoder) - output_video = output_path / f"{output_prefix}_labeled.mp4" - if len(output_suffix) > 0: - output_video = output_video.with_stem(output_video.stem + output_suffix) - - superanimal_colormaps = get_superanimal_colormaps() - colormap = superanimal_colormaps[superanimal_name] if create_labeled_video: + + output_video = output_path / f"{output_prefix}_labeled.mp4" + if len(output_suffix) > 0: + output_video = output_video.with_stem(output_video.stem + output_suffix) + create_video( video_path, output_h5,