{'fraction_non_alphanumeric': 0.03560860793544048, 'fraction_numerical': 0.013113651647612643, 'mean_word_length': 4.789565894490948, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 1, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Pushing the Performance Limit of Scene Text Recognizer without Human Annotation

Scene text recognition (STR) attracts much attention over the years because of its wide application. Most methods train STR model in a fully supervised manner which requires large amounts of labeled data. Although synthetic data contributes a lot to STR, it suffers from the real-tosynthetic domain gap that restricts model performance. In this work, we aim to boost STR models by leveraging both synthetic data and the numerous real unlabeled images, exempting human annotation cost thoroughly. A robust consistency regularization based semi-supervised framework is proposed for STR, which can effectively solve the instability issue due to domain inconsistency between synthetic and real images. A character-level consistency regularization is designed to mitigate the misalignment between characters in sequence recognition. Extensive experiments on standard text recognition benchmarks demonstrate the effectiveness of the proposed method. It can steadily improve existing STR models, and boost an STR model to achieve new state-of-the-art results. To our best knowledge, this is the first consistency regularization based framework that applies successfully to STR.


Introduction
Scene text recognition (STR) is to recognize text in natural scenes and is widely used in many applications such as image retrieval, robot navigation and instant translation. Compared to traditional OCR, STR is more challenging because of multiple variations from the environment, various Figure 1. Scene text recognition test accuracy by using supervised training, existing consistency regularization SSL (UDA [50] and FixMatch [43]) and our method. Cross-domain means the labeled and unlabeled training data are from different domains (e.g. synthetic labeled vs. real unlabeled in our setting), while in-domain means they are from similar condition. UDA and FixMatch are feasible in in-domain condition but fail in cross-domain setting. It is observed that the test accuracy drops drastically during the training process, and the highest accuracy is even lower than that obtained by supervised training. By contrast, our method is able to stabilize the training process and improve test performance in both in-domain and cross-domain conditions. font styles and complicated layouts.
Although STR has made great success, it is mainly researched in a fully supervised manner. Real labeled datasets in STR are usually small because the annotation work is expensive and time-consuming. Hence, two large synthetic datasets MJSynth [16,17] and SynthText [15] are commonly used to train STR models and produce competitive results. However, there exists domain gap between synthetic and real data which restricts the effect of synthetic data. Briefly speaking, synthetic dataset can improve STR performance, but STR model is still hungry for real data.
Considering that it is easy to obtain unlabeled data in real world, many researchers intend to leverage unlabeled data and train models in a Semi-Supervised Learning (SSL) manner.
Baek et al. [3] and Fang et al. [9] introduced selftraining methods to train STR models and receive improved performance. Nevertheless, self-training requires a pretrained model to predict pseudo-labels for unlabeled data and then re-trains the model, which affects the training efficiency. By contrast, Consistency Regularization (CR), another important component of state-of-the-art (SOTA) SSL algorithms, has not been well exploited in STR.
In this paper, we would like to explore a CR-based SSL approach to improve STR models, where only synthetic data and unlabeled real data are used for training, exempting human annotation cost thoroughly. CR assumes that the model should output similar predictions when fed perturbed versions of the same image [38]. It tends to outperform selftraining on several SSL benchmarks [1,36]. Nevertheless, it is non-trivial to utilize existing CR methods to STR directly. We attempt to two representative CR approaches, UDA [50] and FixMatch [43]. Neither of them is feasible in our setting. As shown in Figure 1a, the models are quite unstable during the training process. Compared with experiments on image classification where they show big superiority, we assume the reasons lie in the following two aspects. 1) Our labeled images are synthetic while unlabeled images are from real scenarios. The domain gap between synthetic and real images affects the training stability. Actually, it is found that the collapsed models recognize synthetic inputs with a reasonable accuracy, but generate nearly identical outputs for all real inputs. We conjecture that they incorrectly utilize the domain gap to minimize the overall loss: they learn to distinguish between synthetic and real data, and learn reasonable representations for synthetic data to minimize the supervised loss, but simply project real data to identical outputs such that the consistency loss is zero. To validate this conjecture, we perform another experiment by using training images all from real. As shown in Figure 1b, the training processes of UDA and FixMatch become stable in such a setting. However, we aim to relieve human labeling cost. The introduced domain gap becomes an issue.
2) Different from image classification, STR is a kind of sequence prediction task. The alignment between character sequences brings another difficulty to consistency training.
To address the aforementioned problems, we propose a robust character-level consistency regularization based framework for STR. Firstly, inspired by BYOL [14] that prevents model collapse without using negative samples in contrastive learning, we propose an asymmetric consistency training structure for STR. Secondly, a character-level CR unit is proposed to ensure the character-level consistency during training process. Thirdly, some techniques are subtly adopted in training process, such as weight decay and domain adaption, which improve STR model furthermore.
The main contributions are summarized as follows: 1) We propose a robust consistency regularization based semi-supervised framework for STR. It is capable of tackling the cross-domain setting, thus more easily benefitting from labeled synthetic data and unlabeled real data. Compared with self-training approaches, our method is more efficient, without iteratively predicting and re-training.
2) Considering the sequential property of text, we propose a character-level consistency regularization (CCR) unit to ensure better sequence alignment between the outputs of two siamese models.
3) Extensive experiments are performed to analyze the effectiveness of the proposed framework. It boosts the performance of a variety of existing STR models. Despite free of human annotation, our method achieves new SOTA performance on several standard text recognition benchmarks for both regular and irregular text.

