Stable Diffusion Models are Secretly Good at Visual In-Context Learning
On the map: Diffusion models → Image generation, text-to-image and editing
Abstract (arXiv)
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.
Key facts. Cited by 8 papers in the map (data through 14 Oct 2026). Placed in Image generation, text-to-image and editing, one of 14 directions in Diffusion models. Builds on 44 of its 48 references that are in the map. First posted on arXiv 13 Aug 2025.
Builds on
44 of 48 references.
Closest ancestors · 5
Same direction, newest first
- 2023Unsupervised Keypoints from Pretrained Diffusion Models29 Nov
- 2023In-Context Learning Unlocked for Diffusion Models1 May
- 2023An Edit Friendly DDPM Noise Space: Inversion and Manipulations12 Apr
- 2023Localizing Object-level Shape Variations with Text-to-Image Diffusion Models20 Mar
- 2022InstructPix2Pix: Learning to Follow Image Editing Instructions17 Nov
Other references · 39
- 2017Attention Is All You Needcited by 60,361
- 2021Learning Transferable Visual Models From Natural Language Supervisioncited by 33,744
- 2020Language Models are Few-Shot Learnerscited by 32,419
- 2020An Image is Worth 16x16 Words: Transformers for Image Recognition at Scalecited by 30,186
- 2021High-Resolution Image Synthesis with Latent Diffusion Modelscited by 18,863
- 2014Microsoft COCO: Common Objects in Contextcited by 17,608
- 2023LLaMA: Open and Efficient Foundation Language Modelscited by 14,132
- 2018The Unreasonable Effectiveness of Deep Features as a Perceptual Metriccited by 11,177
- 2014ImageNet Large Scale Visual Recognition Challengecited by 8,498
- 2021Masked Autoencoders Are Scalable Vision Learnerscited by 7,403
- 2022Classifier-Free Diffusion Guidancecited by 5,847
- 2022PaLM: Scaling Language Modeling with Pathwayscited by 5,326
27 more
- 2016The Cityscapes Dataset for Semantic Urban Scene Understandingcited by 4,444
- 2022LAION-5B: An open large-scale dataset for training next generation image-text modelscited by 4,152
- 2020Taming Transformers for High-Resolution Image Synthesiscited by 3,253
- 2022Emergent Abilities of Large Language Modelscited by 2,512
- 2017Arbitrary Style Transfer in Real-time with Adaptive Instance Normalizationcited by 2,010
- 2022LaMDA: Language Models for Dialog Applicationscited by 1,220
- 2021Scaling Language Models: Methods, Analysis & Insights from Training Gophercited by 1,202
- 2016Semantic Understanding of Scenes through the ADE20K Datasetcited by 1,069
- 2022Plug-and-Play Diffusion Features for Text-Driven Image-to-Image Translationcited by 906
- 2023MasaCtrl: Tuning-Free Mutual Self-Attention Control for Consistent Image Synthesis and Editingcited by 727
- 2024Improved Distribution Matching Distillation for Fast Image Synthesiscited by 684
- 2015Holistically-Nested Edge Detectioncited by 592
- 2023InstaFlow: One Step is Enough for High-Quality Diffusion-Based Text-to-Image Generationcited by 395
- 2017One-Shot Learning for Semantic Segmentationcited by 337
- 2022Images Speak in Images: A Generalist Painter for In-Context Visual Learningcited by 318
- 2022Visual Prompting via Image Inpaintingcited by 250
- 2023Sequential Modeling Enables Scalable Learning for Large Vision Modelscited by 212
- 2023SegGPT: Segmenting Everything In Contextcited by 194
- 2019FSS-1000: A 1000-Class Dataset for Few-Shot Segmentationcited by 160
- 2023What Makes Good Examples for Visual In-Context Learning?cited by 150
- 2023Cross-Image Attention for Zero-Shot Appearance Transfercited by 136
- 2023Diffuse, Attend, and Segment: Unsupervised Zero-Shot Segmentation using Stable Diffusioncited by 131
- 2023Explicit Visual Prompting for Low-Level Structure Segmentationscited by 114
- 2022Language Models are General-Purpose Interfacescited by 97
- 2023Explore In-Context Learning for 3D Point Cloud Understandingcited by 40
- 2023Skeleton-in-Context: Unified Skeleton Sequence Modeling with In-Context Learningcited by 27
- 2023IMProv: Inpainting-based Multimodal Prompting for Computer Vision Taskscited by 10
Built on by
Citing papers per year: 2025: 2; 2026: 6.
8 papers.
- 2025Splatent: Splatting Diffusion Latents for Novel View Synthesiscited by 3
- 2025Stability of In-Context Learning: A Spectral Coverage Perspectivecited by 2
- 2026PromptHub: Enhancing Multi-Prompt Visual In-Context Learning with Locality-Aware Fusion, Concentration and Alignmentcited by 2
- 2026The Latent Color Subspace: Emergent Order in High-Dimensional Chaoscited by 0
- 2026Love Me, Love My Label: Rethinking the Role of Labels in Prompt Retrieval for Visual In-Context Learningcited by 0
- 2026Beyond Text Prompts: Visual-to-Visual Generation as A Unified Paradigmcited by 0
- 2026Quo Vadis, Visual In-Context Learning? A Unified Benchmark Across Domains and Taskscited by 0
- 2026Hidden-Shot: Towards One-Shot Task Generalization for Low-Level Vision Generalist Modelscited by 0
- 2026Hidden-Shot: Towards One-Shot Task Generalization for Low-Level Vision Generalist Models1 Jul 2026
- 2026Quo Vadis, Visual In-Context Learning? A Unified Benchmark Across Domains and Tasks9 Jun 2026
- 2026Beyond Text Prompts: Visual-to-Visual Generation as A Unified Paradigm12 May 2026
- 2026Love Me, Love My Label: Rethinking the Role of Labels in Prompt Retrieval for Visual In-Context Learning4 Apr 2026
- 2026PromptHub: Enhancing Multi-Prompt Visual In-Context Learning with Locality-Aware Fusion, Concentration and Alignment19 Mar 2026
- 2026The Latent Color Subspace: Emergent Order in High-Dimensional Chaos12 Mar 2026
- 2025Splatent: Splatting Diffusion Latents for Novel View Synthesis10 Dec 2025
- 2025Stability of In-Context Learning: A Spectral Coverage Perspective25 Sep 2025
Similar, not cited
Close in wording, no citation either way
- 2023Improving In-Context Learning in Diffusion Models with Visual Context-Modulated Prompts
- 2025Underlying Semantic Diffusion for Effective and Efficient In-Context Learning
- 2024Explore In-Context Segmentation via Latent Diffusion Models
- 2026In-Context Collapse in Vision-Language Models and How to Mitigate it?
- 2025I Think, Therefore I Diffuse: Enabling Multimodal In-Context Reasoning in Diffusion Models
- 2024Analogist: Out-of-the-box Visual In-Context Learning with Image Diffusion Model
- 2026Mitigating Mask Prior Drift and Positional Attention Collapse in Large Diffusion Vision-Language Models
- 2025What do vision-language models see in the context? Investigating multimodal in-context learning