LEGO: Self-Supervised Representation Learning for Scene Text Images

Yujin Ren, Jiaxin Zhang, Lianwen JinarXiv 2024 · DOI

Introduction

Scene Text Recognition (STR)—the ability to read text in natural environments—is a critical component of many computer vision systems. Traditionally, STR models rely on massive amounts of synthetic data because labeling real-world images is prohibitively expensive. However, a significant "domain gap" exists: models trained on pristine synthetic text often struggle with the blur, lighting variations, and perspective distortions found in real-world photos.

While Self-Supervised Learning (SSL) has transformed fields like Natural Language Processing (NLP) and general Computer Vision, applying it to text images presents unique challenges. Text possesses a hierarchical structure (strokes to characters to words), high information density (where losing a few pixels can change an 'E' to an 'F'), and strict sequentiality. The LEGO (Local Explicit and Global Order-aware) framework addresses these hurdles by introducing a specialized "Text Knowledge Codebook" to provide structural and semantic priors during the learning process.

The LEGO Framework

LEGO is designed to learn robust representations from unlabeled data by mimicking the way humans learn to read: distinguishing characters, reconstructing their structure, and understanding their sequence. The core of the system is the Text Knowledge Codebook, a discrete quantizer based on a modified Vector Quantized Variational Autoencoder (T-VQVAE).

Overview of the LEGO framework, illustrating the three pre-text tasks: Selective Individual Discrimination (SID), Enhanced Masked Image Modeling (MIM), and Random-ordered Text Rearrangement (RTR).

The Text Knowledge Codebook and "De-styling"

A primary innovation of LEGO is its ability to separate content from style. In standard contrastive learning, two different images of the letter "A" might be treated as negative samples, pushing their representations apart. LEGO's codebook acts as a "de-styler," mapping different visual instances of the same character component to the same latent index. This allows the model to focus on the underlying character structure rather than background noise or font variations.

Visualization of the Text Knowledge Codebook, showing how different visual styles of the same character components are mapped to the same latent index.

Pre-training Tasks

LEGO utilizes the codebook to facilitate three novel pre-text tasks that drive the learning of text-specific features:

  1. Selective Individual Discrimination (SID): This task improves contrastive learning by using the codebook to filter out "false negatives." If two different image patches represent the same character, SID recognizes them as similar, preventing the model from learning divergent representations for the same content.
  2. Enhanced Masked Image Modeling (MIM): To address the high information density of text, LEGO provides "hints" from the codebook via cross-attention. Instead of guessing masked pixels from scratch, the model uses consistent text priors to reconstruct the underlying structure of characters.
  3. Random-ordered Text Rearrangement (RTR): This task focuses on sequentiality. The image is sliced into vertical strips and shuffled; the model must then predict the original order. The codebook helps identify identical slices (e.g., the two 'l's in "hello") so the model is not penalized for swapping indistinguishable components.

Experimental Results

LEGO demonstrates superior performance across multiple benchmarks and tasks:

  • Linear Probe Evaluation: When the encoder is frozen, LEGO achieves significantly higher accuracy than previous state-of-the-art (SOTA) methods. For instance, on the IC13 dataset, LEGO reached 75.9% accuracy, outperforming SimAN's 72.9%.
  • Semi-Supervised Learning: When fine-tuned on synthetic data, LEGO-trained models match or exceed SOTA supervised models, showing particular strength on irregular text datasets like SVTP and CT80.
  • Downstream Versatility: Beyond recognition, LEGO excels in Scene Text Super-Resolution. When applied to the TextZoom dataset, it outperformed specialized models like TSRN and TBSRN in image quality metrics (PSNR and SSIM), proving the encoder captures deep structural knowledge of text.

Conclusion

LEGO provides a powerful framework for self-supervised scene text representation learning. By utilizing a Text Knowledge Codebook to bridge the gap between visual style and character content, it overcomes the traditional limitations of SSL in the text domain. Future work may involve developing end-to-end networks that generate the codebook dynamically, further reducing pipeline complexity and enhancing adaptability to new domains.

Summary updated

BibTeX
@misc{ren2024lego,
  author = {Yujin Ren and Jiaxin Zhang and Lianwen Jin},
  title = {{LEGO: Self-Supervised Representation Learning for Scene Text Images}},
  year = {2024},
  eprint = {2408.02036},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2408.02036},
}
Figure