CVLGAug 13, 2025

Stable Diffusion Models are Secretly Good at Visual In-Context Learning

arXiv:2508.09949v18 citationsh-index: 26
Originality Incremental advance
AI Analysis

This provides a more generalizable and simpler approach for computer vision tasks, benefiting researchers and practitioners by reducing the need for complex training procedures.

The paper tackles the problem of enabling visual in-context learning without specialized training or extra data by repurposing off-the-shelf Stable Diffusion models, achieving improvements such as an 8.9% increase in mIoU for foreground segmentation on the Pascal-5i dataset.

Large language models (LLM) in natural language processing (NLP) have demonstrated great potential for in-context learning (ICL) -- the ability to leverage a few sets of example prompts to adapt to various tasks without having to explicitly update the model weights. ICL has recently been explored for computer vision tasks with promising early outcomes. These approaches involve specialized training and/or additional data that complicate the process and limit its generalizability. In this work, we show that off-the-shelf Stable Diffusion models can be repurposed for visual in-context learning (V-ICL). Specifically, we formulate an in-place attention re-computation within the self-attention layers of the Stable Diffusion architecture that explicitly incorporates context between the query and example prompts. Without any additional fine-tuning, we show that this repurposed Stable Diffusion model is able to adapt to six different tasks: foreground segmentation, single object detection, semantic segmentation, keypoint detection, edge detection, and colorization. For example, the proposed approach improves the mean intersection over union (mIoU) for the foreground segmentation task on Pascal-5i dataset by 8.9% and 3.2% over recent methods such as Visual Prompting and IMProv, respectively. Additionally, we show that the proposed method is able to effectively leverage multiple prompts through ensembling to infer the task better and further improve the performance.

Foundations

The foundational work for this paper's niche, ranked by how specifically the neighbourhood builds on it — not by global fame.

Your Notes