Scene Text Recognition
Researches usually treat text recognition as a sequence prediction task and employ RNNs to model the sequences for recognition without character separation. Connectionist temporal classification (CTC) model [39,47] and attentionbased encoder-decoder model [21,40] are two commonly used frameworks for STR. The success of regular text recognition leads researchers to turn their attention to irregular text recognition. [25,27,40,41,53,56] rectified irregular text into regular ones to alleviate the difficulty in recognition. [23] and [52] employed 2D attention to handle the complicated layout of irregular text. [7,49,55] attempted to improve recognition accuracy by mitigating the alignment drift in attention. [10,34,54] tried to integrate semantic information from language model to enhance word recognition. All those methods need to be trained in a fully supervised manner.

Semi-Supervised Learning
Semi-Supervised Learning (SSL) aims to use labeled data and additional unlabeled data to boost model performance. There are mainly two types of SSL methods that relate to our work, self-training [5,13,22,51] and consistency regularization (CR) [20,30,43,44,50]. Self-training is simple and effective. It first employs labeled data to train a teacher model, then predicts pseudo labels for unlabeled data, and finally trains a student model using both labeled and pseudo-labeled data. Pseudo Label [22] and Noisy Student [51] are two popular variants. CR is based on the manifold assumption that model outputs should be consistent when fed different augmentation views of the same image. For example, Temporal Ensembling [20] encourages a consensus prediction of the unknown labels using  Overall framework of our proposed consistency regularization method for STR. Our model takes advantage of labeled synthetic data and unlabeled real data, exempting human annotation cost thoroughly. An asymmetric structure is designed with EMA and domain adaption to encourage a stable model training.
the outputs of the network-in-training on different epochs. Mean Teacher [44] requires the outputs from teacher model and student model to be consistent, and updates teacher model by averaging student model weights. FixMatch [43] combines CR and pseudo-labeling for better performance. UDA [50] argues the importance of noise injection in consistency training, and achieves SOTA performance on a wide variety of language and vision SSL tasks.

Semi-Supervised Text Recognition
Some work has been proposed to train STR model with SSL. For instance, Gao et al. [11] adopted reinforcement learning techniques to exploit unlabeled data for STR performance improvement. However, both labeled and unlabeled data are divided from synthetic data, without domain gap issue. [58] and [18] utilized domain adaption techniques to mitigate the domain shift between source and target data, so as to improve recognition results on target domain. Baek et al. [3] attempted to train STR model by using real data only, and tried both Pseudo Label and Mean Teacher to enhance STR performance. Fang et al. [9] proposed an autonomous, bidirectional and iterative language modeling for STR. A self-training strategy was applied with the ensemble of iterative prediction to increase STR performance further.

