Insert Anything: Image Insertion via In-Context Editing in DiT

Wensong Song, Hong Jiang, Zongxing Yang, Ruijie Quan, Yi Yang · OpenReview

Abstract

This work presents Insert Anything, a unified framework for reference-based image insertion that seamlessly integrates objects from reference images into target scenes under flexible, user-specified control guidance. Instead of training separate models for individual tasks, our approach is trained once on our new AnyInsertion dataset—comprising 120K prompt-image pairs covering diverse tasks such as person, object, and garment insertion—and effortlessly generalizes to a wide range of insertion scenarios. To address the challenge of capturing both identity features and fine-grained details while allowing local adaptations, we leverage the multimodal attention of the Diffusion Transformer (DiT) to support both mask- and text-guided editing. Furthermore, we introduce an in-context editing mechanism that treats the reference image as contextual information, employing two prompting strategies to harmonize the inserted elements with the target scene while faithfully preserving their distinctive features. Extensive experiments on AnyInsertion, DreamBooth, and VTON-HD benchmarks demonstrate that our method consistently outperforms existing alternatives.

Introduction

Reference-based image insertion—the process of transplanting an object from one image into another realistically—is a fundamental task in creative AI. Historically, this field has been fragmented into specialized sub-tasks like virtual try-on, face swapping, or product placement. These specialized models often struggle with two main issues: rigid control modes (forcing a choice between masks or text) and visual-reference disharmony (failing to preserve fine-grained identity while matching the target scene's lighting and texture). Insert Anything addresses these by treating all insertion tasks as a single "in-context editing" problem within a unified DiT architecture.

Methodology

The core of the framework is built upon the Diffusion Transformer (DiT) architecture, specifically the FLUX.1 [dev] model. Unlike traditional UNet-based models that rely on external encoders to inject reference features, this approach introduces an In-Context Editing mechanism.

The "Polyptych" Strategy

The model processes the reference and target images as a single, concatenated visual input. For precise placement, it utilizes a Mask-Prompt Diptych [Reference Object | Masked Source Image]. For text-guided edits, it uses a Text-Prompt Triptych [Reference Object | Source Image | Empty Region]. By feeding these side-by-side images into the DiT, the model’s multimodal attention mechanism naturally learns the relationship between the reference object and the target environment, reasoning about how the object should look given the surrounding context.

Figure 1: Demonstration of the Insert Anything framework performing reference-based garment insertion. The system preserves the intricate details of the reference boots while harmonizing them with the character's pose and the scene's lighting.

Technical Refinements

  • Hybrid Masking: The model is trained on a mix of precise segmentation masks and loose bounding boxes, ensuring robustness to varied user inputs.
  • Adaptive Crop-and-Zoom: To preserve high-frequency details in small objects (e.g., jewelry), the system dynamically zooms in on the insertion area during inference.

Data and Benchmarking

The authors introduce AnyInsertion, the first large-scale, open-source dataset for general-purpose image insertion, containing 120,000 prompt-image pairs. It covers a vast range of categories including humans, garments, furniture, and vehicles. The model was evaluated against this new benchmark as well as standard datasets like DreamBooth and VTON-HD.

Results and Discussion

Insert Anything achieves state-of-the-art (SOTA) performance across all tested categories. On the AnyInsertion benchmark, it achieved an SSIM of 0.8791, significantly outperforming previous methods like AnyDoor (0.7648). In virtual try-on tasks (VTON-HD), it surpassed specialized models in both image quality (FID) and structural similarity (SSIM).

Key insights include:

  • Unified Models Over Specialized Ones: A single model trained on diverse data can outperform domain-specific SOTA models.
  • Identity Preservation: Treating the reference as "context" preserves identity features (like text or specific textures) more faithfully than external feature extractors like IP-Adapter.
  • DiT Scalability: The spatial reasoning of Transformers is better suited for complex "transplant" operations than the local-receptive-field constraints of traditional UNets.

Conclusion

While Insert Anything sets a new standard for image insertion, future work will focus on improving physical constraint modeling (e.g., gravity and contact points) and reducing computational costs through techniques like Mixture of Experts (MoE). The framework demonstrates the immense potential of DiT-based in-context editing for real-world applications in e-commerce, virtual try-on, and creative content generation.

Summary updated

BibTeX
@inproceedings{song2026insert,
  author = {Wensong Song and Hong Jiang and Zongxing Yang and Ruijie Quan and Yi Yang},
  title = {{Insert Anything: Image Insertion via In-Context Editing in DiT}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2026},
  doi = {10.1609/aaai.v40i11.37866},
}
Figure