What do you want to do?
3 use cases
-
Segment an object in an image from a click
Install SAM 2, download checkpoints and get masks for an image from point or box prompts.
View prompt
Using facebookresearch/sam2, install it with `pip install -e .`, download the checkpoints, and write a script that loads SAM2ImagePredictor and saves a mask PNG for the object at a point I give in <my image>.
-
Track an object through a video
Prompt an object on one frame and propagate its mask through the whole video.
View prompt
With facebookresearch/sam2, write a script that uses build_sam2_video_predictor, adds a box prompt on frame 0 of <my video frames folder>, propagates with propagate_in_video, and writes an overlay video.
-
Load SAM 2 from Hugging Face without the checkpoint script
Use from_pretrained to pull facebook/sam2-hiera-large straight from the Hub.
View prompt
Using facebookresearch/sam2, install `pip install huggingface_hub`, load SAM2ImagePredictor.from_pretrained("facebook/sam2-hiera-large") in a notebook, and segment the main object in <my image>.
Quick start with Sam2
- Check you have what it needs: Python 3.10 or newer with torch 2.5.1 and torchvision 0.20.1 or newer; An NVIDIA GPU with CUDA is recommended; Windows users should use WSL with Ubuntu; A model checkpoint from the download script or Hugging Face.
- Open facebookresearch/sam2 on GitHub and read the README and license.
- Run
git clone https://github.com/facebookresearch/sam2.git && cd sam2thenpip install -e . - Download checkpoints with
./download_ckpts.shinside the checkpoints folder - Build a SAM2ImagePredictor from configs/sam2.1/sam2.1_hiera_l.yaml and ./checkpoints/sam2.1_hiera_large.pt
- Call predictor.set_image with your image and predictor.predict with your prompts
These steps come from our top use case, Segment an object in an image from a click, which also has a copy-paste agent prompt.
Use this in your AI agent
Ask your agent
Using the Deduped MCP, get the setup steps for facebookresearch/sam2
Add Deduped to Claude Code once
claude mcp add --transport http deduped https://dedupedai.com/mcp
Every Monday: the 5 hottest repos and exactly how to use them. Free, one email a week, unsubscribe anytime.
Get them freeAbout this repo
- Who it is forResearchers, video editors and vision engineers who need accurate object masks without training a model.
- Why it is hot20k stars, talked about in 2 AI sources we track
- LanguageJupyter Notebook
- Sourcegithub.com/facebookresearch/sam2 ยท Back to Hot repos
Requirements
- Python 3.10 or newer with torch 2.5.1 and torchvision 0.20.1 or newer
- An NVIDIA GPU with CUDA is recommended; Windows users should use WSL with Ubuntu
- A model checkpoint from the download script or Hugging Face
Add this badge to your README
Maintain Sam2? Show readers where to find these use cases.
Markdown
[](https://dedupedai.com/use-cases/facebookresearch-sam2/?utm_source=github&utm_medium=badge&utm_campaign=facebookresearch-sam2)
HTML
<a href="https://dedupedai.com/use-cases/facebookresearch-sam2/?utm_source=github&utm_medium=badge&utm_campaign=facebookresearch-sam2"><img src="https://dedupedai.com/badge/facebookresearch/sam2.svg" alt="Use cases on Deduped" height="20"></a>
A static image, no tracking script. About the badge
Questions about Sam2
What is Sam2?
SAM 2 is Meta FAIR's Segment Anything Model 2, a foundation model for promptable visual segmentation in images and videos. You give it points or boxes and it returns masks, and in video it tracks objects across frames as masklets. The repo includes SAM 2.1 checkpoints, image and video predictors, Hugging Face loading, training code and a web demo. It is an open-source project on GitHub: https://github.com/facebookresearch/sam2.
How do I use Sam2?
Run git clone https://github.com/facebookresearch/sam2.git && cd sam2 then pip install -e; then download checkpoints with ./download_ckpts.sh inside the checkpoints folder; build a SAM2ImagePredictor from configs/sam2.1/sam2.1_hiera_l.yaml and ./checkpoints/sam2.1_hiera_large.pt. The use cases on this page give the full steps and a copy-paste agent prompt for each job.
Who is Sam2 for?
Researchers, video editors and vision engineers who need accurate object masks without training a model.
What can I do with Sam2?
3 use cases so far, for example: Segment an object in an image from a click; Track an object through a video; Load SAM 2 from Hugging Face without the checkpoint script. Each has steps and a copy-paste agent prompt.
What do I need to run Sam2?
Python 3.10 or newer with torch 2.5.1 and torchvision 0.20.1 or newer; An NVIDIA GPU with CUDA is recommended; Windows users should use WSL with Ubuntu; A model checkpoint from the download script or Hugging Face.
What are alternatives to Sam2?
Other hot AI repos in Research: Docling, LightRAG, Ragflow, Markitdown, MinerU.
Is Sam2 safe to run?
Deduped does not own, audit or vouch for it. Read the README and license, run it on your own systems first and review every command before you run it.