TL;DR
SAM2Long is a training-free upgrade to Meta's SAM 2 that fixes its tendency to lose track of objects during long videos or complex occlusions. By replacing SAM 2's greedy frame-by-frame choices with a constrained tree search and uncertainty-aware memory tracking, it boosts long-term segmentation accuracy by up to 5.3 points with minimal computational overhead.
What Problem Does This Paper Address?
The Segment Anything Model 2 (SAM 2) is a powerful foundation model for video object segmentation (VOS). However, it suffers from a fatal flaw in long video sequences: error accumulation.
SAM 2 processes video frames sequentially using a greedy strategy. At each frame, it predicts multiple mask proposals but only selects the single mask with the highest predicted Quality (IoU) to update its memory bank. When an object becomes occluded, disappears, or passes through a confusing background, this greedy choice becomes highly uncertain. If SAM 2 selects an incorrect or partial mask into its memory, the error is uncorrectable. This corrupted memory then misleads predictions for all subsequent frames, causing the model's tracking performance to degrade drastically over time.
Methods
To break the cycle of error accumulation, the authors introduce SAM2Long, which replaces greedy selection with a heuristic tree-search strategy inspired by classic Multiple Hypothesis Tracking (MHT).
- Constrained Tree Memory: Instead of maintaining a single tracking history, SAM2Long maintains a fixed number ($P$, typically 3) of parallel memory pathways (hypotheses). At each new frame, the mask decoder generates 3 candidate masks for each pathway, expanding the tree to $3P$ candidate branches.
- Pruning via Cumulative Scores: To keep computation under control, the tree is pruned back down to $P$ pathways at the end of each frame. The pruning is guided by a cumulative score—the accumulated logarithm of predicted IoU scores along the pathway.
- Uncertainty Handling: If the model is highly uncertain (i.e., the absolute occlusion confidence scores across all pathways fall below a threshold $\delta_{conf}$), SAM2Long forces the tree to select distinctly shaped masks. It achieves this by rounding predicted IoU scores and ensuring only hypotheses with unique values are preserved, preventing the tree from prematurely converging on identical, incorrect tracking paths.
- Object-Aware Memory Filtering & Modulation: Within each pathway, frames with poor segmentation or high occlusion are filtered out of the memory bank entirely. Furthermore, during cross-attention, the keys are dynamically weighted based on their occlusion scores, forcing the model to pay more attention to reliable, unoccluded historical frames.
Crucially, this entire setup is training-free and introduces zero external parameters. Because the heavy image encoder only needs to run once per frame, branching the lightweight mask decoder and memory module adds negligible overhead.
Datasets
The authors evaluated SAM2Long across a comprehensive suite of benchmarks:
- Video Object Segmentation (VOS): SA-V (validation and test sets), LVOS v1, LVOS v2, MOSE, VOST, PUMaVOS, DAVIS2017, and YTVOS.
- Video Object Tracking (VOT): LaSOT, LaSOText, and GOT-10k (evaluated by converting predicted masks back into bounding boxes).
No new datasets were introduced in this work.
Key Insights and Ideas
- Delayed Decisions Salvage Tracking: In ambiguous situations (like a dancer being momentarily blocked by another person), it is better to say "I'm not sure, let's keep the top 3 possibilities alive" and let future frames resolve the ambiguity.
- Forced Diversity Beats Raw Scores: When a model is confused, its top three scoring masks might just be minor variations of the same wrong object. Forcing the selection of masks with distinct IoU scores preserves structural diversity in the tracking hypotheses.
- Exploiting the Encoder-Decoder Bottleneck: In modern vision models, the image encoder consumes the vast majority of GFlops. By restricting the tree search strictly to the lightweight mask decoder and memory attention layers, SAM2Long gains massive robustness at a fraction of the computational cost.
Key Results
SAM2Long consistently and significantly outperforms SAM 2 across all model sizes (Tiny, Small, Base+, Large) and weight versions (including the updated SAM 2.1):
- Long-Term Benchmarks: On the challenging SA-V test set, SAM2Long-Large improves the $\mathcal{J}\&\mathcal{F}$ score by 5.3 points over standard SAM 2. On the LVOS v2 dataset, it yields a 3.5 point increase for the Small model configuration.
- Error Resilience Over Time: As shown in the per-frame performance curves, the accuracy gap between SAM2Long and SAM 2 widens as the video progresses, validating its success in mitigating error accumulation.
- Efficiency: Maintaining 3 pathways ($P=3$) results in only a 14% FPS slowdown, an 8% increase in GFlops, and a minor 4% increase in GPU memory usage.
Limitations and Future Work
- Bounded by Base Capacity: Because it is a training-free wrapper, SAM2Long cannot fix fundamental representation failures of the underlying SAM 2 image encoder or mask decoder.
- Single-Object Focus: The tree-growth and pruning logic is optimized primarily for tracking individual targets independently. Scaling this framework to handle complex, multi-object combinatorial interactions efficiently remains an open engineering challenge.
Summary updated