Overview
As shown in Figure 2, our framework consists of an STR model for text recognition and a CR architecture to integrate information from both labeled and unlabeled data. We adopt the attention-based encoder-decoder STR model here for illustration. However, our framework is not restricted to autoregressive STR models. The encoder extracts discriminative features from input images, while the decoder generates character-level features. The classifier maps features into probabilities over character space via a linear transformation and Softmax.
We define two modes for STR model, named training mode and inference mode, according to whether the "ground-truth" character sequence is provided. In training mode, "ground-truth" characters are sent to the decoder for next character prediction. By contrast, in inference mode, the output of previous step is fed into decoder to infer next character. Both modes receive a special "BOS" token at the first step which means the start of decoding. Training mode ends when all ground-truth characters are input, while inference mode ends when generating an "EOS" token.
The CR architecture is inspired by UDA [50], which consists of two branches, namely supervised and unsupervised branch, as demonstrated in Figure 2. The supervised branch is trained on labeled data, while the unsupervised branch takes two augmented views of an unlabeled image as input, and requests the outputs to be similar to each other. Motivated by BYOL [14], we employ STR models with the same architecture but different parameters in unsupervised branch for the two views of inputs, denoted as online model and target model separately. The online model shares parameters with the one used in supervised branch. To overcome the instability during model training and improve STR performance, an additional projection layer is introduced before classifier in online model of the unsupervised branch.

Supervised Branch
Supervised branch adopts the online STR model and runs in training mode, using the labeled synthetic data. Specially, denote the weight of online STR model as θ o , which is comprised of parameters from three modules, i.e., encoder, decoder and classifier, referring to Figure 2. Given the input image X L and the ground-truth character sequence Y gt = {y gt 1 , y gt 2 , . . . , y gt T }, the supervised branch outputs a sequence of vector Cross-entropy loss is employed to train the model, i.e., where p L t (y gt t ) represents the predicted probability of the output being y gt t at time step t. T is the sequence length.

Unsupervised Branch
Different from [50] and inspired by [14], unsupervised branch in our framework relies on two models, referred to as online STR model (with model parameter θ o ) and target STR model (with model parameter θ t ) respectively. The two models interact and learn from each other.
Given the input image without label X U , two different augmentation approaches are adopted which produce two augmented views of the image, denoted as X Uw and X Us respectively. The online STR model takes X Us as input and runs in training mode. Motivated by the collapse preventing solution in [14], an additional projection layer is introduced between the decoder and classifier, as shown in Figure 2, and the parameters are denoted as θ p independently. It is composed of 2 layers of perceptron with ReLU activation. The added projection layer makes the architecture asymmetric between the online and target model, which contributes to a stable training process. The classifier is then followed to transform the output vector into probabilities over character space, denoted as P Us = {p Us 1 , p Us 2 , . . . , p Us T }. The target STR model takes X Uw as input and runs in inference mode, which generates a sequence of probabilities P Uw = {p Uw 1 , p Uw 2 , . . . , p Uw T }. The output sequence is used as the reference target to train the online model. A

