Introduction
Contrastive learning has significantly advanced self-supervised representation learning, particularly in computer vision tasks like image classification. However, standard frameworks such as SimCLR treat images as atomic units, which is suboptimal for text recognition. In text recognition, a word image is inherently a sequence of characters rather than a single object. Applying global augmentations like horizontal flipping can fundamentally disrupt the character sequence, leading to misaligned representations and poor learning outcomes.
To address this, the authors propose SeqCLR, a framework specifically designed to learn visual representations that respect the sequential, sub-word structure of text.
Methodology
The SeqCLR framework transforms an input image into a set of sequential representations through a multi-stage pipeline optimized for contrastive learning.
1. Sequence-Preserving Augmentation
Unlike standard contrastive methods, SeqCLR utilizes "sequence-preserving" augmentations. It avoids operations like horizontal flipping or aggressive horizontal cropping that would misalign the underlying character sequence. Instead, it employs vertical cropping, blurring, noise injection, and perspective transformations to create diverse views while maintaining the sequential integrity of the text.
2. Encoder and Projection Architecture
Augmented images are processed by a base encoder—typically a text recognition backbone like ResNet combined with a Bidirectional LSTM (BiLSTM)—to extract a sequence of feature vectors. These vectors are then passed through a projection head that maps them into a latent space specifically optimized for contrastive loss.
3. Instance-Mapping Function
The core innovation of SeqCLR is the instance-mapping function $m(\cdot)$, which divides the feature map into multiple "instances" for sub-word level contrast. The authors explore three strategies:
- All-to-instance: Collapses the entire sequence into a single vector.
- Window-to-instance: Uses adaptive pooling to generate a fixed number of sub-word instances.
- Frame-to-instance: Treats every individual frame in the sequence as a distinct instance.
4. Contrastive Loss
The model employs the InfoNCE loss to maximize the similarity between corresponding sub-word instances from different augmentations of the same image, while minimizing similarity with instances from other images in the batch. This sub-word contrast acts as a data multiplier, providing a denser supervisory signal than whole-image methods.
Experimental Results
SeqCLR was evaluated across various handwritten and scene text benchmarks, including IAM, RIMES, and SyntText.
- State-of-the-Art in Handwriting: SeqCLR achieved significant reductions in Word Error Rate (WER) on IAM (9.5% reduction) and RIMES (20.8% reduction) compared to previous benchmarks.
- Low-Data Efficiency: In semi-supervised settings with only 10% labeled data, SeqCLR consistently outperformed supervised baselines. For instance, on the RIMES dataset using a CTC decoder, it reached 62.5% accuracy versus the baseline's 59.7%.
- Representation Quality: In "decoder-only" evaluations where the encoder remains frozen, SeqCLR outperformed SimCLR by margins of 30-40% in accuracy, demonstrating that it learns features far more relevant to the text recognition task.
Conclusion
SeqCLR successfully adapts contrastive learning for sequential data by introducing sequence-preserving augmentations and sub-word instance mapping. While it shows immense promise in handwritten text and low-data regimes, future work may focus on improving performance with attention-based decoders in scene text by leveraging larger, unlabeled real-world datasets. The framework's success suggests potential applications in other sequence-heavy domains such as speech or action recognition.
Summary updated