Abstract
The Segment Anything Model (SAM) has demonstrated remarkable zero-shot generalization for image segmentation. However, its performance often degrades in specialized domains or when faced with prompt ambiguity. This paper presents a lightweight, "plug-and-play" adaptation strategy that enhances SAM's precision for niche tasks without full-model fine-tuning. By introducing a Prompt Learning Module (PLM) and a Point Matching Module (PMM), the proposed method aligns prompt embeddings with task-specific priors and refines mask boundaries. Experimental results on facial parts, outdoor banners, and license plates show significant improvements in mean Intersection over Union (mIoU) and increased robustness to prompt variations.
1. Introduction
Meta’s Segment Anything Model (SAM) represents a milestone in computer vision, trained on over 1.1 billion masks to provide a foundation for general-purpose segmentation. Despite its versatility, SAM faces two primary challenges: prompt sensitivity and domain-specific limitations. A single point prompt can be ambiguous; for instance, clicking a cheek could imply segmenting the skin, the entire face, or a specific facial feature. Furthermore, SAM often struggles with "out-of-distribution" data, such as specialized medical imagery or text-heavy industrial objects, which were underrepresented in its training set.
Traditional adaptation methods involve fine-tuning the entire model, which is computationally expensive given SAM's 641 million parameters (ViT-H). This paper proposes a more efficient alternative that freezes the foundation model and trains a minimal set of auxiliary parameters to specialize the model for specific tasks.
2. Proposed Method
The core of the proposed approach is a lightweight adaptation framework that adds only 2.8 million parameters (approximately 0.25% of the total) while keeping the original SAM backbone frozen.
2.1 Prompt Learning Module (PLM)
Rather than adjusting the user's input coordinates in the image space, the PLM operates within the high-dimensional embedding space. It processes the initial prompt and image features to calculate a "feature offset." This offset shifts the prompt's mathematical representation to align with task-specific goals. For example, in a facial segmentation task, the PLM learns to interpret a point near the center of the face as a request to segment the entire face or a specific feature like the nose, depending on the training objective.
2.2 Point Matching Module (PMM)
To improve boundary precision, the authors introduced the PMM, which utilizes a Point Matching Loss (PML). This module guides the predicted mask's edge points toward the ground-truth boundaries during training. By employing a "Boundary Transformer," the PMM refines the contours of the output mask, ensuring that the final segmentation is not only semantically correct but also geometrically accurate.
2.3 Plug-and-Play Architecture
The modular nature of the PLM and PMM allows them to be swapped easily. Users can maintain a single frozen SAM instance and load different lightweight "cartridges" for various tasks, such as medical imaging, industrial inspection, or facial analysis.
3. Experimental Evaluation
The method was evaluated on three datasets representing different challenges:
- CelebA-HQ: Focused on 18 distinct facial parts (e.g., eyes, lips, hair) to test fine-grained semantic understanding.
- Outdoor Banner Dataset: A synthesized dataset of 7,000 images designed to test the model's ability to handle rectangular priors and text-heavy content under various perspectives.
- Kaggle Car License Plate: A real-world dataset of 433 images used to evaluate precision on small, high-contrast objects.
4. Results and Discussion
The proposed adaptation significantly outperformed the vanilla SAM across all benchmarks.
4.1 Quantitative Performance
The improvements in mean Intersection over Union (mIoU) were substantial:
- Facial Parts: mIoU increased from 35.05% (vanilla SAM) to 71.67%.
- Outdoor Banners: Performance rose from 30.27% to 97.33%, demonstrating the model's success in learning to treat banners as single units despite internal text distractions.
- License Plates: mIoU improved from 63.79% to 76.29%.
4.2 Robustness to Prompt Ambiguity
A key finding was the increased robustness to "sloppy" clicking. By visualizing IoU maps—heatmaps showing how segmentation accuracy changes as the prompt point moves—the researchers demonstrated that their method creates much larger "high-accuracy zones" (red areas in Figure 5b). This indicates that the model has learned a "shape prior" for the target objects, allowing it to correctly infer the intended mask even if the user's click is off-center.
5. Conclusion
This paper demonstrates that foundation models like SAM can be effectively specialized for niche tasks through lightweight prompt learning. By shifting the focus from coordinate-space adjustments to embedding-space offsets and boundary refinement, the proposed method achieves high precision with minimal computational overhead. Future work may explore extending this approach to video-based tracking and multi-modal prompting.
Summary updated