Abstract
Under the backdrop of large-scale pre-training, large visual models (LVM) have demonstrated significant potential in image understanding. The recent emergence of the Segment Anything Model (SAM) has brought a qualitative shift in the field of image segmentation, supporting flexible interactive cues and strong learning capabilities. However, its performance often falls short in cross-domain and few-shot applications. Transferring prior knowledge from foundation models to new applications while preserving learning capabilities is worth exploring. This work proposes a task-adaptive prompt framework based on SAM, a new paradigm for Cross-domain few-shot segmentation (CD-FSS). First, a Multi-level Feature Fusion (MFF) was used for integrated feature extraction. Besides, an additional Class Domain Task-Adaptive Auto-Prompt (CDTAP) module was combined with the segmentation branch for class-domain agnostic feature extraction and high-quality learnable prompt production. This significant advancement uses a unique generative approach to prompts alongside a comprehensive model structure and specialized prototype computation. While ensuring that the prior knowledge of SAM is not discarded, the new branch disentangles category and domain information through prototypes, guiding it in adapting the CD-FSS. We have achieved the best results on three benchmarks compared to the recent state-of-the-art (SOTA) methods. Comprehensive experiments showed that after task-specific and weighted guidance, the abundant feature information of SAM can be better learned for CD-FSS.
Introduction
Large Visual Models (LVMs), particularly the Segment Anything Model (SAM), have revolutionized image segmentation with their zero-shot capabilities. However, these models encounter a significant challenge in Cross-domain Few-shot Segmentation (CD-FSS). Standard few-shot segmentation assumes training and testing data share the same domain. In contrast, CD-FSS requires models to generalize from natural images to specialized domains like medical X-rays or satellite imagery using only one or five labeled examples. SAM often struggles in these scenarios because its features are mismatched with specialized domain distributions, and its reliance on manual prompts is impractical for automated tasks. This paper introduces the TAVP (Task-Adaptive Visual Prompt) framework to bridge this gap by adapting SAM for specialized, low-data environments.
Methodology
The TAVP framework treats SAM as a frozen foundation and introduces a lightweight, learnable branch to handle domain adaptation. The architecture is built around two core innovations:
- Multi-level Feature Fusion (MFF): While SAM's high-level features are semantically rich, they often lose fine-grained edge details. MFF extracts and fuses features from the early, middle, and late layers of the SAM encoder to retain both global context and local boundary information.
- Class Domain Task-Adaptive Auto-Prompt (CDTAP): This module acts as the adaptive engine. It utilizes a Cycle-consistent Selection strategy to generate high-quality prototypes. By matching features between the "support" (labeled) and "query" (unlabeled) images, it ensures the model focuses on the target category while filtering out domain-specific noise.
Instead of manual interaction, the system generates dense visual prompts (embeddings) automatically to guide the SAM decoder. This approach is highly efficient; the SAM backbone remains frozen, and the TAVP module adds only 36.5 million learnable parameters—a fraction of the 641 million parameters in a full SAM-H model. This efficiency allows the model to run at 12 FPS, significantly faster than standard adaptation baselines.
Experimental Results
The model was evaluated on four diverse benchmarks: ISIC (skin lesions), ChestX (medical X-rays), Deepglobe (satellite imagery), and FSS1000 (natural images). TAVP established a new state-of-the-art (SOTA) performance across these datasets.
As detailed in the results table, TAVP achieved an average accuracy improvement of 1.3% in 1-shot and a substantial 11.76% in 5-shot settings compared to previous SOTA methods like APSeg. The performance gain is particularly notable in complex medical imaging tasks, where TAVP produces more accurate and complete masks than standard few-shot methods. The use of cycle consistency proved vital in filtering false positives, leading to cleaner segmentation results in challenging target domains.
Conclusion
TAVP demonstrates that the vast prior knowledge embedded in large foundation models like SAM can be effectively repurposed for specialized tasks through task-adaptive prompting. By disentangling class and domain information, the framework provides a robust solution for CD-FSS. While performance is strong, challenges remain in high-resolution remote sensing data like Deepglobe. Future work will explore more efficient prompt types and the integration of vision-language models to enable text-guided cross-domain segmentation.
Summary updated