In-Context Edit: Enabling Instructional Image Editing with In-Context Generation in Large Scale Diffusion Transformer

Zechuan Zhang, Ji Xie, Yu Lu, Zongxin Yang, Yi YangarXiv 2025 · DOI

Abstract

Instructional image editing aims to modify images based on natural language commands. Current state-of-the-art models typically require massive datasets and extensive compute, while training-free methods often struggle with layout stability and complex instructions. This paper introduces ICEdit, a framework that reformulates image editing as an "in-context" generation task. By leveraging the bidirectional attention of large-scale Diffusion Transformers (DiTs) and a novel Mixture-of-Experts (MoE) fine-tuning strategy, ICEdit achieves state-of-the-art performance using only 0.1% of the training data required by previous top-tier models.

Introduction

Instructional image editing allows users to perform complex modifications—such as "make the sky a sunset" or "add a cat to the sofa"—using simple natural language. Historically, researchers have faced a trade-off between two paradigms. High-performance models like Emu Edit require over 10 million image pairs for training, necessitating massive computational resources. Conversely, training-free methods are efficient but frequently suffer from "layout instability," where the model inadvertently alters parts of the image that should remain static.

ICEdit addresses these challenges by tapping into the intrinsic knowledge of large-scale Diffusion Transformers (like FLUX). Instead of architectural overhauls, ICEdit treats the source and target images as a side-by-side diptych, allowing the model to learn the relationship between the original and the edited version through context.

Methodology

The In-Context Editing Paradigm

Rather than modifying the DiT architecture to accept a separate reference image, ICEdit formats the input as a diptych. The source image is placed on the left, and the target image is generated on the right. Because DiTs utilize bidirectional attention, the model naturally "looks" at the source image tokens to inform the generation of the target tokens. To bridge the gap between descriptive prompts (which DiTs favor) and instructional commands, ICEdit wraps user instructions in a descriptive template: "A diptych... on the right, the scene is identical to the left but [instruction]."

LoRA-MoE (Mixture of Experts)

To manage the wide variety of possible edits—ranging from texture changes to object additions—ICEdit employs a parameter-efficient Mixture-of-Experts approach. Multiple "expert" LoRA modules are integrated into the model, with a router selecting the most appropriate expert for a given task based on visual and textual tokens. This allows for specialized high-quality editing while training only 1% of the total model parameters.

Early Filter Inference-Time Scaling

To improve robustness, ICEdit introduces a selection mechanism during inference. The model samples multiple noise candidates and runs them for a limited number of denoising steps (e.g., 10 steps). A Vision-Language Model (VLM), such as Qwen-VL, acts as a judge to evaluate which candidate best aligns with the instruction. Only the highest-scoring seed is allowed to complete the full 50-step denoising process, significantly reducing the frequency of failed generations.

Experimental Setup and Results

Data and Metrics

ICEdit was trained on a curated dataset of just 50,000 samples sourced from MagicBrush and OmniEdit. This represents a 1000x reduction in data compared to models like Emu Edit. Evaluation was conducted on the Emu Edit and MagicBrush benchmarks using CLIP-I (image similarity), DINO, and the VIE-score, a GPT-4o-based metric that aligns closely with human judgment of instruction adherence.

Performance Highlights

  • State-of-the-Art Results: ICEdit matched or outperformed previous SOTA models across major benchmarks. On the Emu Test set, it achieved a CLIP-I of 0.907 and a DINO score of 0.866.
  • Extreme Efficiency: The model achieved these results with 0.1% of the training data and 1% of the trainable parameters compared to previous leading methods.
  • Layout Stability: Qualitatively, the model demonstrated an exceptional ability to preserve the identity and background of the source image while executing precise modifications.

Discussion and Limitations

Despite its efficiency, ICEdit faces challenges in spatial relocation (e.g., moving an object from one side of the room to another), likely due to a lack of motion-oriented training data. Additionally, the T5 text encoder can occasionally struggle with semantic ambiguity, such as confusing different meanings of the same word. Finally, while the Early Filter strategy improves quality, using a large VLM as a judge introduces additional computational overhead during inference.

Conclusion

ICEdit demonstrates that large-scale Diffusion Transformers are powerful in-context learners. By reframing editing as a diptych generation task and employing a Mixture-of-Experts strategy, high-quality instructional image editing becomes possible with a fraction of the data and compute previously thought necessary.

Summary updated

BibTeX
@misc{zhang2025context,
  author = {Zechuan Zhang and Ji Xie and Yu Lu and Zongxin Yang and Yi Yang},
  title = {{In-Context Edit: Enabling Instructional Image Editing with In-Context Generation in Large Scale Diffusion Transformer}},
  year = {2025},
  eprint = {2504.20690},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2504.20690},
}
Figure