TPFNet: A Novel Text In-painting Transformer for Text Removal

Onkar Susladkar, Dhruv Makwana, Gayatri Deshmukh, Sparsh Mittal, Sai Chandra Teja R, Rekha Singhal

TL;DR

TPFNet is a novel, end-to-end text removal network that splits the task into low-resolution feature synthesis and high-resolution image generation. By combining a Pyramidal Vision Transformer (PVT) with a multi-headed decoder and a segmentation-conditional adversarial loss, it achieves state-of-the-art text erasure and image in-painting performance without destroying background details.

What Problem Does This Paper Address?

Text removal (or text erasure) from images is a crucial task for privacy preservation (e.g., redacting sensitive information like phone numbers or addresses from street views) and image editing (e.g., translating text on signs).

Unlike standard image in-painting where the user manually provides a mask of the region to fill, automatic text removal requires the network to both locate the text and erase it seamlessly. This is highly challenging because text lacks clear border lines, varies wildly in font, size, color, and orientation, and often blends into complex background textures. Existing methods frequently suffer from blurred outputs, fail to completely erase text strokes, or accidentally delete text-like background objects such as logos and symbols.

Methods

TPFNet introduces a progressive, two-part architecture trained in an end-to-end framework:

  1. Part 1: Feature Synthesis (Low-Resolution): Because it is simpler to eliminate noise and text features from lower-dimensional spaces, the input $512 \times 512$ image is first downsampled to $256 \times 256$. A Pyramidal Vision Transformer (PVT) serves as the encoder to capture multi-scale feature maps. The decoder features a novel multi-headed structure with three distinct branches that simultaneously predict:
  2. A binary segmentation map (to precisely locate text).
  3. A high-pass filtered image (using a Laplacian filter to capture structural edges).
  4. A low-resolution text-free image. An attention block fuses the knowledge from the segmentation and edge branches back into the main text-free generation branch.

  5. Part 2: Image Generation (High-Resolution): This stage takes the synthesized features from Part 1 and uses transpose convolutions alongside Conv blocks with Squeeze-and-Excitation (SE) blocks to upscale the image back to a clean, high-quality $512 \times 512$ text-free output.

Overview of Part 1: Feature Synthesis
Overview of Part 2: Image Generation

Novel Loss Function: Standard conditional GANs condition their discriminator on the original input image. TPFNet instead conditions its PatchGAN discriminator on the predicted segmentation map. This forces the adversarial loss to focus strictly on the regions where text was removed, ensuring realistic texture generation.

Datasets

The authors evaluated TPFNet on three open-source datasets:

  • Oxford Synthetic Real Scene Text Detection Dataset: Approximately 800,000 synthetic images combining natural backgrounds with diverse text properties. Used primarily for pre-training.
  • SCUT Synthetic Text Removal Dataset (SCUT-8K): Contains 8,000 training and 800 test images.
  • SCUT-EnsText Dataset: A real-world dataset containing 3,562 images with highly diverse, naturally occurring text.

Key Insights and Ideas

  • Resolution-Staged In-painting: Operating on a lower resolution ($256 \times 256$) first allows the network to focus on the semantic task of text erasure without getting bogged down by high-frequency texture details. Part 2 can then focus purely on super-resolution and texture reconstruction.
  • Multi-Task Synergy: Forcing the decoder to learn text segmentation and edge detection simultaneously provides powerful structural priors. The high-pass filter branch acts as a guide to preserve background geometry, preventing the "blurry smudge" effect common in older models.
  • Targeted Discriminator Conditioning: By conditioning the discriminator on the segmentation mask rather than the full input image, the network receives much sharper gradient signals regarding how well the text regions specifically have been inpainted.

Key Results

TPFNet significantly outperformed previous state-of-the-art models (such as EnsNet and EraseNet) across nearly all quantitative metrics:

  • SCUT-EnsText Benchmarks: TPFNet achieved a Peak Signal-to-Noise Ratio (PSNR) of 39.00 and an SSIM of 0.9730, drastically beating EraseNet (PSNR: 32.29, SSIM: 0.9542).
  • Erasure Cleanliness: To measure how thoroughly text was removed, the authors ran an independent text detector on the output images. A lower detection precision means cleaner erasure. TPFNet dropped text detection precision to 21.12% on SCUT-EnsText, compared to EraseNet's 53.20%.
  • Qualitative Performance: Visually, TPFNet successfully differentiates between actual text and text-like background elements. For instance, it leaves warning symbols and logos intact while cleanly wiping out adjacent text characters.
Figure 4: Qualitative results on SCUT-8K dataset

Limitations and Future Work

Despite its strong performance, the authors note a few remaining challenges:

  • Extreme Angles & Overlapping Text: TPFNet still struggles to perfectly segment and erase heavily overlapping characters or text captured at highly oblique camera angles.
  • Multilingual Generalization: The model is bound by its training data languages. The authors plan to explore unsupervised learning approaches in the future to enable the network to remove text in languages it has never seen during training.

Summary updated

Abstract

Text erasure from an image is helpful for various tasks such as image editing and privacy preservation. In this paper, we present TPFNet, a novel one-stage (end-toend) network for text removal from images. Our network has two parts: feature synthesis and image generation. Since noise can be more effectively removed from low-resolution images, part 1 operates on low-resolution images. The output of part 1 is a low-resolution text-free image. Part 2 uses the features learned in part 1 to predict a high-resolution text-free image. In part 1, we use "pyramidal vision transformer" (PVT) as the encoder. Further, we use a novel multi-headed decoder that generates a high-pass filtered image and a segmentation map, in addition to a text-free image. The segmentation branch helps locate the text precisely, and the high-pass branch helps in learning the image structure. To precisely locate the text, TPFNet employs an adversarial loss that is conditional on the segmentation map rather than the input image. On Oxford, SCUT, and SCUT-EnsText datasets, our network outperforms recently proposed networks on nearly all the metrics. For example, on SCUT-EnsText dataset, TPFNet has a PSNR (higher is better) of 39.0 and text-detection precision (lower is better) of 21.1, compared to the best previous technique, which has a PSNR of 32.3 and precision of 53.2. The source code can be obtained from https://github.com/CandleLabAI/TPFNet
BibTeX
@inproceedings{susladkar2022tpfnet,
  author = {Onkar Susladkar and Dhruv Makwana and Gayatri Deshmukh and Sparsh Mittal and Sai Chandra Teja R and Rekha Singhal},
  title = {{TPFNet: A Novel Text In-painting Transformer for Text Removal}},
  booktitle = {ICDAR},
  year = {2022},
  url = {https://openreview.net/forum?id=Eu7rWcTS7n},
}
Figure