On Manipulating Scene Text in the Wild With Diffusion Models

Joshua Santoso, christian simon, Williem

Abstract

Diffusion models have gained attention for image editing yielding impressive results in text-to-image tasks. On the downside, one might notice that generated images of stable diffusion models suffer from deteriorated details. This pitfall impacts image editing tasks that require information preservation, e.g., scene text editing. As a desired result, the model must show the capability to replace the text on the source image to the target text while preserving the details, e.g., color, font size, and background. To leverage the potential of diffusion models, in this work, we introduce Diffusion-BasEd Scene Text manipulation Network, so-called DBEST. Specifically, we design two adaptation strategies, namely one-shot style adaptation and text-recognition guidance. In experiments, we thoroughly assess and compare our proposed method against state-of-the-arts on various scene text datasets, then provide extensive ablation studies for each granularity to analyze our performance gain. Also, we demonstrate the effectiveness of our proposed method to synthesize scene text indicated by competitive Optical Character Recognition (OCR) accuracy. Our method achieves 94.15% and 98.12% on COCO-text and ICDAR2013 datasets for character-level evaluation. The code is available on GitHub: https://github.com/joshuajano/DBEST

Introduction

Scene text manipulation—the process of altering text within a natural image while maintaining the original visual context—presents a significant challenge in computer vision. This task requires a precise decoupling of "style" (including font, texture, lighting, and background) from "content" (the specific characters).

Historically, Generative Adversarial Networks (GANs) have been the standard for this task. However, GANs often struggle with the high variability found in "in-the-wild" images, frequently producing blurry artifacts or failing to match the complex backgrounds of the original scene. While modern large-scale Latent Diffusion Models (LDMs) like Stable Diffusion excel at generating high-quality general imagery, they are notoriously unreliable when it comes to rendering specific, legible text strings and preserving fine-grained source details. DBEST aims to bridge this gap by harnessing the generative power of diffusion models while enforcing the structural integrity required for legible text.

Methodology

The DBEST framework is built upon a Latent Diffusion Model and utilizes a two-stage approach to achieve high-fidelity text manipulation.

Domain Pre-training

The model initially undergoes fine-tuning on a large-scale synthetic dataset, SynText (100,000 images). This stage teaches the model the general characteristics of scene text, which are often underrepresented in general-purpose text-to-image models.

Inference-Time Optimization

To handle the unique characteristics of a specific input image, DBEST employs two core strategies during the inference process:

  1. One-shot Style Adaptation: Rather than relying solely on text prompt inversion, the model's weights are briefly fine-tuned on the single source image. This process "locks in" the specific textures, colors, and background elements of the unique scene.
  2. Text Recognition Guidance: To ensure the generated output matches the user's target text, a pre-trained Optical Character Recognition (OCR) model is integrated into the pipeline. During the diffusion process, the OCR model provides a gradient via cross-entropy loss, "steering" the denoising process toward the correct target characters.
Overview of the DBEST framework, illustrating the integration of one-shot style adaptation and text recognition guidance during the diffusion process.

Evaluation and Results

The researchers evaluated DBEST against several standard benchmarks, including COCO-Text, ICDAR2013, ICDAR2015, IIIT5K, and SVT. These datasets provide a rigorous test of the model's ability to handle perspective distortion, noise, and complex artistic fonts.

Quantitative Performance

DBEST achieved state-of-the-art results, significantly outperforming previous methods. On the COCO-Text dataset, the model reached 94.15% character-level accuracy and 83.00% word-level accuracy. For comparison, the previous leading method, SRNet, achieved only 56.58% and 21.00% respectively.

Qualitative Comparison

Visual assessments demonstrate that DBEST superiorly maintains the "grain," lighting, and texture of the original photo. Competing methods like Imagic or SDEdit often fail to change the text correctly or completely lose the source style, whereas DBEST successfully handles curved text and low-resolution inputs.

Qualitative comparison of DBEST against state-of-the-art methods like SRNet, De-Render, and Imagic, showing superior style preservation and text legibility.

Conclusion

DBEST represents a significant advancement in scene text manipulation by successfully adapting diffusion models for high-precision editing. By utilizing an OCR "critic" and one-shot weight adaptation, the model ensures both legibility and stylistic consistency. While the current implementation faces challenges regarding inference speed (approximately 8 minutes per image) and dynamic spatial layout adjustment, it sets a new benchmark for fidelity in "in-the-wild" text editing. Future work will focus on optimizing inference times and improving the model's ability to handle varying text lengths within constrained spaces.

Summary updated

BibTeX
@inproceedings{santoso2024manipulating,
  author = {JOSHUA SANTOSO and christian simon and Williem},
  title = {{On Manipulating Scene Text in the Wild With Diffusion Models}},
  booktitle = {IEEE/CVF Winter Conference on Applications of Computer Vision},
  year = {2024},
  url = {https://openreview.net/forum?id=G2iu8hUSuJ},
}
Figure