mlsanityData to 14 Oct 2026

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

arXiv 2508.09949 ↗First posted 13 Aug 2025cs.CV cs.LGcited by 8

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

  1. 2023Unsupervised Keypoints from Pretrained Diffusion Models29 Nov
  2. 2023In-Context Learning Unlocked for Diffusion Models1 May
  3. 2023An Edit Friendly DDPM Noise Space: Inversion and Manipulations12 Apr
  4. 2023Localizing Object-level Shape Variations with Text-to-Image Diffusion Models20 Mar
  5. 2022InstructPix2Pix: Learning to Follow Image Editing Instructions17 Nov

Other references · 39

  1. 2017Attention Is All You Needcited by 60,361
  2. 2021Learning Transferable Visual Models From Natural Language Supervisioncited by 33,744
  3. 2020Language Models are Few-Shot Learnerscited by 32,419
  4. 2020An Image is Worth 16x16 Words: Transformers for Image Recognition at Scalecited by 30,186
  5. 2021High-Resolution Image Synthesis with Latent Diffusion Modelscited by 18,863
  6. 2014Microsoft COCO: Common Objects in Contextcited by 17,608
  7. 2023LLaMA: Open and Efficient Foundation Language Modelscited by 14,132
  8. 2018The Unreasonable Effectiveness of Deep Features as a Perceptual Metriccited by 11,177
  9. 2014ImageNet Large Scale Visual Recognition Challengecited by 8,498
  10. 2021Masked Autoencoders Are Scalable Vision Learnerscited by 7,403
  11. 2022Classifier-Free Diffusion Guidancecited by 5,847
  12. 2022PaLM: Scaling Language Modeling with Pathwayscited by 5,326
27 more
  1. 2016The Cityscapes Dataset for Semantic Urban Scene Understandingcited by 4,444
  2. 2022LAION-5B: An open large-scale dataset for training next generation image-text modelscited by 4,152
  3. 2020Taming Transformers for High-Resolution Image Synthesiscited by 3,253
  4. 2022Emergent Abilities of Large Language Modelscited by 2,512
  5. 2017Arbitrary Style Transfer in Real-time with Adaptive Instance Normalizationcited by 2,010
  6. 2022LaMDA: Language Models for Dialog Applicationscited by 1,220
  7. 2021Scaling Language Models: Methods, Analysis & Insights from Training Gophercited by 1,202
  8. 2016Semantic Understanding of Scenes through the ADE20K Datasetcited by 1,069
  9. 2022Plug-and-Play Diffusion Features for Text-Driven Image-to-Image Translationcited by 906
  10. 2023MasaCtrl: Tuning-Free Mutual Self-Attention Control for Consistent Image Synthesis and Editingcited by 727
  11. 2024Improved Distribution Matching Distillation for Fast Image Synthesiscited by 684
  12. 2015Holistically-Nested Edge Detectioncited by 592
  13. 2023InstaFlow: One Step is Enough for High-Quality Diffusion-Based Text-to-Image Generationcited by 395
  14. 2017One-Shot Learning for Semantic Segmentationcited by 337
  15. 2022Images Speak in Images: A Generalist Painter for In-Context Visual Learningcited by 318
  16. 2022Visual Prompting via Image Inpaintingcited by 250
  17. 2023Sequential Modeling Enables Scalable Learning for Large Vision Modelscited by 212
  18. 2023SegGPT: Segmenting Everything In Contextcited by 194
  19. 2019FSS-1000: A 1000-Class Dataset for Few-Shot Segmentationcited by 160
  20. 2023What Makes Good Examples for Visual In-Context Learning?cited by 150
  21. 2023Cross-Image Attention for Zero-Shot Appearance Transfercited by 136
  22. 2023Diffuse, Attend, and Segment: Unsupervised Zero-Shot Segmentation using Stable Diffusioncited by 131
  23. 2023Explicit Visual Prompting for Low-Level Structure Segmentationscited by 114
  24. 2022Language Models are General-Purpose Interfacescited by 97
  25. 2023Explore In-Context Learning for 3D Point Cloud Understandingcited by 40
  26. 2023Skeleton-in-Context: Unified Skeleton Sequence Modeling with In-Context Learningcited by 27
  27. 2023IMProv: Inpainting-based Multimodal Prompting for Computer Vision Taskscited by 10

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2025: 2; 2026: 6.

8 papers.

Similar, not cited

Close in wording, no citation either way

  1. 2023Improving In-Context Learning in Diffusion Models with Visual Context-Modulated Prompts
  2. 2025Underlying Semantic Diffusion for Effective and Efficient In-Context Learning
  3. 2024Explore In-Context Segmentation via Latent Diffusion Models
  4. 2026In-Context Collapse in Vision-Language Models and How to Mitigate it?
  5. 2025I Think, Therefore I Diffuse: Enabling Multimodal In-Context Reasoning in Diffusion Models
  6. 2024Analogist: Out-of-the-box Visual In-Context Learning with Image Diffusion Model
  7. 2026Mitigating Mask Prior Drift and Positional Attention Collapse in Large Diffusion Vision-Language Models
  8. 2025What do vision-language models see in the context? Investigating multimodal in-context learning