From 2677beaaf508dc2251dcf5056b0af1ef007b7623 Mon Sep 17 00:00:00 2001 From: Ishaan Gupta Date: Sat, 20 Sep 2025 05:16:49 +0530 Subject: [PATCH] fixed sam-2 API compatibility in video_predictor.py by Initializing missing frames_tracked_per_obj dictionary in inference state --- wan/modules/animate/preprocess/video_predictor.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/wan/modules/animate/preprocess/video_predictor.py b/wan/modules/animate/preprocess/video_predictor.py index 016d50d..01b9ff4 100644 --- a/wan/modules/animate/preprocess/video_predictor.py +++ b/wan/modules/animate/preprocess/video_predictor.py @@ -152,6 +152,10 @@ class SAM2VideoPredictor(_SAM2VideoPredictor): # metadata for each tracking frame (e.g. which direction it's tracked) inference_state["tracking_has_started"] = False inference_state["frames_already_tracked"] = {} + + # resolves KeyError: 'frames_tracked_per_obj' when using newer SAM-2 versions for running preprocessing in 'replacement mode' + inference_state["frames_tracked_per_obj"] = {} + # Warm up the visual backbone and cache the image feature on frame 0 self._get_image_feature(inference_state, frame_idx=0, batch_size=1) return inference_state \ No newline at end of file