Skip to content
 
 

Repository files navigation

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]

SAM 3 architecture SAM 3 is a unified foundation model for promptable segmentation in images and videos. It can detect, segment, and track objects using text or visual prompts such as points, boxes, and masks. Compared to its predecessor SAM 2, SAM 3 introduces the ability to exhaustively segment all instances of an open-vocabulary concept specified by a short text phrase or exemplars. Unlike prior work, SAM 3 can handle a vastly larger set of open-vocabulary prompts. It achieves 75-80% of human performance on our new SA-CO benchmark which contains 270K unique concepts, over 50 times more than existing benchmarks.

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.

Latest updates

03/27/2026 -- SAM 3.1 Object Multiplex is released. It introduces a shared-memory approach for joint multi-object tracking that is significantly faster without sacrificing accuracy.

  • A new suite of improved model checkpoints (denoted as SAM 3.1) are released on Hugging Face. See RELEASE_SAM3p1.md for full details.
    • To use the new SAM 3.1 checkpoints, you need the latest model code from this repo. If you have installed an earlier version of this repo, pull the latest code from this repo (with git pull), and then reinstall the repo following Installation below.

Installation

Prerequisites

  • Python 3.12 or higher
  • PyTorch 2.7 or higher
  • CUDA-compatible GPU with CUDA 12.6 or higher
  1. Install uv and Python 3.12:
uv python install 3.12
  1. Clone the repository:
git clone https://github.com/facebookresearch/sam3.git
cd sam3
  1. Create the local environment and install the package:
uv sync

The uv project configuration installs torch==2.10.0 and torchvision from the PyTorch CUDA 12.8 wheel index used by the previous pip instructions.

  1. Install additional dependencies for example notebooks or development:
# For running example notebooks
uv sync --extra notebooks

# For development
uv sync --extra train --extra dev
  1. Optional dependencies for faster inference
uv sync --extra fast-inference

The fast-inference extra includes cc-torch, which builds a CUDA extension locally and requires the CUDA toolkit compiler (nvcc) to be available on PATH. If nvcc is not installed, the cc-torch build will fail during uv sync.

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 login after generating an access token.)

Basic Usage

import torch
#################################### For Image ####################################
from PIL import Image
from sam3.model_builder import build_sam3_image_model
from sam3.model.sam3_image_processor import Sam3Processor
# Load the model
model = build_sam3_image_model()
processor = Sam3Processor(model)
# Load an image
image = Image.open("<YOUR_IMAGE_PATH.jpg>")
inference_state = processor.set_image(image)
# Prompt the model with text
output = processor.set_text_prompt(state=inference_state, prompt="<YOUR_TEXT_PROMPT>")

# Get the masks, bounding boxes, and scores
masks, boxes, scores = output["masks"], output["boxes"], output["scores"]

#################################### For Video ####################################

from sam3.model_builder import build_sam3_video_predictor

video_predictor = build_sam3_video_predictor()
video_path = "<YOUR_VIDEO_PATH>" # a JPEG folder or an MP4 video file
# Start a session
response = video_predictor.handle_request(
    request=dict(
        type="start_session",
        resource_path=video_path,
    )
)
response = video_predictor.handle_request(
    request=dict(
        type="add_prompt",
        session_id=response["session_id"],
        frame_index=0, # Arbitrary frame index
        text="<YOUR_TEXT_PROMPT>",
    )
)
output = response["outputs"]

Local Flask API

The repository includes a minimal Flask server for image inference. Start it with:

uv run serve.py

Send requests to POST /predict as multipart/form-data with an image file and a prompts JSON object. The image embedding is computed once, then each keyed prompt entry is applied independently and returned under the same key.

curl -X POST http://localhost:8000/predict \
  -F image=@image.jpg \
  -F prompts='{
    "car": {"text": "red car"},
    "wheel": {"text": "wheel", "bbox": [120, 80, 60, 45], "bbox_format": "xywh"}
  }'

Each prompts entry may include a text prompt (text, or prompt) and/or a geometric box prompt using bbox, geometric_prompt, or geometric. Box prompts are JSON arrays of four numbers. The default format is xywh in image pixel coordinates; set bbox_format or geometric_format to xyxy or cxcywh when needed.

curl -X POST http://localhost:8000/predict \
  -F image=@image.jpg \
  -F prompts='{
    "same_kind": {"prompt": "same kind of object", "geometric": [120, 80, 180, 125], "geometric_format": "xyxy"}
  }' \
  -F score_threshold=0.25

The response contains image_width, image_height, and a results object keyed like the request. Optionally pass score_threshold to filter lower-confidence predictions.

Examples

The examples directory contains notebooks demonstrating how to use SAM3 with various types of prompts:

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:

# Make sure you have the notebooks dependencies installed
uv sync --extra notebooks

# Start Jupyter notebook
jupyter notebook examples/sam3_image_predictor_example.ipynb

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

Model Instance Segmentation Box Detection
LVIS SA-Co/Gold LVIS COCO SA-Co/Gold
cgF1 AP cgF1 cgF1 AP AP APo cgF1
Human - - 72.8 - - - - 74.0
OWLv2* 29.3 43.4 24.6 30.2 45.5 46.1 23.9 24.5
DINO-X - 38.5 21.3 - 52.4 56.0 - 22.5
Gemini 2.5 13.4 - 13.0 16.1 - - - 14.4
SAM 3 37.2 48.5 54.1 40.6 53.6 56.4 55.7 55.7

* Partially trained on LVIS, APo refers to COCO-O accuracy

Video Results

Model SA-V test YT-Temporal-1B test SmartGlasses test LVVIS test BURST test
cgF1 pHOTA cgF1 pHOTA cgF1 pHOTA mAP HOTA
Human 53.1 70.5 71.2 78.4 58.5 72.3 - -
SAM 3 30.3 58.0 50.8 69.9 36.4 63.6 36.3 44.5

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.

SA-Co dataset

Development

To set up the development environment:

uv sync --extra dev --extra train

To format the code:

ufmt format .

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.

@misc{carion2025sam3segmentconcepts,
      title={SAM 3: Segment Anything with Concepts},
      author={Nicolas Carion and Laura Gustafson and Yuan-Ting Hu and Shoubhik Debnath and Ronghang Hu and Didac Suris and Chaitanya Ryali and Kalyan Vasudev Alwala and Haitham Khedr and Andrew Huang and Jie Lei and Tengyu Ma and Baishan Guo and Arpit Kalla and Markus Marks and Joseph Greer and Meng Wang and Peize Sun and Roman Rädle and Triantafyllos Afouras and Effrosyni Mavroudi and Katherine Xu and Tsung-Han Wu and Yu Zhou and Liliane Momeni and Rishi Hazra and Shuangrui Ding and Sagar Vaze and Francois Porcher and Feng Li and Siyuan Li and Aishwarya Kamath and Ho Kei Cheng and Piotr Dollár and Nikhila Ravi and Kate Saenko and Pengchuan Zhang and Christoph Feichtenhofer},
      year={2025},
      eprint={2511.16719},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2511.16719},
}

About

The repository provides code for running inference and finetuning with the Meta Segment Anything Model 3 (SAM 3), links for downloading the trained model checkpoints, and example notebooks that show how to use the model.

Resources

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages