Bridge the Points: Graph-based Few-shot Segment Anything Semantically

Anqi Zhang, Guangyu Gao, Jianbo Jiao, Chi Harold Liu, Yunchao Wei

Abstract

The Segment Anything Model (SAM) has revolutionized object segmentation but remains class-agnostic, requiring manual prompts for semantic tasks. We present GF-SAM, a graph-based framework for few-shot semantic segmentation (FSS) that automates prompt selection without manual hyperparameter tuning. By modeling point-mask relationships as a directed graph and employing a positive-negative alignment strategy, GF-SAM achieves state-of-the-art accuracy and significantly higher inference speeds than previous automated methods.

Introduction

While SAM provides near-perfect object boundaries, it lacks inherent semantic understanding. To adapt SAM for Few-shot Semantic Segmentation (FSS)—where a model learns to segment a new class from only a few labeled examples—researchers have faced three primary obstacles: the difficulty of automated prompt selection, the high computational cost of iterative refinement, and the reliance on dataset-specific hyperparameters.

GF-SAM addresses these issues by bridging the "granularity gap" between fine-grained semantic features (e.g., from DINOv2) and coarse-grained SAM masks. By utilizing graph theory to organize point prompts, the framework eliminates the need for manual thresholding and iterative SAM passes.

The GF-SAM Framework

The GF-SAM pipeline is a parameter-free system that processes images in a single pass. It is composed of three core modules:

Positive-Negative Alignment (PNA)

Traditional FSS models often focus solely on foreground features. GF-SAM's PNA module explicitly incorporates background context from reference images. By comparing the target image features against both "positive" (object) and "negative" (background) references, the model generates more reliable candidate point prompts, reducing initial false positives.

Point-Mask Clustering (PMC)

The PMC module is the central innovation of this work. It treats selected points and their corresponding SAM-generated masks as nodes in a directed graph. An edge is drawn from Point A to Point B if the mask generated by Point A covers Point B. By identifying "weakly connected components" within this graph, the system naturally clusters points into distinct object instances. This non-parametric approach avoids the limitations of traditional clustering methods like K-means, which require a pre-defined number of clusters.

Post-Gating Strategy

To ensure high-fidelity results, GF-SAM employs a dual-gating mechanism. Positive Gating uses a mask-growth algorithm to verify that final segments are dominated by positive semantic pixels. Overshooting Gating acts as a self-consistency check, filtering out masks that erroneously extend beyond the object's true boundaries into the background.

The GF-SAM architecture, illustrating the flow from Positive-Negative Alignment to Graph-based Point-Mask Clustering and final Post-Gating.

Experimental Evaluation

GF-SAM was evaluated across a wide array of benchmarks, including standard FSS datasets (Pascal-$5^i$, COCO-$20^i$, LVIS-$92^i$), part segmentation tasks (PACO-Part), and cross-domain challenges (Deepglobe, ISIC, iSAID-$5^i$).

Accuracy and Generalization

GF-SAM established new state-of-the-art results for generalist models. On the COCO-$20^i$ dataset, it achieved a 58.7% mIoU, outperforming the previous leader, Matcher, by 5.8%. Its performance on the massive LVIS-$92^i$ dataset (35.2% mIoU) and various cross-domain tasks demonstrates exceptional robustness and the ability to generalize to medical and aerial imagery without task-specific tuning.

Efficiency

A key advantage of GF-SAM is its inference speed. By avoiding the iterative mask generation cycles common in other SAM-based FSS models, GF-SAM processes images at 1.88s/img. This is nearly seven times faster than Matcher (12.7s/img) and eight times faster than PerSAM-F (16.5s/img).

Comparison of GF-SAM against state-of-the-art models. The radar chart (right) shows superior generalization across datasets, while the scatter plot (left) highlights the optimal speed-accuracy trade-off.

Conclusion

GF-SAM demonstrates that graph-based reasoning can effectively bridge the gap between pixel-level semantic features and object-level masks. By replacing manual hyperparameter tuning with a structured, parameter-free clustering approach, GF-SAM provides a scalable and efficient solution for automated semantic segmentation. Future work will focus on addressing coordinate bias to improve the localization of very small-scale objects.

Summary updated

BibTeX
@inproceedings{zhang2024bridge,
  author = {Anqi Zhang and Guangyu Gao and Jianbo Jiao and Chi Harold Liu and Yunchao Wei},
  title = {{Bridge the Points: Graph-based Few-shot Segment Anything Semantically}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=jYypS5VIPj},
}
Figure