Abstract
In this work, we address in-context learning (ICL) for the task of image segmentation, introducing a novel approach that adapts a modern Video Object Segmentation (VOS) technique for visual in-context learning. This adaptation is inspired by the VOS method's ability to efficiently and flexibly learn objects from a few examples. Through evaluations across a range of support set sizes and on diverse segmentation datasets, our method consistently surpasses existing techniques. Notably, it excels with data containing classes not encountered during training. Additionally, we propose a technique for support set selection, which involves choosing the most relevant images to include in this set. By employing support set selection, the performance increases for all tested methods without the need for additional training or prompt tuning.
Introduction
In-context learning (ICL) is the mechanism that allows Large Language Models (LLMs) to perform new tasks based solely on examples provided in a prompt, without updating model weights. In computer vision, however, ICL is still in its early stages. Current state-of-the-art visual ICL methods, such as Painter or SegGPT, rely on a "gridding" approach where support images and their masks are stitched into a large grid and treated as an image-inpainting problem.
This gridding approach introduces three major bottlenecks: fixed capacity (support set size is limited at training), resolution loss (images must be downsampled to fit the grid), and high computational cost. This paper addresses these issues by proposing a visual ICL system that is resolution-independent and can handle an arbitrary number of example images.
Methodology
The core innovation is the adaptation of XMem, a modern Video Object Segmentation (VOS) framework, for static image segmentation tasks.
VOS as In-Context Learning
In a standard video task, a VOS model "remembers" an object from the first frame and tracks it through subsequent frames. The authors treat a support set of examples as a "video" of a specific concept. By populating XMem’s memory with embeddings of support image-mask pairs, the model can use this memory to predict the mask for a new query image, effectively treating it as the next frame in a sequence.
Support Set Selection ($s^3$)
Rather than using random examples, the authors propose Support Set Selection ($s^3$). This strategy utilizes CLIP to identify the $N$ images in a large "meta-support set" that are most semantically similar to the query image. This ensures the model receives the most relevant context for the task at hand.
Logit Averaging
To compare fairly with gridding models like SegGPT, the authors introduced "logit averaging." Instead of forcing a model to process a grid of four images simultaneously, they run the model on one example at a time and average the raw prediction "logits," which significantly boosted the performance of existing baseline methods.
Datasets and Evaluation
The model was trained on a massive compilation of diverse data, including ADE20K, Cityscapes, and COCO-Stuff. To test true generalization, the authors evaluated the model on Out-of-Distribution (OOD) datasets it never encountered during training:
- Medical: Dental-teeth and Dental-jaw segmentation.
- Satellite/Aerial: FloodNet (identifying flooded areas).
- Biomedical: LIVECell (cell segmentation).
- Infrastructure: SHREC (potholes and road cracks).
Key Results
- Superior Generalization: On OOD datasets, the XMem-based approach consistently outperformed gridding methods. For instance, on the LIVECell dataset, XMem achieved an mIoU of 80.57, compared to SegGPT's 41.30.
- The Selection Boost: Implementing $s^3$ improved performance for every method tested, with gains sometimes exceeding 14%.
- Scaling Support: Unlike gridding methods that are limited by their training architecture, XMem's performance continues to improve as the support set size increases, plateauing around 20 images.
Conclusion and Future Work
By utilizing a memory architecture instead of fixed grids, this approach allows for high-resolution, flexible visual in-context learning. While currently specialized for binary segmentation tasks, the framework demonstrates that VOS architectures are highly effective for zero-shot and few-shot image segmentation. Future research will address the current performance plateau observed at larger support set sizes and the computational overhead associated with the selection process.
Summary updated