📈 GH Trending Explorer 🎲 Surprise me

← all repos

facebookresearch / sam2

git clone https://github.com/facebookresearch/sam2.git 🔥 on GitHub Trending today

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

—
stars, 24h
—
stars, 7 days
+150
stars, 30 days · #1,605
20k
★ total
2.6k
forks · 423 open issues

Star history starts 2026-10-20; the chart appears after the second daily snapshot.

LanguageJupyter Notebook
LicenseApache-2.0
Created2024-07-29 (2y ago)
Last push4mo ago
Watchers115
OwnerOrganization

Seen on GitHub Trending

  • 2026-10-20 — #4 monthly in jupyter-notebook · +150 ★

Links

README excerpt
# SAM 2: Segment Anything in Images and Videos
**AI at Meta, FAIR**
Nikhila Ravi, Valentin Gabeur, Yuan-Ting Hu, Ronghang Hu, Chaitanya Ryali, Tengyu Ma, Haitham Khedr, Roman Rädle, Chloe Rolland, Laura Gustafson, Eric Mintun, Junting Pan, Kalyan Vasudev Alwala, Nicolas Carion, Chao-Yuan Wu, Ross Girshick, Piotr Dollár, Christoph Feichtenhofer
[`Paper`] [`Project`] [`Demo`] [`Dataset`] [`Blog`] [`BibTeX`]
**Segment Anything Model 2 (SAM 2)** is a foundation model towards solving promptable visual segmentation in images and videos. We extend SAM to video by considering images as a video with a single frame. The model design is a simple transformer architecture with streaming memory for real-time video processing. We build a model-in-the-loop data engine, which improves model and data via user interaction, to collect **our SA-V dataset**, the largest video segmentation dataset to date. SAM 2 trained on our data provides strong performance across a wide range of tasks and visual domains.
## Latest updates
**12/11/2024 -- full model compilation for a major VOS speedup and a new `SAM2VideoPredictor` to better handle multi-object tracking**
- We now support `torch.compile` of the entire SAM 2 model on videos, which can be turned on by setting `vos_optimized=True` in `build_sam2_video_predictor`, leading to a major speedup for VOS inference.
- We update the implementation of `SAM2VideoPredictor` to support independent per-object inference, allowing us to relax the assumption of prompting for multi-object tracking and adding new objects after tracking starts.
- See `RELEASE_NOTES.md` for full details.
**09/30/2024 -- SAM 2.1 Developer Suite (new checkpoints, training code, web demo) is released**
- A new suite of improved model checkpoints (denoted as **SAM 2.1**) are released. See Model Description for details.
 * To use the new SAM 2.1 checkpoints, you need the latest model code from this repo. If you have installed an earlier version of this repo, please first uninstall the previous version via `pip uninstall SAM-2`, pull the latest code from this repo (with `git pull`), and then reinstall the repo following Installation below.
- The training (and fine-tuning) code has been released. See `training/README.md` on how to get started.
- The frontend + backend code for the SAM 2 web demo has been released. See `demo/README.md` for details.
## Installation
SAM 2 needs to be installed first before use. The code requires `python>=3.10`, as well as `torch>=2.5.1` and `torchvision>=0.20.1`. Please follow the instructions here to install both PyTorch and TorchVision dependencies. You can install SAM 2 on a GPU machine using:
 [code] 
If you are installing on Windows, it's strongly recommended to use Windows Subsystem for Linux (WSL) with Ubuntu.
To use the SAM 2 predictor and run the example notebooks, `jupyter` and `matplotlib` are required and can be installed by:
 [code] 
Note:
1. It's recommended to create a new Python environment via Anaconda for this insta