SAM-Aware Graph Prompt Reasoning Network for Cross-Domain Few-Shot Segmentation

Shi-Feng Peng, Guolei Sun, Yong Li, Hongsong Wang, Guo-Sen Xie

Abstract

Few-shot segmentation (FSS) in cross-domain scenarios remains a significant challenge due to large domain shifts and the difficulty of generating high-quality visual prompts. This paper introduces the SAM-Aware Graph Prompt Reasoning Network (GPRN), which leverages the Segment Anything Model (SAM) to initialize semantically rich prompts. By employing a Graph Attention Network for relational reasoning among over-segmented SAM regions and an Adaptive Point Selection module for test-time refinement, GPRN achieves state-of-the-art performance across diverse datasets, including satellite and medical imagery.

Introduction

Few-shot segmentation (FSS) aims to segment novel object classes using only a few annotated support images. While standard FSS has seen progress, Cross-Domain FSS (CD-FSS) presents a steeper hurdle: models must generalize to data distributions entirely different from their training set—for example, moving from natural images to satellite photos or medical X-rays.

Existing CD-FSS approaches face three primary obstacles. First, Domain Disparity prevents features learned in one domain from translating effectively to another. Second, Poor Initialization in current visual prompting techniques often relies on random noise, which lacks spatial context. Finally, while the Segment Anything Model (SAM) is a powerful generalist, its tendency toward Over-segmentation often breaks single semantic objects into fragmented sub-regions, complicating consistent feature representation.

Methods: The GPRN Framework

The proposed GPRN addresses these issues by integrating SAM into the learning pipeline through three core modules.

Overview of the GPRN architecture, illustrating the SAM-aware Prompt Initialization (SPI), Graph Prompt Reasoning (GPR), and Adaptive Point Selection (APS) modules.

1. SAM-aware Prompt Initialization (SPI)

Instead of starting with random noise, GPRN utilizes masks generated by SAM to create task-specific visual prompts. A ranking strategy is employed to handle overlapping masks, ensuring that finer-grained details are preserved. These masks are then converted into feature vectors via Masked Average Pooling (MAP), injecting high-level spatial knowledge directly into the backbone features.

2. Graph Prompt Reasoning (GPR)

To mitigate SAM’s over-segmentation, GPR treats each visual prompt as a node in a fully connected graph. A Graph Attention Network (GAT) enables these nodes to perform relational reasoning. This allows prompts representing different parts of the same object (e.g., the wing and fuselage of an airplane) to aggregate information and achieve global semantic consistency.

3. Adaptive Point Selection (APS)

APS is a non-parametric test-time refinement module. It analyzes the model's initial coarse prediction using a distance transform to identify the most representative foreground and background points. These points are fed back into SAM as prompts, producing a final, high-fidelity segmentation mask without requiring additional training.

Experimental Setup

GPRN was trained on the PASCAL VOC dataset (augmented with SDS) and evaluated on four diverse cross-domain benchmarks:

  • Deepglobe: Satellite imagery.
  • ISIC: Dermatoscopic skin lesion images.
  • Chest X-Ray: Medical radiographs.
  • FSS-1000: 1,000 diverse object classes.

Results and Discussion

GPRN establishes a new state-of-the-art for CD-FSS across all tested benchmarks.

Quantitative comparison of GPRN against state-of-the-art methods on four cross-domain benchmarks.

In the 1-shot setting, GPRN outperforms the previous best non-fine-tuning method by 10.4% in mean-IoU. When compared against methods that include a fine-tuning phase (such as IFA), GPRN maintains its lead, surpassing them by 3.9% in both 1-shot and 5-shot settings. The model's robustness is particularly evident in medical domains; for instance, it achieved 87.0% mean-IoU on Chest X-Rays, far exceeding previous SAM-based competitors like PerSAM (61.0%).

Conclusion

GPRN demonstrates that leveraging SAM as a semantic prior, rather than just a post-processor, significantly enhances cross-domain generalization. While the reliance on SAM introduces computational overhead and the current implementation uses a fixed mask count, the integration of graph-based relational reasoning effectively solves the over-segmentation problem. Future work will focus on improving efficiency and extending this approach to video-based few-shot tasks.

Summary updated

BibTeX
@inproceedings{peng2025sam,
  author = {Shi-Feng Peng and Guolei Sun and Yong Li and Hongsong Wang and Guo-Sen Xie},
  title = {{SAM-Aware Graph Prompt Reasoning Network for Cross-Domain Few-Shot Segmentation}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2025},
  doi = {10.1609/aaai.v39i6.32695},
}
Figure