UPOCR: Towards Unified Pixel-Level OCR Interface

Dezhi Peng, Zhenhua Yang, Jiaxin Zhang, Chongyu Liu, Yongxin Shi, Kai Ding, Fengjun Guo, Lianwen Jin

TL;DR

UPOCR is a "generalist" model that unifies diverse pixel-level OCR tasks—such as erasing text, segmenting strokes, and detecting tampered text—into a single image-to-image translation framework. By using a Vision Transformer (ViT) backbone with learnable task prompts, it achieves state-of-the-art performance across multiple benchmarks simultaneously, proving that specialized architectures are no longer a prerequisite for high-accuracy OCR.

The Problem: A Fragmented OCR Landscape

Traditionally, Optical Character Recognition (OCR) has been a highly fragmented field. If you wanted to remove text from an image (text removal), you’d build a specific GAN-based architecture. If you wanted to highlight text strokes (segmentation), you’d build a completely different model. If you wanted to find forged text in a document (tampered detection), you’d likely need a third model specializing in frequency analysis.

High-level concept of UPOCR unifying three distinct OCR tasks.

This fragmentation creates massive overhead for research and deployment. These specialized models use different input formats, loss functions, and training tricks. The authors of UPOCR ask a simple question: Can we treat all pixel-level OCR tasks as a simple image-to-image transformation?

Methods: The UPOCR Framework

The authors introduce UPOCR (Unified Pixel-level OCR interface). Its design rests on four core pillars:

Detailed architecture of UPOCR showing the unified paradigm, architecture, and training strategy.
  1. Unified Paradigm: Every task is treated as an RGB-to-RGB translation. For text removal, the output is the "cleaned" image. For segmentation or tampered detection, the output is a color-coded mask (e.g., red for tampered text, green for real text).
  2. ViT-based Architecture: The model uses a Swin Transformer v2 encoder-decoder. Unlike previous models that rely on complex, multi-stage refinements, UPOCR uses a standard hierarchical structure to extract and reconstruct features.
  3. Learnable Task Prompts: This is the framework's "secret sauce." Instead of using natural language prompts (which can be ambiguous), the authors insert learnable embeddings into the feature space between the encoder and decoder. These prompts act as a steering wheel, pushing the general features extracted by the encoder into task-specific regions so the decoder knows exactly what to generate.
  4. Unified Loss: The model is trained by simply minimizing the difference between the predicted image and the ground truth at both the pixel level (L1 loss) and the feature level (perceptual and style losses).

Datasets and Evaluation

The model was evaluated on three distinct tasks using well-known benchmarks:

  • SCUT-EnsText: For scene text removal.
  • TextSeg: For fine-grained text segmentation.
  • Tampered-IC13: For detecting tampered text in the wild.

Notably, the Tampered-IC13 dataset is quite small (only 229 training samples). UPOCR’s ability to perform well here highlights the benefits of joint training across multiple tasks.

Key Insights

  • The Power of "Text-ness": One of the biggest takeaways is that joint training helps data-starved tasks. By learning what text looks like from the large segmentation and removal datasets, the model becomes much better at identifying tampered text, even with very few specific examples.
  • Task Prompts as Feature Offsets: Using t-SNE visualizations, the authors showed that the learnable prompts effectively cluster features. General features are "pushed" into distinct zones for removal, segmentation, or detection, allowing the same weights to serve three different masters.
  • Simplicity is Scalable: By stripping away task-specific modules (like external text detectors or frequency fusion branches), UPOCR proves that a sufficiently powerful vision backbone can learn these internal representations implicitly.

Key Results

UPOCR doesn't just "work" on multiple tasks; it often beats the specialists:

  • Text Removal: Achieved a 37.14 PSNR on SCUT-EnsText, outperforming the previous state-of-the-art (ViTEraser).
  • Text Segmentation: Reached 88.76% fgIoU, surpassing specialized models like ARM-Net.
  • Tampered Text Detection: Achieved a 71.71% mIoU, a significant jump over traditional segmentation-based methods like DeepLabV3+.
  • Efficiency: The model runs at 17 FPS on an NVIDIA RTX 3090, making it viable for real-time applications.

Limitations and Future Work

While highly effective, UPOCR has a few limitations. The current prompts are learned during training, meaning that adding a new task (e.g., layout analysis) requires re-training the model. The authors suggest that automatic learning of prompts from a few examples is a key direction for future work. Additionally, the model can still struggle with "inconspicuous correlations"—extremely subtle text erasures that lack a strong visual signature.

Ultimately, the authors believe this unified interface could eventually be expanded beyond pixel-level tasks to include text recognition and broader document understanding.

Check out the code: https://github.com/shannanyinxiang/UPOCR

Summary updated

BibTeX
@inproceedings{peng2024upocr,
  author = {Dezhi Peng and Zhenhua Yang and Jiaxin Zhang and Chongyu Liu and Yongxin Shi and Kai Ding and Fengjun Guo and Lianwen Jin},
  title = {{UPOCR: Towards Unified Pixel-Level OCR Interface}},
  booktitle = {International Conference on Machine Learning},
  year = {2024},
  url = {https://openreview.net/forum?id=rEZ24oJhbn},
}
Figure