fixed sam-2 API compatibility in video_predictor.py by Initializing missing frames_tracked_per_obj dictionary in inference state

This commit is contained in:
Ishaan Gupta
2025-09-20 05:16:49 +05:30
parent a64d5b25af
commit 2677beaaf5
@@ -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