OFL-SAM2: Prompt SAM2 with Online Few-shot Learner for Efficient Medical Image Segmentation

Meng Lan, Lefei Zhang, Xiaomeng Li

Abstract

OFL-SAM2 is a prompt-free framework that adapts the Segment Anything Model 2 (SAM2) for medical image segmentation by replacing manual prompts with an online few-shot learner. By training a lightweight mapping network that updates during inference, it achieves state-of-the-art performance on 3D volumes and surgical videos using only a handful of annotated training samples.

Introduction

While SAM2 has revolutionized video segmentation, its transition to the medical domain faces a major hurdle: the "prompting" tax. SAM2 typically requires a human expert to provide points or boxes to define a target. In medical contexts, where a single 3D scan can contain hundreds of slices, manual prompting is prohibitively labor-intensive and requires expensive specialist time.

Furthermore, medical images are rife with "distractors" — adjacent tissues or organs that look nearly identical to the target. Standard SAM2, relying on generic pixel-level matching, often gets confused by these neighbors. Existing "prompt-free" solutions either require massive datasets for fine-tuning or fail to capture the spatiotemporal context that makes SAM2 powerful in the first place.

Methods

The authors introduce OFL-SAM2, which keeps the core SAM2 architecture frozen but adds two lightweight, trainable components:

  1. Online Few-shot Learner: Instead of a human prompt, a "mapping network" transforms generic image features into target-specific features. This network is first trained on a few annotated volumes (offline) and then—crucially—continues to update its parameters online during inference. This allows the model to adapt to the specific anatomical variations of a new patient's scan.
  2. Adaptive Fusion Module (AFM): This module acts as a smart mixer. It dynamically integrates the target features from the mapping network with the spatiotemporal features from SAM2’s memory bank. This ensures the model uses both "what the target looks like" (from the learner) and "where the target was in the last slice" (from SAM2's memory).

To prevent the model from learning from its own mistakes, a Quality-aware Update Strategy is employed. Only predictions with a high confidence score are used to update the mapping network and the memory bank during inference.

An overview of the OFL-SAM2 framework, highlighting the offline training and online update branches.

Experimental Setup

The model was evaluated on three diverse medical imaging benchmarks: Synapse-CT (multi-organ CT), PROMISE12 (prostate MRI), and Autolaparo (laparoscopic video). In all cases, the model was tested in "label-efficient" settings, using as few as 2 or 3 training volumes.

Key Results

OFL-SAM2 consistently outperformed both the original SAM2 and other recent medical adaptations. On the Synapse-CT dataset, it achieved a 82.52% Mean Dice score with only 3 training volumes, significantly outperforming H-SAM (80.12%) and FATE-SAM2 (76.38%). On PROMISE12, it reached 88.74% Mean Dice, a substantial lead over the second-best method.

Visual comparison showing OFL-SAM2's superior accuracy and robustness against distractors compared to H-SAM2.

Beyond Dice scores, OFL-SAM2 demonstrated superior boundary precision. On Synapse-CT, it reduced the Average Hausdorff Distance (HD) from 24.08 (standard SAM2) down to 8.22, indicating much more precise segmentations.

Conclusion

OFL-SAM2 addresses the "prompting tax" by treating inference as a continuous learning process. By specializing its mapping network on the fly for each specific patient, it overcomes the distractor problem common in medical imaging. While it still requires a small set of annotated support images for initialization, it represents a significant step toward efficient, automated medical image segmentation.

Summary updated

BibTeX
@inproceedings{lan2026ofl,
  author = {Meng Lan and Lefei Zhang and Xiaomeng Li},
  title = {{OFL-SAM2: Prompt SAM2 with Online Few-shot Learner for Efficient Medical Image Segmentation}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2026},
  doi = {10.1609/aaai.v40i7.37502},
}
Figure