Encoder Decoder
Online model  stop-gradient operation is acted on the target model, and its parameters θ t are an exponential moving average (EMA) of the online model parameter θ o , i.e., where α ∈ [0, 1] is the target decay rate. EMA makes the target model produce relatively stable targets for online model, which helps to keep the projection layer in near optimal and benefits the model training as well.
As indicated in [13,50], regularizing predictions with low entropy would be beneficial to SSL. We sharpen the output from target STR model P Uw by using a low Softmax temperature τ . Denote the output vector at step t before Softmax as z Uw t = {z Uw 1 , z Uw 2 , . . . , z Uw C }, C is the number of character classes, then We set τ = 0.4 following [50]. The consistency training regularizes the outputs of P Uw and P Us to be invariant. However, given that STR is a sequence recognition task, a character-level consistency regularization (CCR) unit is proposed for autoregressive decoder, so as to keep a good sequence alignment. As shown in Figure 3, in decoding time step t, a pseudo label is generated from target model by taking the class that has the highest probability in p Uw t . The pseudo label will be used as the input for both online and target decoder in next time step. The design enforces online decoder and target decoder share the same context information, benefits character level alignment, and thus ensures a stable consistency training.
To alleviate the influence caused by noise samples in training process, we filter out noise samples based on their confidence scores in recognition. The confidence score is the cumulative product of the maximum output probability from target model in each decoding step, i.e., The consistency loss used in unsupervised branch is then defined as: where I(s Uw > β U ) is an indicator, β U is a threshold for filtering out noises and Dist(·) is a function to measure the character-level distance between P Uw and P Us . There are several choices for Dist, such as Cross Entropy (CE), KLdivergence or Mean Squared Error (MSE). KL-divergence is adopted in our framework by default.

Additional Training Techniques
Weight Decay. Weight decay is an important component in contrastive learning [6,14] and SSL [43]. It is claimed that [45] weight decay in BYOL can help balance weights between predictor and online model dynamically, and improve the representation ability of online model. Here we also adopt it into our model training so as to improve the feature learning capability of online model.
Domain Adaption. To mitigate the domain shift in training data, a character-level domain adaptation unit is employed between the supervised and unsupervised branches, referring to [58]. Specially, in each decoding step, decoder of the online model extracts vision feature for the character to be decoded, denoted as H L = {h L 1 , h L 2 , · · · , h L T } and H Us = {h Us 1 , h Us 2 , · · · , h Us T } for features extracted in supervised and unsupervised branch respectively. Domain adaption loss is defined as where ∥ · ∥ 2 F denotes the squared matrix Frobenius norm, cov(H) is covariance matrix, d is the feature dimension.

Overall Objective Function
We sum the three loss functions defined above. The overall objective function for training our proposed model is: where λ cons and λ da are hyper-parameters to balance three terms. We set λ cons = 1 and λ da = 0.01 empirically.

Datasets
Two types of data are used here for training, i.e., synthetic data with annotations and real data without label.
Two widely used synthetic datasets are adopted including SynthText (ST) [15] and MJSynth (MJ) [17], which results in 14.5M samples in total, referring to as synthetic labeled data (SL).
For real unlabeled scene text data, we collected from three public available datasets, Places2 [59], OpenImages 1 and ImageNet ILSVRC 2012 [37]. CRAFT [4] was employed to detect text from these images. Then we cropped text images with detection scores larger than 0.7. Images with low resolution (width times height is less than 1000) were also discarded. There are finally 10.5M images, denoted as real unlabeled data (RU).
In addition, during ablation study, to demonstrate the superiority of the proposed framework, we also conduct experiments by using real labeled data collected by [3]. It has 278K images totally, named as real labeled data (RL).
Six commonly used scene text recognition benchmarks are adopted to evaluate our method.
Street View Text (SVT) [48] consists of 647 word images collected from Google Street View for test.
SVT-Perspective (SVTP) [35] contains 645 images for test, which are cropped from side-view snapshots in Google Street View.

Evaluation Metric
Following common practice, we report word-level accuracy for each dataset. Moreover, in order to comprehensively evaluate models for their recognition performance on both regular and irregular text, following [3], we introduce an average score (Avg) which is the accuracy over the union of samples in all six datasets.

