Exploring Effective Factors for Improving Visual In-Context Learning

Yanpeng Sun, Qiang Chen, Jian Wang, Jingdong Wang, Zechao Li

Abstract

Visual In-Context Learning (ICL) has historically struggled to match the performance of specialized meta-learning models due to the spatial complexity of visual data. This paper introduces prompt-SelF, a framework that optimizes prompt selection and fusion to achieve state-of-the-art results in one-shot segmentation and detection without any model fine-tuning.

Introduction

In Natural Language Processing (NLP), In-Context Learning allows models like GPT-4 to perform new tasks by observing a few text examples. In Computer Vision, achieving similar flexibility has been challenging. Unlike linear text, images are multi-dimensional, making the "format" of the prompt critical. Previous attempts were highly sensitive to image arrangement and example selection. This research identifies prompt selection and prompt fusion as the two primary factors determining the success of visual ICL.

Overview of the prompt-SelF framework, illustrating prompt selection from a database, fusion of query and prompt images, and the final inference process using a large-scale visual model.

Methodology: The prompt-SelF Framework

The authors propose prompt-SelF, a framework built on three core pillars designed to stabilize and enhance visual ICL:

  1. Pixel-Level Retrieval (Selection): The researchers discovered that prompts with high spatial similarity to the query image perform best. Instead of using global features, they employ a CLIP-based feature extractor to find examples in a database that match the query image at a granular, pixel-like level.
  2. Multi-Arrangement Fusion: Large-scale vision models (such as MAE-VQGAN) are sensitive to spatial positioning. There are eight logical ways to arrange a 2x2 grid containing the prompt image, its ground truth, and the query image. Different arrangements "activate" different aspects of the model's internal knowledge.
  3. Ensemble Inference: Rather than selecting one arrangement, prompt-SelF generates predictions for all eight and uses a majority voting strategy (ensembling) to produce a final, robust result.
Visual demonstration of the eight different image arrangements (A1-A8) and the resulting ensemble mask, showing significant improvement in IoU.

Key Insights and Results

Spatial Similarity and Knowledge Activation

A critical finding is that the most effective prompt is not just one from the same category, but one that is spatially congruent. For example, if a query image features an object on the left, a prompt with an object in the same position yields superior results. The authors hypothesize that different arrangements act as unique "keys" to the model's pre-trained knowledge, with some better at identifying edges and others at textures.

Performance Benchmarks

The framework was evaluated on standard benchmarks including Pascal-5i for segmentation and PASCAL VOC 2012 for detection:

  • Segmentation Breakthrough: prompt-SelF achieved a mean IoU (mIoU) of 41.02 on Pascal-5i, surpassing the specialized meta-learning model OSLSM (40.80) and vastly outperforming previous ICL methods like Visual Prompting (26.91).
  • The Power of Ensembling: Moving from a single arrangement (~35.89 mIoU) to an ensemble of eight provided a massive performance boost to 41.02.
  • Domain Robustness: The pixel-level selection method proved robust to domain shifts (e.g., using COCO prompts for Pascal images), with only a minor performance drop of 1.22 mIoU points.

Limitations and Future Work

While prompt-SelF marks a significant step forward, it remains dependent on the quality of the underlying large-scale vision model. Current resolution constraints (downsampling sub-images to 111x111) can hinder the segmentation of intricate objects. Additionally, the ensemble approach increases computational overhead. Future research may explore larger backbones and sophisticated reasoning steps, akin to Chain-of-Thought prompting in NLP, to further bridge the gap between visual and textual in-context learning.

Summary updated

BibTeX
@article{sun2023exploring,
  author = {Yanpeng Sun and Qiang Chen and Jian Wang and Jingdong Wang and Zechao Li},
  title = {{Exploring Effective Factors for Improving Visual In-Context Learning}},
  journal = {IEEE Trans. Image Process.},
  year = {2023},
  url = {https://openreview.net/forum?id=vH49AgdImM},
}
Figure