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

TextCtrl: Diffusion-based Scene Text Editing with Prior Guidance Control

Weichao Zeng, Yan Shu, Zhenhang Li, Dongbao Yang, Yu Zhou

Introduction

Scene Text Editing (STE) is the task of modifying text within a natural image while maintaining the original background, font style, and environmental lighting. While generative models have advanced significantly, existing approaches often struggle with "style drift"—where the new text fails to match the original aesthetic—and "rendering errors," such as typos or illegible characters. TextCtrl addresses these challenges by introducing a diffusion-based framework that explicitly disentangles text style from glyph structure and employs a novel attention mechanism to ensure high-fidelity rendering.

The Challenges of Scene Text Editing

Current STE methodologies generally fall into two categories: GAN-based and Diffusion-based models. GAN-based methods typically utilize a "divide-and-conquer" strategy, separating text transfer from background restoration. However, these models often fail to generalize to "in-the-wild" images, resulting in noticeable artifacts at the boundaries of edited text.

In contrast, Diffusion-based models possess superior generative capacity but are often "unconstrained." This lack of constraint leads to two primary issues:

  1. Style Deviations: The generated text may not accurately reflect the color, texture, or lighting of the source.
  2. Rendering Errors: The weak correlation between text prompts and visual structures often results in spelling mistakes or nonsensical glyphs.

Methodology: Prior Guidance Control

TextCtrl overcomes these limitations by guiding a conditional diffusion model with two specific priors: Fine-grained Style and Robust Structure.

1. Style-Structure Disentanglement

The framework utilizes two pre-trained encoders to explicitly separate the "what" from the "how":

  • Text Glyph Structure Encoder ($\mathcal{T}$): A transformer-based encoder trained with "font-variance augmentation." By exposing the model to a vast array of fonts, it learns the fundamental structural properties of characters, making it robust against stylistic variations.
  • Text Style Encoder ($\mathcal{S}$): Trained via a multi-task paradigm involving color transfer, font transfer, text removal, and segmentation. This forces the encoder to isolate stylistic elements (texture, color, lighting) from the underlying character shapes.

2. Glyph-adaptive Mutual Self-attention (GaMuSa)

To maintain consistency with the source image during inference, TextCtrl introduces the Glyph-adaptive Mutual Self-attention (GaMuSa) mechanism. The process begins with DDIM inversion to create a parallel "reconstruction branch" of the original image. During denoising, the model "borrows" features from this branch via mutual self-attention. The "glyph-adaptive" component uses a vision encoder to measure the similarity between the current generation and the target text, dynamically adjusting style injection to ensure the output remains both legible and stylistically faithful.

Datasets and Evaluation

The authors trained TextCtrl on 200k synthetic paired images and introduced ScenePair, the first real-world pairwise dataset for STE. ScenePair contains 1,280 image pairs from datasets like ICDAR 2013 and HierText, featuring different words in identical environments to provide a true benchmark for style consistency.

Key Results

TextCtrl demonstrates significant improvements over state-of-the-art models like AnyText and DiffSTE:

  • Accuracy: On the ScenePair benchmark, TextCtrl achieved a word accuracy (ACC) of 84.67%, vastly outperforming AnyText (51.12%) and MOSTEL (37.69%).
  • Fidelity: The model achieved superior Fréchet Inception Distance (FID) and Peak Signal-to-Noise Ratio (PSNR) scores, indicating higher image quality and better stylistic alignment.
  • Qualitative Performance: Visual evaluations show that TextCtrl excels at mimicking complex textures, such as weathered wood or neon glows, while maintaining clean background transitions.

Conclusion and Future Work

TextCtrl represents a significant step forward in STE by replacing unconstrained generation with explicit prior guidance. By utilizing a parallel reconstruction branch as a "style anchor," the model avoids the common pitfalls of hallucination and style drift.

However, limitations remain. The current framework lacks a "geometric prior," making it difficult to edit text on highly curved or 3D-projected surfaces. Future research will focus on integrating geometric controls, such as Thin Plate Spline (TPS) transformations, to handle non-linear text layouts and improving evaluation metrics to better capture human-aligned "style coherency."

Summary updated

BibTeX
@inproceedings{zeng2024textctrl,
  author = {Weichao Zeng and Yan Shu and Zhenhang Li and Dongbao Yang and Yu Zhou},
  title = {{TextCtrl: Diffusion-based Scene Text Editing with Prior Guidance Control}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=SQVns9hWJT},
}
Figure