Implementation Details
The whole model is trained end-to-end without pretraining. We use a batch size of 384 for labeled data and 288 for unlabeled data. By default, we set the target decay rate α = 0.999 and confidence threshold β U = 0.5 respectively. Both supervised branch and unsupervised branch are jointly trained, while we only use the model in supervised branch in inference time.
Four STR models are adopted to validate the effectiveness of the proposed framework, with their default model configurations, including CRNN [39], MORAN [28], HGA [52] and TRBA [2]. Note that CRNN uses CTC for character decoding, which is non-autoregressive. Hence, CCR is not adopted when training model with CRNN.
We adopt Adadelta when training MORAN or HGA, following their original optimization method. The learning rate is 1.0 initially and decreases during training process. AdamW [26] optimizer is adopted when using CRNN or TRBA model. Following [3], we use the one-cycle learning rate scheduler [42] with a maximum learning rate of 0.001. The weight decay rate is aligned with the used STR model.
The unsupervised branch takes two augmented views of an image as input. Here we define two types of augmentations, i.e., StrongAug and WeakAug. StrongAug is borrowed from RandAugment [8] which includes multiple augmentation strategies on both geometry transformations and color jitter. Considering Cutout may crop some characters from the image which will corrupt the semantic information of text, we remove "Cutout" operation from RandAugment. WeakAug only has color jitter, including brightness, contrast, saturation and hue. In our framework, we use WeakAug for target model and StrongAug for online models of both supervised and unsupervised branches.

Comparison with SOTA
We perform experiments by using different STR models. For fair comparison, we also reproduce those models under supervised setting using the same data augmentation strategy as that used in our semi-supervised training. As presented in Table 1, our reproduced models have comparable or even higher accuracies than that reported in the original paper. Those results provide an even fair baseline to show the advantage of our method. Experiments with their original settings can be found in Supplementary.
By training with the proposed framework using additional unlabeled real images, all models gain improvement. To be specific, CRNN improves by 3.1% (from 82.8% to 85.9%) on average, MORAN increases from 88.5% to 90.2% (+1.7%). HGA has an accuracy increase of 2.5% (from 88.7% to 91.2%) and TRBA has an increase of 3.0% (from 91.5% to 94.5%). The consistent enhancement over different STR models shows the effectiveness and universality of our proposed method. Specially, the performance gain over irregular text (IC15, SVTP and CUTE) is more obvious, since irregular text has more variance on appearance which is hard to be generated by synthetic engine.
Note that although TRBA is worse than ABINet [9] in supervised setting (91.5% vs. 92.7%), our framework helps TRBA outperform ABINet that adopts self-training in semisupervised setting (94.5% vs. 93.5%), which proves the superiority of our proposed CR method again. Compared with other SOTA work, our proposed framework with TRBA achieves the highest accuracies on vast majority of test datasets (only except IIIT), which demonstrates its robustness for both regular and irregular text recognition.
In addition, to accelerate training process, we perform an experiment with TRBA using only 10% synthetic labeled  data (denoted as "SL sm " that contains only 1.45M images) and 10% real unlabeled data (denoted as "RU sm " which has 1.05M images). Surprisingly, experimental results is fairly good with the average score of 93.2%, even higher than that obtained by TRBA pr (91.5%) and ABINet [9] (92.7%). It should be noted that TRBA pr and ABINet are trained in a fully supervised manner using all synthetic data (14.5M). The training data is 5.8 times more than that used in TRBA sm . The excellent results suggest the necessary of using real images in training STR models and the advantage of our semi-supervised training framework.
In Figure 4, we present several examples that can be correctly recognized by TRBA cr but encounter failure when using TRBA pr . Although the employed real images are unlabeled, STR models can still get benefit from our method, particularly for recognizing text that is severely blurred, distorted, or with artistic font.

Ablation Study
In order to analyze the proposed model, we conduct a series of ablation experiments in this section. All ablation experiments are performed using TRBA because of its good performance. SL sm and RU sm are employed for fast training. More experiments with different data sizes can be found in Supplementary.

