Include entire sam3 package instead of just sam3 and sam3.model (#327)
Summary: there are several imports within the
sam3.modelpackage that reference other packages withinsam3other thansam3andsam3.model(for example here). This fixes the package structure so that you canpip installthe package andimport sam3Pull Request resolved: https://github.com/facebookresearch/sam3/pull/327
Reviewed By: haithamkhedr
Differential Revision: D88950127
Pulled By: lematt1991
fbshipit-source-id: 3554512d304ccdf679a9af8606bbfe1f7f2a1cfb
SAM 3: Segment Anything with Concepts
Meta Superintelligence Labs
Nicolas Carion*, Laura Gustafson*, Yuan-Ting Hu*, Shoubhik Debnath*, Ronghang Hu*, Didac Suris*, Chaitanya Ryali*, Kalyan Vasudev Alwala*, Haitham Khedr*, Andrew Huang, Jie Lei, Tengyu Ma, Baishan Guo, Arpit Kalla, Markus Marks, Joseph Greer, Meng Wang, Peize Sun, Roman Rädle, Triantafyllos Afouras, Effrosyni Mavroudi, Katherine Xu°, Tsung-Han Wu°, Yu Zhou°, Liliane Momeni°, Rishi Hazra°, Shuangrui Ding°, Sagar Vaze°, Francois Porcher°, Feng Li°, Siyuan Li°, Aishwarya Kamath°, Ho Kei Cheng°, Piotr Dollar†, Nikhila Ravi†, Kate Saenko†, Pengchuan Zhang†, Christoph Feichtenhofer†
* core contributor, ° intern, † project lead, order is random within groups
[
Paper] [Project] [Demo] [Blog] [BibTeX]This breakthrough is driven by an innovative data engine that has automatically annotated over 4 million unique concepts, creating the largest high-quality open-vocabulary segmentation dataset to date. In addition, SAM 3 introduces a new model architecture featuring a presence token that improves discrimination between closely related text prompts (e.g., “a player in white” vs. “a player in red”), as well as a decoupled detector–tracker design that minimizes task interference and scales efficiently with data.
Installation
Prerequisites
Getting Started
⚠️ Before using SAM 3, please request access to the checkpoints on the SAM 3 Hugging Face repo. Once accepted, you need to be authenticated to download the checkpoints. You can do this by running the following steps (e.g.
hf auth loginafter generating an access token.)Basic Usage
Examples
The
examplesdirectory contains notebooks demonstrating how to use SAM3 with various types of prompts:sam3_image_predictor_example.ipynb: Demonstrates how to prompt SAM 3 with text and visual box prompts on images.sam3_video_predictor_example.ipynb: Demonstrates how to prompt SAM 3 with text prompts on videos, and doing further interactive refinements with points.sam3_image_batched_inference.ipynb: Demonstrates how to run batched inference with SAM 3 on images.sam3_agent.ipynb: Demonsterates the use of SAM 3 Agent to segment complex text prompt on images.saco_gold_silver_vis_example.ipynb: Shows a few examples from SA-Co image evaluation set.saco_veval_vis_example.ipynb: Shows a few examples from SA-Co video evaluation set.There are additional notebooks in the examples directory that demonstrate how to use SAM 3 for interactive instance segmentation in images and videos (SAM 1/2 tasks), or as a tool for an MLLM, and how to run evaluations on the SA-Co dataset.
To run the Jupyter notebook examples:
Model
SAM 3 consists of a detector and a tracker that share a vision encoder. It has 848M parameters. The detector is a DETR-based model conditioned on text, geometry, and image exemplars. The tracker inherits the SAM 2 transformer encoder-decoder architecture, supporting video segmentation and interactive refinement.
Image Results
* Partially trained on LVIS, APo refers to COCO-O accuracy
Video Results
SA-Co Dataset
We release 2 image benchmarks, SA-Co/Gold and SA-Co/Silver, and a video benchmark SA-Co/VEval. The datasets contain images (or videos) with annotated noun phrases. Each image/video and noun phrase pair is annotated with instance masks and unique IDs of each object matching the phrase. Phrases that have no matching objects (negative prompts) have no masks, shown in red font in the figure. See the linked READMEs for more details on how to download and run evaluations on the datasets.
Development
To set up the development environment:
To format the code:
Contributing
See contributing and the code of conduct.
License
This project is licensed under the SAM License - see the LICENSE file for details.
Acknowledgements
We would like to thank the following people for their contributions to the SAM 3 project: Alex He, Alexander Kirillov, Alyssa Newcomb, Ana Paula Kirschner Mofarrej, Andrea Madotto, Andrew Westbury, Ashley Gabriel, Azita Shokpour, Ben Samples, Bernie Huang, Carleigh Wood, Ching-Feng Yeh, Christian Puhrsch, Claudette Ward, Daniel Bolya, Daniel Li, Facundo Figueroa, Fazila Vhora, George Orlin, Hanzi Mao, Helen Klein, Hu Xu, Ida Cheng, Jake Kinney, Jiale Zhi, Jo Sampaio, Joel Schlosser, Justin Johnson, Kai Brown, Karen Bergan, Karla Martucci, Kenny Lehmann, Maddie Mintz, Mallika Malhotra, Matt Ward, Michelle Chan, Michelle Restrepo, Miranda Hartley, Muhammad Maaz, Nisha Deo, Peter Park, Phillip Thomas, Raghu Nayani, Rene Martinez Doehner, Robbie Adkins, Ross Girshik, Sasha Mitts, Shashank Jain, Spencer Whitehead, Ty Toledano, Valentin Gabeur, Vincent Cho, Vivian Lee, William Ngan, Xuehai He, Yael Yungster, Ziqi Pang, Ziyi Dou, Zoe Quake.
Citing SAM 3
If you use SAM 3 or the SA-Co dataset in your research, please use the following BibTeX entry.