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:
Arpit Kalla
2026-03-27 10:18:58 -07:00
committed by meta-codesync[bot]
parent 86ed770940
commit 9f22cb976f
79 changed files with 20772 additions and 792 deletions
+3 -3
View File
@@ -243,9 +243,9 @@ def download_sav():
def main():
assert len(sys.argv) > 1, "You have to provide the name of the dataset"
dataset_name = sys.argv[1]
assert dataset_name in annotation_files, (
f"The dataset can be one of {list(annotation_files.keys())}"
)
assert (
dataset_name in annotation_files
), f"The dataset can be one of {list(annotation_files.keys())}"
if dataset_name == "yt1b":
download_youtube()
+3 -3
View File
@@ -68,9 +68,9 @@ def process_image(args):
def main():
assert len(sys.argv) > 1, "You have to provide the name of the dataset"
dataset_name = sys.argv[1]
assert dataset_name in annotation_files, (
f"The dataset can be one of {list(annotation_files.keys())}"
)
assert (
dataset_name in annotation_files
), f"The dataset can be one of {list(annotation_files.keys())}"
all_outputs = []
for file in annotation_files[dataset_name]:
with open(os.path.join(config["path_annotations"], file), "r") as f:
@@ -58,9 +58,9 @@ class YtVideoPrep:
df = self.yt1b_start_end_time_df[
self.yt1b_start_end_time_df.saco_yt1b_id == self.saco_yt1b_id
]
assert len(df) == 1, (
f"Expected exactly 1 row for saco_yt1b_id: {self.saco_yt1b_id}, found {len(df)}"
)
assert (
len(df) == 1
), f"Expected exactly 1 row for saco_yt1b_id: {self.saco_yt1b_id}, found {len(df)}"
id_and_frame_map_row = df.iloc[0]
yt_video_id = (
@@ -82,9 +82,9 @@ class YtVideoPrep:
def download_youtube_video(self):
video_url = f"https://youtube.com/watch?v={self.yt_video_id}"
assert os.path.exists(self.cookies_file), (
f"Cookies file '{self.cookies_file}' not found. Must have it to download videos."
)
assert os.path.exists(
self.cookies_file
), f"Cookies file '{self.cookies_file}' not found. Must have it to download videos."
outtmpl = self.raw_video_path