Abstract
Interactive segmentation has been significantly advanced by Meta’s Segment Anything Model (SAM). However, SAM often suffers from "instability," where additional user clicks can paradoxically degrade segmentation quality. We present FocSAM, a redesigned pipeline that introduces a lightweight "focus refiner" to dynamically refocus image embeddings on target objects. FocSAM matches state-of-the-art accuracy while maintaining real-time performance, running nearly 18 times faster than high-performance competitors on standard CPUs.
Introduction: The Stability Challenge in SAM
Interactive segmentation allows users to iteratively refine masks via clicks. While SAM offers impressive zero-shot capabilities, its architecture relies on pre-computed, static image embeddings. This leads to a "stability" issue: because the decoder cannot dynamically "zoom in" on complex targets, a single corrective click can cause a previously accurate mask to collapse or shift wildly.
As shown in the comparison above, SAM's IoU can plummet (e.g., from 88.59% to 12.78%) with a single additional click, whereas FocSAM maintains a stable, high-quality mask. This instability occurs because SAM’s decoder struggles to integrate interactive click information with static, global image features.
Methodology: The Focus Refiner
FocSAM addresses these limitations by integrating a "focus refiner" into the SAM pipeline. This component is typically activated after the second click to adjust image embeddings based on the initial mask prediction and query embeddings.
The refiner consists of two primary innovations:
- Dynamic Window Multi-head Self-Attention (Dwin-MSA): Instead of costly image re-encoding, Dwin-MSA partitions existing embeddings into windows and performs attention only on those intersecting the predicted mask. This "refocuses" the model on the object of interest with minimal overhead.
- Pixel-wise Dynamic ReLU (P-DyReLU): This dynamic activation function uses initial click information to generate pixel-wise parameters, enhancing target features while suppressing background noise at a granular level.
Experimental Evaluation
FocSAM was trained on COCO and LVIS and evaluated across diverse benchmarks, including standard datasets (GrabCut, Berkeley, SBD, DAVIS) and challenging scenarios like industrial inspection (MVTec) and camouflaged objects (COD10K).
Key Results
- Accuracy: FocSAM achieved a mean Number of Clicks (NoC@90) of 5.38, outperforming the original SAM (6.85) and matching heavy-weight models like SimpleClick-ViT-H (5.40).
- Efficiency: On a CPU, FocSAM requires only 0.39 seconds per click (SPC), compared to 6.99 seconds for SimpleClick-ViT-H. This represents an 18x speedup, making it ideal for real-time annotation tools.
- Stability: Statistical analysis confirms that FocSAM significantly reduces "deteriorating" clicks, providing a more predictable user experience.
Conclusion
FocSAM demonstrates that high-quality interactive segmentation does not require massive re-encoding. By intelligently refocusing existing features, FocSAM provides a stable, accurate, and CPU-friendly alternative to existing state-of-the-art models. Future work will explore automated triggering of the refiner and its application to video and medical imaging tasks.
Summary updated