Effect of domain gap on model stability
In this work, we propose a stable CR based SSL framework for STR. As stated in Section 1, we guess it is the domain inconsistency among training data used in STR that causes the instability or even failure by previous CR methods.
To prove this conjecture, we perform experiments using domain consistent training data (in-domain data). Specially, we split the real labeled training data RL into RL 20p and RL 80p with a ratio of 1:4. RL 20p is adopted with labels while RL 80p is employed without annotations. SOTA CR  Table 1. Comparison with SOTA methods on STR test accuracy. In each column, the best result is shown in bold, and the best result in supervised setting is shown with underline. "-pr" means our reproduced results and "-cr" means using our consistency regularization method. Our method improves STR models firmly, and propels TRBA towards new SOTA performance on test benchmarks. methods are tested, including FixMatch [43] and UDA [50]. As presented in Table 2, when training data is from the same domain, they work well. The test accuracy increases by 3.6% using FixMatch and 2.6% using UDA. However, when the training data is from different domains, e.g., SL sm and RU sm , their training processes become unstable. We test the models before collapse. The recognition accuracies are even lower than that obtained by only using SL sm , with performance degradation of 11.0% (FixMatch) and 4.6% (UDA) separately. By contrast, our method is able to improve the recognition accuracy no matter the training data is from similar domain or not. In comparison to the results by fully supervised training, our method improves STR model accuracy steadily by 4.5% (84.8% to 89.3%) using in-domain data and 3.3% (89.9% to 93.2%) in cross-domain setting. The performance gain in in-domain setting is even larger than that brought by FixMatch and UDA.

Ablation on model units
The techniques used in our method include an additional projection layer for asymmetric structure, EMA, domain adaption and weight decay. Here we analyze the effect of each unit in detail. The experiments are performed with CCR added to benefit character-level consistency.
As presented in Table 3, the use of additional projection layer can improve the final average score by 0.7%. However, the performance is still lower than that obtained under fully supervised setting (87.7% vs. 89.9%). As indicated in [45], without weight decay, the consistency between online and target outputs is dependent mainly on the projection layer, rendering the online model weights inferior. Weight decay helps balance weights between online model and pro-  Table 3. Ablation on model units. "Projection" means using additional projection layer before classifier. "WD" means weight decay, "EMA" means using EMA for target model. "DA" means domain adaption.   jection layer dynamically. The use of weight decay, with projection layer, increases the average score on test data by another 3.5%, surpassing the supervised results. EMA mechanism brings an accuracy gain of 1.6% furthermore as it helps keep projection layer in near-optimal and improves training stability. Lastly, the adding of domain adaption improves the average test accuracy up to 93.2%.

Effect of CCR
Another contribution of this work is a character-level consistency regularization (CCR) unit to handle the specially sequential property of STR task. Instead of letting online model and target model run separately in unsupervised branch (standard consistency regularization, SCR), and only restricting their final outputs by consistency loss, we proposed CCR to enforce the same context information for both online and target model. Experimental results in Table 4 prove the effectiveness of CCR. It helps TRBA improve 1% more on the final test accuracy.  Table 6. Comparison with other semi-supervised methods. Our method brings more benefit to STR model and outperforms the other approaches.

Ablation on distance measure functions
By default, we use KL-divergence to measure the consistency in loss function (5). Here we test other distance measure functions, such as CE and MSE. As presented in Table 5, empirically, CE leads to similar recognition performance with KL-divergence, while MSE results in lower accuracies (93.2% vs. 91.0%).

Comparison with Other Semi-supervised Methods
We compare our method with other SSL approaches that have been successfully used in STR, including Pseudo Label (PL) [22] and Noisy Student (NS) [51]. TRBA is used as the basic model. PL based SSL is performed following the practice in [3], while NS based SSL is following [51], with the threshold β U = 0.5 and 3 iterations of re-training.
The results are shown in Table 6. Our CR based method outperforms all the others, with the resulted average score 2.3% higher than PL and 0.8% higher than NS. Note that compared to NS, our training process is more efficient, without time-consuming iterations.

Conclusion
In this paper, we propose a robust character-level consistency regularization method for STR. Our framework consists of a supervised branch trained with synthetic labeled data, and an unsupervised branch trained by two augmented views of real unlabeled images. An asymmetric structure is designed with EMA, weight decay and domain adaption to encourage a stable model training and overcome the domain gap issue caused by synthetic and real images. Moreover, a character-level consistency regularization unit is proposed to ensure better character alignment. Without using any human annotated data, our method is able to improve existing STR models by a large margin, and achieves new SOTA performance on STR benchmarks.