SAM 2 segments objects in still images and video streams from clicks, boxes, or masks, with checkpoints and predictors for local GPU inference.
Overview
Segment Anything Model 2 (SAM 2) is a foundation model for promptable visual segmentation across images and videos. Still frames are handled like single-frame video, while video mode tracks masklets over time with a transformer design and streaming memory for sequential processing.
Python packages expose image and video predictors: load a checkpoint, provide prompts, and receive masks. Image workflows mirror the original SAM APIs, including automatic mask generation. Video workflows keep per-object state, accept new prompts mid-sequence, and support multi-object tracking with optional compiled paths for faster video object segmentation.
Checkpoints ship in several sizes with published benchmark scores on SA-V, MOSE, and LVOS-style evaluations. Weights download via provided scripts or Hugging Face loaders. Training and fine-tuning code targets custom image or video datasets, and a separate locally deployable web demo stack mirrors the public interactive experience.
Install on GPU hosts with recent Python, PyTorch, and TorchVision releases; Windows users are directed toward WSL with Ubuntu for setup.
Key features
- Click and box prompted masks
- Video masklet propagation
- Automatic image mask generation
- Multiple checkpoint size tiers
- Hugging Face model loading
- Multi-object video tracking state
- Optional full-model compilation
- Custom dataset training support
Use cases
- Interactive image editing masks
- Video object tracking
- Research on segmentation datasets
- Fine-tuning on domain footage
- Locally hosted segmentation demos