RePlan: Reasoning-Guided Region Planning for Complex Instruction-Based Image Editing

Tianyuan Qu, Lei Ke, Xiaohang Zhan, Longxiang Tang, Yuqi Liu, Bohao Peng, Bei Yu, Dong Yu, Jiaya Jia · Submission to ICLR 2026 · Rejected

TL;DR

RePlan tackles complex, reasoning-heavy image editing by coupling a vision–language planner with a diffusion editor through a plan-then-execute paradigm. By training a VLM planner with GRPO reinforcement learning on just ~1K instruction-only samples and executing edits via a training-free attention-masking mechanism on MMDiT backbones, RePlan performs parallel, multi-region edits with high consistency and minimal semantic bleeding.

What Problem Does This Paper Address?

Instruction-based image editing typically excels when instructions are explicit ("make the cat brown") and scenes are simple. However, real-world editing frequently suffers from Instruction–Visual Complexity (IV-Complexity):

  • Visual ambiguity: Cluttered backgrounds, multiple similar objects, or occlusions.
  • Linguistic/Reasoning ambiguity: Multi-step edits, implicit physical/temporal reasoning ("adjust the heaters to reflect the cooling evening"), or knowledge-based queries.

Existing end-to-end models (such as InstructPix2Pix or unified VLM-diffusion architectures) treat vision-language models simply as global semantic encoders. As a result, edits often "bleed" into unrelated regions, or the model fails to modify the intended object. Meanwhile, traditional multi-round inpainting pipelines suffer from cumulative image degradation and slow, sequential inference.

Methods

RePlan divides complex editing into explicit planning and parallel execution:

[Image + Instruction] 
         │
         ▼
[VLM Planner (Qwen2.5-VL 7B)] ── CoT Reasoning ──► Global hint + Local {BBox, Hint} pairs
         │
         ▼
[Diffusion Decoder (MMDiT)]  ── Training-Free Attention Region Injection ──► Final Image
  1. Reasoning-Guided Region Planner: A VLM generates chain-of-thought (CoT) reasoning, producing structured JSON outputs containing global hints (e.g., style changes) and localized bounding boxes paired with sub-instructions or negative hints ("keep this region unchanged").
  2. Two-Stage GRPO Reinforcement Learning: Using Group Relative Policy Optimization (GRPO) on only 1K instruction-only examples:
  3. Stage 1 (Format & Reasoning): Rewards proper tag structures, valid JSON formatting, and CoT reasoning length/quality.
  4. Stage 2 (Visual Execution): Uses Qwen2.5-VL 72B as a reward evaluator measuring target localization ($R_T$), instruction effect ($R_E$), and background consistency ($R_C$). Consistency is reweighted by effect ($R_C \cdot R_E$) to penalize models that achieve "consistency" by making no changes at all.
  5. Training-Free Attention Region Injection: During MMDiT denoising (e.g., Flux.1 Kontext or Qwen-Image-Edit), cross-token attention is constrained via 5 rules:
  6. Intra-group: Tokens within the same modality or bounding-box patch group are fully connected.
  7. Hint isolation: Distinct regional instruction text tokens cannot attend to one another, preventing prompt contamination.
  8. Image–latent connectivity: Latent and image tokens remain globally connected to preserve seamless boundaries and overall image coherence.
  9. Region/Background constraints: Image patches only attend to their assigned region hints and global hints; background patches only attend to global hints.

Datasets

  • Training Data: ~1,000 instruction-only samples curated from COCO, LISA ReasonSeg, TextSceneHQ, TableVQA-Bench, and TableQA, filtered using Gemini 2.5 Pro and Qwen2.5-VL-72B.
  • IV-Edit Benchmark (New): A newly constructed evaluation benchmark containing ~800 instruction–image pairs (averaging 21 words per instruction, with 182 multi-target cases). It spans:
  • 7 Referring Types: Visual, Structural, Content (for text/document tasks), and Feature, Spatial, Knowledge, Understanding (for real-world photography).
  • 16 Task Types: Direct object modifications (Add/Delete/Replace), attribute/pose shifts, reasoning/prediction tasks (Physics, Scenario, Open-ended), and text-rendering edits.

Key Insights and Ideas

  • Text Decoupling Eliminates Semantic Spillover: The primary culprit behind unwanted edits is cross-attention interference between unrelated text prompts and visual tokens. Restricting attention masks so that background tokens see only global instructions while region tokens see only their sub-prompts isolates edits without needing iterative inpainting.
  • Global Image-Latent Attention Preserves Boundaries: Completely severing attention between edited patches and background patches causes stark boundary seams. Allowing image and latent tokens to stay fully connected preserves global style and natural transitions.
  • Background Tokens Need Text: Completely removing text attention from untouched background patches resulted in severe noise and distortion—indicating text tokens help anchor feature representations inside the diffusion backbone.
  • Coarse Bounding Boxes Suffice: Perturbing bounding-box coordinates by up to 50% shifted scores by less than 0.02 on weighted metrics, demonstrating that the attention-injection mechanism is remarkably tolerant to rough spatial localization.

Key Results

Evaluated by Gemini-2.5-Pro across Target, Consistency, Quality, and Effect:

  • State-of-the-Art Open-Source Performance: On the IV-Edit benchmark, RePlan (Qwen-Image) achieved an Overall score of 3.51 and a Weighted score of 2.91, outperforming base Qwen-Image (3.05 / 2.62), Bagel-Think (3.05 / 2.46), and Flux.1 Kontext Dev (3.22 / 2.49).
  • Superior Consistency: RePlan (Flux.1 Kontext) reached 3.64 Consistency (vs. 2.88 for Flux.1 Kontext Dev, 1.79 for Qwen-Image, and 1.77 for GPT-4o), effectively ending instruction leakage into surrounding areas.
  • RL Alignment is Essential: Off-the-shelf zero-shot planners (Gemini 2.5 Pro at 2.95 Overall; Qwen2.5-VL 7B at 2.60 Overall) struggled with box accuracy and format compliance, confirming the necessity of two-stage GRPO training.

Limitations and Future Work

  • Cascading Errors: If the VLM planner misidentifies targets or produces drastically wrong bounding boxes, the diffusion editor cannot recover.
  • Scope of Generation: Edits that require radical whole-scene semantic shifts or drastic geometry re-generation may still test the boundaries of box-level attention constraints.
  • Future Directions: Incorporating interactive human-in-the-loop workflows (allowing users to adjust VLM-generated bounding boxes or prompts on the fly) and expanding attention-injection mechanisms to video editing.

Summary updated

BibTeX
@misc{qu2025replan,
  author = {Tianyuan Qu and Lei Ke and Xiaohang Zhan and Longxiang Tang and Yuqi Liu and Bohao PENG and Bei Yu and Dong Yu and Jiaya Jia},
  title = {{RePlan: Reasoning-Guided Region Planning for Complex Instruction-Based Image Editing}},
  year = {2025},
  eprint = {2512.16864},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2512.16864},
}
Figure