Exploring Effective Factors for Improving Visual In-Context Learning

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

TL;DR

This paper identifies prompt selection and prompt fusion as the two critical factors governing the performance of visual in-context learning (ICL). The authors introduce prompt-SelF, a framework that uses pixel-level retrieval to find high-quality demonstrations and an ensemble of multiple spatial arrangements to outperform traditional meta-learning methods in 1-shot segmentation for the first time.

What Problem Does This Paper Address?

In-context learning (ICL) allows models to tackle new tasks using just a few examples (prompts) without any parameter updates. While this is a cornerstone of Large Language Models (LLMs), it is still in its infancy for computer vision.

Existing visual ICL frameworks often yield inconsistent results. The authors identify a major gap: we don't yet fully understand what makes a visual prompt effective. They set out to investigate how the choice of the demonstration image and its spatial arrangement alongside the query image (fusion) affects the model's ability to "understand" and execute a task like segmentation or detection.

Methods

The authors propose a framework called prompt-SelF, which optimizes the two key factors they identified:

  1. Pixel-level Prompt Selection: Instead of picking a random example or using global image-level features for retrieval, they use pixel-level features (extracted from a CLIP visual encoder). This allows the system to find a prompt image that is spatially and contextually similar to the query image, which the authors found to be a primary determinant of success.
  2. Ensemble Prompt Fusion: A visual prompt typically consists of a 2x2 grid containing the prompt image, its ground truth label, the query image, and a space for the prediction. There are 8 valid ways to arrange these while keeping the prompt pair adjacent.
  3. The "SelF" Strategy: Rather than trying to find the single "best" arrangement, prompt-SelF generates all 8 possible fused images and feeds them into a frozen large-scale vision model (MAE-VQGAN). It then uses a majority voting ensemble (with a default threshold of 4/8) to produce the final prediction.
Figure 1: A framework for visual in-context learning. It involves the following steps. (a) Select the prompt pair cor- responding to the task from the database based on the query image. (b) Fusion the query image and the selected prompt image to create a new image. (c) Feed new images into a pre-trained large-scale vision model to get predictions for query images. This paradigm enables the visual model to learn in-context by utilizing the knowledge captured from the prompt image to enhance the accuracy of the prediction for the demand image.

Datasets

The researchers evaluated their framework on standard computer vision benchmarks:

  • PASCAL-5i: Used for single-object segmentation tasks.
  • PASCAL VOC 2012: Used for single-object detection (specifically, using coarse bounding box prompts to generate fine-grained segmentations).
  • MSCOCO: Used to test the model's robustness against "domain shift" (e.g., using a COCO-derived prompt to segment a Pascal image).

Key Insights and Ideas

  • Spatial Similarity is Crucial: High-quality prompts are those that are spatially similar to the query. Pixel-level retrieval is significantly more effective than global image-level retrieval for dense tasks like segmentation.
  • Arrangement Sensitivity: Large-scale vision models are surprisingly sensitive to the spatial arrangement of the prompt grid. Different arrangements "activate" different parts of the knowledge stored in the frozen model.
  • The Power of Ensembling: Because it is difficult to predict which specific arrangement will work best for a given query, ensembling multiple arrangements provides a robust and significant performance boost.
  • ICL vs. Meta-Learning: The results suggest that visual ICL, when properly optimized, can finally compete with and even surpass specialized meta-learning architectures that require task-specific training.
Figure 2: (a) The selection of different prompts can affect the results of the same query image, therefore, choosing a high- quality prompt can have a positive impact on visual in-context learning. (b) Different prompt fusion methods activate knowl- edge at different positions in the large-scale model, leading to varying degrees of impact on visual in-context learning. Note that the red box in the figure is the prediction result, and the blue box is the prompt pair.

Key Results

  • New State-of-the-Art: prompt-SelF achieved a mean IoU of 41.02% on PASCAL-5i, significantly outperforming previous ICL methods like VP (26.91%) and VPR (35.56%).
  • Surpassing Meta-Learning: For the first time, a visual ICL method outperformed established meta-learning baselines like OSLSM (40.80%) in 1-shot segmentation.
  • Robustness to Domain Shift: The pixel-level retrieval method proved more resilient than image-level methods when the prompt and query came from different datasets (e.g., COCO → Pascal).
  • Threshold Optimization: Through ablation, the authors found that a majority voting threshold of 4/8 provided the optimal balance for the ensemble strategy.
Figure 4: Ablation study of thresholds in ensemble strategy. The denominator and numerator of the threshold indicate the complete count of arrangements and the minimum count needed to establish the final outcome, correspondingly.

Limitations and Future Work

The authors acknowledge that most current large-scale vision models (like ViT or BEiT) are not natively designed for in-context learning; they are trained to process individual images rather than grids of related images. Consequently, they may not fully capture the complex relationships between a prompt and a query.

Future work should focus on designing large-scale models specifically architected for visual ICL, which could lead to even more robust and versatile "generalist" vision systems.

Summary updated

BibTeX
@article{sun2023exploring,
  author = {Yanpeng Sun and Qiang Chen and Xiaofan Li 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