ContextDrag: Precise Drag-Based Image Editing via Context-Preserving Token Injection and Position-Consistent Attention

Huiguo He, Pengyu Yan, Ziqi Yi, Weizhi Zhong, Zheng Liu, Yejun Tang, Huan Yang, Kun Gai, Guanbin Li, Lianwen Jin · OpenReview

Abstract

Drag-based image editing aims to modify visual content followed by user-specified drag operations. Despite existing methods having made notable progress, they still fail to fully exploit the contextual information in the reference image, including fine-grained texture details, leading to edits with limited coherence and fidelity. To address this challenge, we introduce ContextDrag, a new paradigm for drag-based editing that leverages the strong contextual modeling capability of editing models, such as FLUX-Kontext. By incorporating VAE-encoded features from the reference image, ContextDrag can leverage rich contextual cues and preserve fine-grained details, without the need for finetuning or inversion. Specifically, ContextDrag introduced a novel Context-preserving Token Injection (CTI) that injects noise-free reference features into their correct destination locations via a Latent-space Reverse Mapping (LRM) algorithm. This strategy enables precise drag control while preserving consistency in both semantics and texture details. Second, ContextDrag adopts a novel Position-Consistent Attention (PCA), which positional re-encodes the reference tokens and applies overlap-aware masking to eliminate interference from irrelevant reference features. Extensive experiments on DragBench-SR and DragBench-DR demonstrate that our approach surpasses all existing SOTA methods.

Introduction

Drag-based image editing allows users to intuitively manipulate visual content by defining "handle" points and dragging them to "target" locations. While conceptually simple, achieving precise spatial manipulation while maintaining high image fidelity remains a significant challenge in computer vision. Existing approaches typically fall into two categories: optimization-based methods that require time-consuming finetuning (the "Optimization Trap") and inversion-based methods that often struggle with texture preservation (the "Texture Trap").

As the field transitions from U-Net architectures to Diffusion Transformers (DiTs) like FLUX, new methodologies are required to handle spatial manipulation that respects token-based processing and positional information. ContextDrag addresses these issues by introducing a finetuning-free framework that preserves fine-grained textures and ensures spatial consistency through advanced attention mechanisms.

Methodology

ContextDrag operates on a finetuning-free paradigm, utilizing three core technical pillars to enable precise editing without the computational overhead of traditional optimization.

The ContextDrag framework overview, illustrating the Drag-Guided Editing pipeline and the Position-Consistent Attention mechanism.

Latent-space Reverse Mapping (LRM)

Rather than warping pixels in the image space, ContextDrag operates within the latent space. It employs an inverse-distance weighting algorithm to calculate the precise mapping between the reference image tokens and their destination in the edited image. This ensures that the semantic content is correctly relocated according to user drag instructions.

Context-preserving Token Injection (CTI)

To avoid the "reconstruction noise" common in inversion-based methods, ContextDrag utilizes noise-free features directly from the VAE-encoded reference image. By injecting these high-fidelity features into the diffusion process, the model can preserve intricate textures—such as animal scales or fabric patterns—that are often lost in standard noisy feature manipulation.

Position-Consistent Attention (PCA)

Diffusion Transformers rely on Rotary Position Embeddings (RoPE) to maintain spatial awareness. ContextDrag introduces PCA to resolve conflicts that arise when tokens are moved but their positional metadata remains static. This includes Positional Re-Encoding (PRE), which updates token coordinates, and Overlap-aware Attention-Masking (OAM), which prevents "ghosting" artifacts by masking out the original object's location during the attention phase.

Experimental Evaluation

The framework was evaluated on two primary benchmarks: DragBench-SR (100 images) and DragBench-DR (205 images). Evaluation metrics included Mean Distance (MD) for spatial accuracy and Image Fidelity (IF). Additionally, a GPT-4o-based pipeline was used to assess Concept Preservation (CP) and Prompt Following (PF).

Qualitative comparison of ContextDrag against several state-of-the-art methods across various editing scenarios.

Key Results

  • Superior Accuracy: On DragBench-SR, ContextDrag achieved a Mean Distance (MD) of 19.07, outperforming previous SOTA methods like Inpaint4Drag (20.57) and GoodDrag (21.90).
  • High Fidelity: The model scored 0.82 on the Prompt Following metric, indicating superior adherence to user instructions compared to existing baselines.
  • Efficiency: By eliminating the need for finetuning or complex inversion, ContextDrag is significantly faster. It processes a 1024x1024 image in approximately 84 seconds, whereas optimization-heavy methods like SDE-Drag can take over 900 seconds.

Conclusion

ContextDrag demonstrates that precise, high-fidelity drag-based editing can be achieved without the need for model finetuning. By leveraging noise-free VAE features and recalibrating positional embeddings within a DiT architecture, the framework sets a new state-of-the-art for the field. While currently limited in handling complex 3D-like deformations (such as flipping objects), future work will explore more sophisticated deformation fields to address non-linear spatial transformations.

Summary updated

BibTeX
@misc{he2025contextdrag,
  author = {Huiguo He and Pengyu Yan and Ziqi Yi and Weizhi Zhong and Zheng Liu and Yejun Tang and Huan Yang and Kun Gai and Guanbin Li and Lianwen Jin},
  title = {{ContextDrag: Precise Drag-Based Image Editing via Context-Preserving Token Injection and Position-Consistent Attention}},
  year = {2025},
  eprint = {2512.08477},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2512.08477},
}
Figure