In-Context Brush: Zero-shot Customized Subject Insertion with Context-Aware Latent Space Manipulation

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Xu, Yu, Tang, Fan, Wu, You, Gao, Lin, Deussen, Oliver, Yan, Hongbin, Li, Jintao, Cao, Juan, Lee, Tong-Yee
Format: Preprint
Published: 2025
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866909623710121984
author Xu, Yu
Tang, Fan
Wu, You
Gao, Lin
Deussen, Oliver
Yan, Hongbin
Li, Jintao
Cao, Juan
Lee, Tong-Yee
author_facet Xu, Yu
Tang, Fan
Wu, You
Gao, Lin
Deussen, Oliver
Yan, Hongbin
Li, Jintao
Cao, Juan
Lee, Tong-Yee
contents Recent advances in diffusion models have enhanced multimodal-guided visual generation, enabling customized subject insertion that seamlessly "brushes" user-specified objects into a given image guided by textual prompts. However, existing methods often struggle to insert customized subjects with high fidelity and align results with the user's intent through textual prompts. In this work, we propose "In-Context Brush", a zero-shot framework for customized subject insertion by reformulating the task within the paradigm of in-context learning. Without loss of generality, we formulate the object image and the textual prompts as cross-modal demonstrations, and the target image with the masked region as the query. The goal is to inpaint the target image with the subject aligning textual prompts without model tuning. Building upon a pretrained MMDiT-based inpainting network, we perform test-time enhancement via dual-level latent space manipulation: intra-head "latent feature shifting" within each attention head that dynamically shifts attention outputs to reflect the desired subject semantics and inter-head "attention reweighting" across different heads that amplifies prompt controllability through differential attention prioritization. Extensive experiments and applications demonstrate that our approach achieves superior identity preservation, text alignment, and image quality compared to existing state-of-the-art methods, without requiring dedicated training or additional data collection.
format Preprint
id arxiv_https___arxiv_org_abs_2505_20271
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle In-Context Brush: Zero-shot Customized Subject Insertion with Context-Aware Latent Space Manipulation
Xu, Yu
Tang, Fan
Wu, You
Gao, Lin
Deussen, Oliver
Yan, Hongbin
Li, Jintao
Cao, Juan
Lee, Tong-Yee
Computer Vision and Pattern Recognition
Artificial Intelligence
Graphics
Recent advances in diffusion models have enhanced multimodal-guided visual generation, enabling customized subject insertion that seamlessly "brushes" user-specified objects into a given image guided by textual prompts. However, existing methods often struggle to insert customized subjects with high fidelity and align results with the user's intent through textual prompts. In this work, we propose "In-Context Brush", a zero-shot framework for customized subject insertion by reformulating the task within the paradigm of in-context learning. Without loss of generality, we formulate the object image and the textual prompts as cross-modal demonstrations, and the target image with the masked region as the query. The goal is to inpaint the target image with the subject aligning textual prompts without model tuning. Building upon a pretrained MMDiT-based inpainting network, we perform test-time enhancement via dual-level latent space manipulation: intra-head "latent feature shifting" within each attention head that dynamically shifts attention outputs to reflect the desired subject semantics and inter-head "attention reweighting" across different heads that amplifies prompt controllability through differential attention prioritization. Extensive experiments and applications demonstrate that our approach achieves superior identity preservation, text alignment, and image quality compared to existing state-of-the-art methods, without requiring dedicated training or additional data collection.
title In-Context Brush: Zero-shot Customized Subject Insertion with Context-Aware Latent Space Manipulation
topic Computer Vision and Pattern Recognition
Artificial Intelligence
Graphics
url https://arxiv.org/abs/2505.20271