NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

ImageBrush: Learning Visual In-Context Instructions for Exemplar-Based Image Manipulation

Yasheng Sun, Yifan Yang, Houwen Peng, Yifei Shen, Yuqing Yang, Han Hu, Lili Qiu, Hideki Koike

Introduction

Image manipulation has traditionally relied on text prompts to guide edits. However, language often fails to capture the nuance of artistic textures, complex geometric shifts, or specific lighting conditions. ImageBrush introduces a paradigm shift by using "visual instructions"—pairs of before-and-after example images—to define manipulation tasks. By treating image editing as a diffusion-based in-context learning problem, ImageBrush captures human intent with high precision across diverse domains.

Overview of ImageBrush performance across diverse tasks including style transfer, object swapping, and pose manipulation.

The Challenge of Linguistic Ambiguity

While models like InstructPix2Pix have democratized image editing, they are limited by the "modality gap." Describing a specific brushstroke or a subtle facial expression in words is often impossible. ImageBrush eliminates this gap by using pixels to instruct pixels. The model learns to extract an underlying "transformation rule" from a single visual demonstration and applies it to a new query image, bypassing the ambiguity of natural language.

Methodology: Visual In-Context Learning

ImageBrush conceptualizes manipulation as a visual prompting task, inspired by the few-shot capabilities of Large Language Models (LLMs).

1. Progressive In-Painting

The framework arranges an example pair (source $E$, target $E'$) and a query image ($I$) into a grid. The model is then tasked with "inpainting" the missing fourth slot to generate the edited query image ($I'$). This setup allows the model to infer the relationship between $E$ and $E'$ and apply it directly to $I$.

2. Diffusion-Based Generation

Unlike single-pass networks, ImageBrush utilizes a Latent Diffusion Model (LDM). This allows for iterative refinement, enabling the model to progressively build complex textures and maintain structural integrity, much like a painter adding detail layer by layer.

3. Visual Prompting Encoder

To bridge the semantic gap between the example and the query, the authors developed a dual-component encoder. A shared Vision Transformer (ViT) extracts features, while a bi-directional transformer captures the "delta" (the change) between the example images. These learned instructions are then injected into the main UNet via cross-attention layers.

A specific example of visual prompting: the model learns the style and structure transformation from the house examples (left) and applies it to the castle query (middle).

Evaluation and Key Insights

The model was trained on a massive synthetic dataset of 310k editing pairs and evaluated across benchmarks like Scannet (image translation), UBC-Fashion (pose transfer), and DAVIS (video segmentation).

Symmetry as a Metric

A key contribution is the introduction of two new metrics to evaluate instruction adherence without ground truth:

  • Prompt Fidelity: Applying the learned rule back to the original example $E$ should recover $E'$.
  • Image Fidelity: The transformation should be reversible; using the inverse example ($E' \rightarrow E$) should reconstruct the original $I$.

Results

ImageBrush consistently outperforms both specialized and general-purpose models. On the Scannet dataset, it achieved an FID of 9.18, significantly better than the previous state-of-the-art, CoCosNet (19.49). Qualitatively, ImageBrush demonstrates superior adherence to specific visual textures—such as turning a bridge into ice—where text-based models often hallucinate generic or irrelevant results.

Limitations and Future Work

Despite its versatility, ImageBrush faces challenges when there is a significant contextual disparity between the example pair and the query image (e.g., applying a car transformation to a cat). Additionally, while it excels at holistic changes, extremely subtle background adjustments or the generation of tiny, intricate objects remain areas for future improvement. The authors suggest that expanding the framework could eventually lead to a "vision foundation model" capable of understanding any visual manipulation through demonstration.

Conclusion

ImageBrush demonstrates that visual demonstrations are a denser and more accurate form of instruction than text for complex image manipulation. By unifying diverse tasks—from pose changes to seasonal shifts—under a single diffusion-based framework, it paves the way for more intuitive and precise creative tools.

Summary updated

BibTeX
@inproceedings{sun2023imagebrush,
  author = {Yasheng SUN and Yifan Yang and Houwen Peng and Yifei Shen and Yuqing Yang and Han Hu and Lili Qiu and Hideki Koike},
  title = {{ImageBrush: Learning Visual In-Context Instructions for Exemplar-Based Image Manipulation}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=EmOIP3t9nk},
}
Figure