SAM 3.1 Release (#503)
Summary: SAM 3.1 multiplex video tracking for the OSS sam3 repository. Features: - Multiplex architecture: batch N objects into fixed-capacity buckets for efficient multi-object tracking (16 objects per bucket) - Unified API: build_sam3_predictor(version="sam3.1") with auto-download from HuggingFace (facebook/sam3.1) - Flash Attention 3, torch.compile support (~31 FPS compiled on H100) - Text prompts, point prompts, box prompts, object removal, refinement - Clean inheritance: Sam3MultiplexBase extends Sam3VideoBase - Shared base predictor (Sam3BasePredictor) for both SAM3 and SAM3.1 Performance (H100, 5 objects, compiled): - SAM 3.1: ~31 FPS - Memory: ~17.7 GB Usage: from sam3 import build_sam3_predictor predictor = build_sam3_predictor() # auto-downloads SAM 3.1 from HF Pull Request resolved: https://github.com/facebookresearch/sam3/pull/503 Reviewed By: josephgreer Differential Revision: D98500763 Pulled By: arpitkalla fbshipit-source-id: e2b74568f24bb4ecfb3144a4e8ec559aae6db5e8
This commit is contained in:
committed by
meta-codesync[bot]
parent
86ed770940
commit
9f22cb976f
@@ -324,9 +324,7 @@ class IABCEMdetr(LossWithWeights):
|
||||
if num_det_queries is not None:
|
||||
logging.warning("note: it's not needed to set num_det_queries anymore")
|
||||
if self.use_separate_loss_for_det_and_trk:
|
||||
assert not self.weak_loss, (
|
||||
"Do not use weak_loss in this case -- set separate loss for detection and tracking queries instead"
|
||||
)
|
||||
assert not self.weak_loss, "Do not use weak_loss in this case -- set separate loss for detection and tracking queries instead"
|
||||
self.det_exhaustive_loss_scale_pos = det_exhaustive_loss_scale_pos
|
||||
self.det_exhaustive_loss_scale_neg = det_exhaustive_loss_scale_neg
|
||||
self.det_non_exhaustive_loss_scale_pos = det_non_exhaustive_loss_scale_pos
|
||||
@@ -341,9 +339,7 @@ class IABCEMdetr(LossWithWeights):
|
||||
and det_non_exhaustive_loss_scale_neg == 1.0
|
||||
and trk_loss_scale_pos == 1.0
|
||||
and trk_loss_scale_neg == 1.0
|
||||
), (
|
||||
"If not using separate loss for detection and tracking queries, separate detection and tracking loss scales should all be 1.0"
|
||||
)
|
||||
), "If not using separate loss for detection and tracking queries, separate detection and tracking loss scales should all be 1.0"
|
||||
|
||||
def get_loss(self, outputs, targets, indices, num_boxes):
|
||||
assert len(outputs["pred_logits"].shape) > 2, "Incorrect predicted logits shape"
|
||||
@@ -444,9 +440,7 @@ class IABCEMdetr(LossWithWeights):
|
||||
pass
|
||||
|
||||
if self.weak_loss:
|
||||
assert not self.use_separate_loss_for_det_and_trk, (
|
||||
"Do not use weak_loss in this case -- set separate loss for detection and tracking queries instead"
|
||||
)
|
||||
assert not self.use_separate_loss_for_det_and_trk, "Do not use weak_loss in this case -- set separate loss for detection and tracking queries instead"
|
||||
|
||||
# nullify the negative loss for the non-exhaustive classes
|
||||
assert loss_bce.shape[0] == targets["is_exhaustive"].shape[0]
|
||||
@@ -500,9 +494,9 @@ class IABCEMdetr(LossWithWeights):
|
||||
loss_bce = loss_bce.mean()
|
||||
else:
|
||||
assert isinstance(self.pad_n_queries, int)
|
||||
assert loss_bce.size(1) < self.pad_n_queries, (
|
||||
f"The number of predictions is more than the expected total after padding. Got {loss_bce.size(1)} predictions."
|
||||
)
|
||||
assert (
|
||||
loss_bce.size(1) < self.pad_n_queries
|
||||
), f"The number of predictions is more than the expected total after padding. Got {loss_bce.size(1)} predictions."
|
||||
loss_bce = loss_bce.sum() / (self.pad_n_queries * loss_bce.size(0))
|
||||
|
||||
bce_f1 = torchmetrics.functional.f1_score(
|
||||
|
||||
Reference in New Issue
Block a user