NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

EditText: Structure-Aware Generation and Selective Visual Transport for Fine-Grained Text Editing

Zhaobin Chu, Guandong Li, Xin Lv, Zhiwei Zeng

TL;DR

Replacing text inside an image with generative AI usually involves an annoying trade-off: either the new letters look slightly off-style, or the model subtly hallucinates and blurs the rest of your unedited background. EditText solves both problems at once by splitting the task inside a single Diffusion Transformer—generating fresh, style-matched characters inside the edit box while actively "transporting" untouched visual details directly from the source image. It nails everything from tiny receipt numbers to intricate Chinese calligraphy without messing up a single background leaf.

Figure 2. Text Editing through Generation and Visual Trans- port. Inside the orange dashed box, the model replaces “0000” with “699” in the original lettering style. The green boxes high- light roof and foliage details that the model preserves by reusing visual features from the masked source image.

What Problem Does This Paper Address?

Editing text in the wild is deceptively hard. Imagine changing "0000" to "699" on a busy travel poster, updating a tiny dimension label in an installation diagram, or swapping complex Chinese characters on a curved emblem.

Different scripts fight you in different ways: alphabetic words change length and spacing, logographic characters (like Chinese) pack dense strokes into tiny boxes, and numerals demand crisp alignment. Meanwhile, standard generative image editors regenerate the entire image at once. Even when you give the model a source image as a condition, small details outside your edit box—adjacent text, foliage, fine textures—often degrade or drift. Existing models struggle to simultaneously render discrete, structurally accurate new characters, clone the exact font/color/texture of the old text, and keep the unedited pixels frozen in place.

Methods

Built on a Diffusion Transformer (DiT) using Flow Matching (initialized from Qwen-Image-Edit-2511), EditText introduces three clever mechanisms alongside a two-stage training recipe:

  • Dual-Condition Fill: Instead of feeding the model just a masked image, EditText splits the source image into two spatially aligned canvases. The masked image blacks out the edit box so the model can reuse the unedited surroundings. The style reference does the exact inverse—keeping only the original text crop on a black background—giving the model direct font, color, and perspective cues without needing rendered target glyph templates at inference.
  • Selective Visual Transport (Attention Transport): The authors mathematically decompose how an output token attends to the masked source image into Source Weight (how much total attention goes to the source image) and a Spatial Aggregation Kernel (where spatially inside that image it looks). At inference time—requiring zero extra trainable parameters—they intercept queries in a 4-token boundary band right outside the edit box. Keeping the total Source Weight fixed, they re-weight the internal spatial distribution to focus tightly on the matching spatial neighborhood, preventing background details from blurring.
  • Two-Stage Training & Glyph-Aware Structural Loss:
  • Stage 1 (Reconstruction): Full-parameter fine-tuning where the model simply reconstructs masked text using the original OCR string and no style reference.
  • Stage 2 (Replacement): LoRA fine-tuning on actual text-replacement pairs using the style reference. Because small text boxes contribute almost nothing to a global pixel loss, Stage 2 adds a Glyph-aware Structural Loss—comparing Scharr edge gradients on the predicted clean latents inside the edit box, weighted spatially by an offline target glyph map.

Datasets

  • Training Data: Stage 1 uses 500,000 real images with OCR-annotated text masks for self-supervised reconstruction. Stage 2 uses 21,061 paired text-replacement examples where source and target strings differ.
  • TBench (New Benchmark): Because OCR metrics ignore visual style and full-image similarity metrics miss tiny character typos, the authors built TBench. It contains 400 diverse tasks across scene text, UI screens, posters, and receipts, split cleanly into Alphabetic (26.00%), Logographic (39.25%), and Arabic numerals (34.75%), specifically testing length changes, dense layouts, and ultra-small text (many taking up $<0.5\%$ of image area).

Key Insights and Ideas

  • Having the pixels isn't enough; spatial routing matters: In a neat diagnostic experiment, the authors circularly shifted source image latents horizontally by just 1 to 4 tokens while keeping all token values identical. Background preservation degraded immediately. Just handing a DiT a source image doesn't guarantee it copies details cleanly—it must aggregate from the exact corresponding spatial coordinates.
  • Decoupling "how much" from "where" in attention: By preserving the total attention mass allocated to the masked image while sharpening where it looks locally, you get crisp detail preservation (boosting non-edit SSIM from 0.9231 to 0.9786 in ablations) without throwing off the global balance between text and image tokens during generation.
  • Supervising structure without ruining texture: Applying structural gradient loss on predicted clean latents—using rendered glyphs only as spatial loss weights rather than pixel targets—teaches crisp character strokes while letting the model inherit natural lighting and texture from the target image.

Key Results

On TBench, EditText outperforms strong open and commercial baselines (including Qwen-Image-Edit, Seedream, FireRed, GPT-image, and Nano Banana variants):

  • State-of-the-art Preservation: Achieves 0.9769 non-edit-region SSIM and 0.0460 full-image LPIPS (lower is better), virtually eliminating background drift.
  • Top Text Accuracy & Human Preference: Reaches the lowest normalized edit distance (0.2352 ED), competitive OCR inclusion (70.93%), and takes the #1 spot in human evaluation with a 76.68% pass rate (edging out Nano Banana Pro at 75.00% and gpt-image-2.5-sunburst at 68.79%).
Figure 1. Fine-grained text editing across three text categories. From top to bottom, two rows each present Alphabetic, Logographic, and Arabic numerals, for a total of 17 examples. Each pair shows the source image with a red edit box on the left and the corresponding result on the right. Full images are tightly arranged at their original aspect ratios. Alphabetic examples include phrase length changes, logo letters, dense storefront text, and very small English text. Logographic examples include outlined subtitles, curved team emblems, scene plaques, dense body text, and very small handwritten and screen text. Arabic numeral examples include screen numerals, digit-count changes, small text on posters, and very small dimension labels in installation diagrams.

Limitations and Future Work

  • Encoding bottlenecks: Because EditText operates in latent space, reusing ultra-fine background details is still capped by what the VAE encoder can preserve without loss.
  • Style-structure entanglement: Because the style reference image literally shows the old letters, those original strokes occasionally bleed through, leaving behind minor stroke errors or ghost remnants in the newly generated text.
  • Box constraints: Drastic changes in phrase length still have to squeeze or stretch inside a fixed user-defined edit box. Future work aims to improve latent detail encoding, cleanly disentangle visual style from character geometry, and support length-adaptive bounding layouts.

Summary updated

BibTeX
@misc{chu2026edittext,
  author = {Zhaobin Chu and Guandong Li and Xin Lv and Zhiwei Zeng},
  title = {{EditText: Structure-Aware Generation and Selective Visual Transport for Fine-Grained Text Editing}},
  year = {2026},
  eprint = {2611.32134},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.32134},
}
Figure