The Segment Anything Model (SAM) has fundamentally altered the computer vision landscape by providing a powerful foundation model capable of segmenting virtually any object. However, its zero-shot capabilities rely heavily on receiving the right "nudge" in the form of high-quality prompts. In few-shot segmentation—where only one or two annotated support images are available—finding the optimal set of point prompts remains a significant challenge.
PromptPilot introduces a novel, inference-time optimization strategy that automates prompt engineering through a hierarchical multi-agent reinforcement learning (RL) framework. By treating prompt construction as a cooperative game, PromptPilot achieves state-of-the-art segmentation across natural, medical, and video datasets without requiring any updates to the underlying model parameters.
The Challenge of Few-Shot Prompting
In few-shot segmentation (FSS), the objective is to segment novel categories using minimal reference data. While SAM is highly capable, its performance is notoriously sensitive to prompt quality. Existing automated prompt construction methods typically fall into three traps:
- Static Heuristics: Methods utilizing fixed rules (like K-means clustering) fail to incorporate SAM’s actual output feedback, leading to suboptimal prompts.
- The Balancing Act: An effective prompt set must maintain semantic consistency (points must accurately target the object) while ensuring spatial coverage (points should span the entire object rather than clustering in one area). Monolithic RL models often struggle to balance these competing objectives.
- Credit Assignment: When SAM generates an inaccurate mask, it is difficult to identify which specific point prompt caused the error. Without granular credit assignment, models cannot effectively prune harmful prompts.
The PromptPilot Architecture
To overcome these limitations, PromptPilot formulates prompt construction as a sequential decision-making process using frozen DINOv2 and SAM models. It employs a hierarchical, multi-agent setup to decouple competing objectives.
The Dual-Agent System
Rather than relying on a single monolithic policy, PromptPilot utilizes two specialized actor agents:
- The Feature Agent: Operating in the "Feature Domain" using DINOv2 embeddings, this agent ensures semantic purity. It focuses on placing positive prompts on features that match the target object and negative prompts on background features.
- The Physical Agent: Operating in the "Physical Domain" (pixel coordinates), this agent is responsible for spatial diversity. It ensures prompts are adequately distributed to capture the object's full boundaries.
The Manager Agent
A centralized Manager Agent acts as the system's arbiter. It evaluates the complementary prompt modifications proposed by the Feature and Physical agents and selects the optimal action based on SAM's feedback and a hybrid reward structure.
Game-Theoretic Credit Assignment
The core innovation of PromptPilot is its solution to the credit assignment problem. The authors treat the prompt set as a coalition in a cooperative game.
To evaluate the true value of each point, the system employs a Leave-One-Out (LOO) strategy. It calculates the overall segmentation score, removes a single point, and measures the resulting change in performance. If the score improves upon a point's removal, that point is deemed "harmful" and its marginal contribution is penalized. This marginal contribution is smoothed over time using an Exponential Moving Average (EMA), allowing the Manager Agent to dynamically prune redundant or misleading points and maintain a concise, robust prompt configuration.
Experimental Validation and Results
PromptPilot was rigorously tested across a diverse array of domains to demonstrate its broad generalization capabilities:
- Natural Images: On the highly challenging MS COCO dataset, PromptPilot achieved a 47.1% mIoU, outperforming the previous RL-based state-of-the-art (FM-PPO) by an impressive 16.7 percentage points. It also demonstrated strong performance on PASCAL VOC.
- Medical Imaging (Cross-Domain): The framework was evaluated on specialized medical datasets including ISIC (skin lesions), Kvasir (endoscopy), GBM (kidney membranes), and JSRT (chest X-rays). Remarkably, PromptPilot frequently outperformed models explicitly fine-tuned on medical data. For instance, on the GBM dataset, PromptPilot achieved 60.6% mIoU compared to SAM-LoRA's 55.5%, despite never seeing medical data during training.
- Video Object Segmentation: Tested on DAVIS 2016 and 2017, PromptPilot exhibited strong temporal stability, proving that its dynamic, frame-by-frame optimization effectively mitigates error accumulation in video sequences.
Limitations and Future Directions
While highly effective, the PromptPilot framework has a few notable limitations:
- Inference Latency: The Leave-One-Out evaluation and iterative RL loops require multiple forward passes through SAM. This makes the method computationally heavier and potentially slower than single-pass heuristic approaches.
- Initialization Dependency: The system relies on a coarse initialization derived from DINOv2 features. In cases of extreme domain shift where initial feature matching fails entirely, the agents may struggle to recover and optimize effectively.
Future work may explore extending this game-theoretic framework to accommodate other prompt modalities, such as bounding boxes or scribbles, and applying the multi-agent optimization strategy to other vision foundation models beyond SAM.
Project Resources: * Code Repository: https://github.com/L-AILab/PromptPilot
Summary updated