Skip to content

Commit

Permalink
patch for the case of offload_state_to_cpu=True in the new `SAM2Vid…
Browse files Browse the repository at this point in the history
…eoPredictor`

This PR adds a pathc for the case of `offload_state_to_cpu=True` where `pred_masks` might have been offload to CPU device (close #489)
  • Loading branch information
ronghanghu committed Dec 12, 2024
1 parent 393ae33 commit 6451b74
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sam2/sam2_video_predictor.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,8 @@ def propagate_in_video(
if frame_idx in obj_output_dict["cond_frame_outputs"]:
storage_key = "cond_frame_outputs"
current_out = obj_output_dict[storage_key][frame_idx]
pred_masks = current_out["pred_masks"]
device = inference_state["device"]
pred_masks = current_out["pred_masks"].to(device, non_blocking=True)
if self.clear_non_cond_mem_around_input:
# clear non-conditioning memory of the surrounding frames
self._clear_obj_non_cond_mem_around_input(
Expand Down

0 comments on commit 6451b74

Please sign in to comment.