SAM3 multi-GPU session as default
Summary: Default to multi-GPUs to avoid OOM. CPU offload seems to not helping as it still need to copy back into memory for tracking ___ overriding_review_checks_triggers_an_audit_and_retroactive_review Oncall Short Name: storytelling_ai_fsx_health Differential Revision: D102039480 fbshipit-source-id: c3540efb984382756ead223f16b66f5d87bbeb0b
This commit is contained in:
committed by
meta-codesync[bot]
parent
7567e8028c
commit
c3a42ff674
@@ -64,6 +64,7 @@ class Sam3BasePredictor:
|
|||||||
getattr(self, "default_output_prob_thresh", 0.5),
|
getattr(self, "default_output_prob_thresh", 0.5),
|
||||||
),
|
),
|
||||||
obj_id=request.get("obj_id", None),
|
obj_id=request.get("obj_id", None),
|
||||||
|
rel_coordinates=request.get("rel_coordinates", True),
|
||||||
)
|
)
|
||||||
elif request_type == "remove_object":
|
elif request_type == "remove_object":
|
||||||
return self.remove_object(
|
return self.remove_object(
|
||||||
@@ -146,6 +147,7 @@ class Sam3BasePredictor:
|
|||||||
clear_old_boxes: bool = True,
|
clear_old_boxes: bool = True,
|
||||||
output_prob_thresh: float = 0.5,
|
output_prob_thresh: float = 0.5,
|
||||||
obj_id: Optional[int] = None,
|
obj_id: Optional[int] = None,
|
||||||
|
rel_coordinates: bool = True,
|
||||||
):
|
):
|
||||||
"""Add text, box and/or point prompt on a specific video frame."""
|
"""Add text, box and/or point prompt on a specific video frame."""
|
||||||
session = self._get_session(session_id)
|
session = self._get_session(session_id)
|
||||||
@@ -175,6 +177,7 @@ class Sam3BasePredictor:
|
|||||||
box_labels=bounding_box_labels,
|
box_labels=bounding_box_labels,
|
||||||
clear_old_boxes=clear_old_boxes,
|
clear_old_boxes=clear_old_boxes,
|
||||||
output_prob_thresh=output_prob_thresh,
|
output_prob_thresh=output_prob_thresh,
|
||||||
|
rel_coordinates=rel_coordinates,
|
||||||
)
|
)
|
||||||
if obj_id is not None:
|
if obj_id is not None:
|
||||||
kwargs["obj_id"] = obj_id
|
kwargs["obj_id"] = obj_id
|
||||||
@@ -187,6 +190,7 @@ class Sam3BasePredictor:
|
|||||||
valid_params = set(sig.parameters.keys())
|
valid_params = set(sig.parameters.keys())
|
||||||
filtered_kwargs = {k: v for k, v in kwargs.items() if k in valid_params}
|
filtered_kwargs = {k: v for k, v in kwargs.items() if k in valid_params}
|
||||||
|
|
||||||
|
with torch.autocast(device_type="cuda", dtype=torch.bfloat16):
|
||||||
frame_idx, outputs = self.model.add_prompt(**filtered_kwargs)
|
frame_idx, outputs = self.model.add_prompt(**filtered_kwargs)
|
||||||
return {"frame_index": frame_idx, "outputs": outputs}
|
return {"frame_index": frame_idx, "outputs": outputs}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user