TL;DR
TinySAM 2 is an ultra-efficient video segmentation model designed for edge deployment, achieving 90% of SAM 2.1's performance while using just 7% of the memory tokens and 3% of the training data. By introducing joint spatiotemporal token compression and a memory quality management mechanism, it slashes computational overhead to enable real-time, on-device tracking.
What Problem Does This Paper Address?
Meta’s Segment Anything Model 2 (SAM 2) revolutionized video object segmentation and tracking through its innovative memory bank mechanism. However, this power comes at a massive computational cost. SAM 2 relies on a heavy image encoder, and its memory attention module performs cross-attention over historical frames, resulting in token lengths that hover around 30,000.
This creates a massive computational bottleneck during inference, making real-time deployment on edge devices (like smartphones or robotics) nearly impossible. Furthermore, training SAM 2 from scratch demands an immense amount of resources—requiring 256 A100 GPUs running for over 100 hours. TinySAM 2 tackles these efficiency and training barriers head-on.
Methods
The authors introduce three core optimizations to transform SAM 2 into a lightweight, real-time model:
- Lightweight Image Encoder: The default heavy Hiera encoder is replaced with RepViT, a mobile-friendly CNN architecture. This single change reduces the image encoder parameters to just 1/5 of the original Hiera-Tiny baseline.
- Spatial Memory Compression: To reduce intra-frame redundancy, TinySAM 2 applies simple average pooling (using a $2 \times 2$ sliding window) to features before they enter the memory bank. This effectively reduces the spatial token count per frame by 4x while preserving essential geometric structures.
- Temporal Memory Compression: Inspired by video compression frameworks (like I-frames and P-frames), the model treats the ground-truth frame as an anchor and compresses subsequent "motion frames." It computes the cosine similarity between adjacent frames; tokens with the lowest similarity—meaning they contain the most novel motion information—are prioritized and selected globally via a Top-$n$ strategy.
- Memory Quality Management: Instead of blindly storing every historical frame, TinySAM 2 filters the memory bank. Frames are excluded if the target object is absent or if the predicted mask confidence (Intersection over Union, or IoU) falls below a threshold ($\theta = 0.5$). This prevents the memory from being polluted during brief occlusions.
Datasets
The model was trained and evaluated using a mix of standard video and image segmentation datasets:
- SA-V: The large-scale video dataset introduced with SAM 2, utilizing its validation and test sets to evaluate challenging scenarios like fast motion and complex occlusions.
- DAVIS (2017 val): A standard benchmark for video object segmentation.
- YTVOS (2019 val): YouTube Video Object Segmentation dataset.
- SA-1B: The authors used a tiny 0.5% subset of this massive image dataset for pre-training, drastically reducing data requirements.
Key Insights and Ideas
- Motion Carries the Message: In temporal compression, the intuition is counter-intuitive but highly effective: discard the highly similar tokens. Backgrounds and static objects remain identical across frames, so tracking models only need to remember the tokens that change significantly to capture object motion.
- Quality Over Continuity: Existing models often suffer from error accumulation because they continuously update their memory banks even when an object is occluded. Filtering out low-confidence frames maintains a clean, diverse representation of the target's appearance.
- Pooling is Enough: While complex learned transformations (like transformers or convolutions) can compress spatial features, simple average pooling yields better segmentation accuracy ($J\&F$ scores) with zero parameter overhead.
Key Results
TinySAM 2 delivers a remarkable balance of speed, size, and accuracy:
- Performance: It achieves an average $J\&F$ score of 73.8 across benchmarks, retaining 90% of SAM 2.1's accuracy (82.1).
- Efficiency: It cuts total model parameters by 55% (17.5M vs. 38.9M) and slashes memory token length by 93%.
- Speed: TinySAM 2 runs at 25.6 FPS on a single V100 GPU, making it truly real-time and outperforming competing lightweight models like SAM-I2V by nearly 4x.
Qualitatively, TinySAM 2 maintains robust tracking through multi-instance and occlusion scenarios where other lightweight models fail and lose track of targets.
Limitations and Future Work
While TinySAM 2 excels at tracking macro-movements efficiently, the aggressive spatial pooling and lightweight encoder mean it slightly underperforms the full SAM 2.1 on fine, intricate details (such as precisely delineating thin structures like animal legs). Additionally, the memory quality management module introduces a minor computational check that slightly reduces raw inference frame rates compared to an unmanaged baseline, though the accuracy trade-off makes it well worth it. Future work will likely focus on recovering these fine details without sacrificing the model's edge-friendly footprint.
Summary updated