{'fraction_non_alphanumeric': 0.03176387912860155, 'fraction_numerical': 0.016865776528460996, 'mean_word_length': 4.756877022653722, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
On-Device Text Image Super Resolution

Recent research on super-resolution (SR) has witnessed major developments with the advancements of deep convolutional neural networks. There is a need for information extraction from scenic text images or even document images on device, most of which are low-resolution (LR) images. Therefore, SR becomes an essential pre-processing step as Bicubic Upsampling, which is conventionally present in smartphones, performs poorly on LR images. To give the user more control over his privacy, and to reduce the carbon footprint by reducing the overhead of cloud computing and hours of GPU usage, executing SR models on the edge is a necessity in the recent times. There are various challenges in running and optimizing a model on resource-constrained platforms like smartphones. In this paper, we present a novel deep neural network that reconstructs sharper character edges and thus boosts OCR confidence. The proposed architecture not only achieves significant improvement in PSNR over bicubic upsampling on various benchmark datasets but also runs with an average inference time of 11.7 ms per image. We have outperformed state-of-the-art on the Text330 dataset. We also achieve an OCR accuracy of 75.89% on the ICDAR 2015 TextSR dataset, where ground truth has an accuracy of 78.10%.


I. INTRODUCTION
Compression techniques used by social media platforms significantly reduce the resolution of images adversely affecting the finer details. Due to the large amounts of images being shared over social media today, there is a growing abundance of low resolution (LR) images on smartphones. LR text images thus, pose a challenge for existing text detection and recognition frameworks on device. Moreover, it gets difficult for the user to read the text due to blurry character edges. Hence, super-resolution (SR) of text images is an intuitive solution. SR is a well-studied problem in computer vision and various approaches have been proposed in the literature. Some very early approaches use interpolation techniques [1]- [3] based on sampling theory. Many previous studies even adopted edge-based [4] techniques and patch-based techniques [5]- [7] to approach the problem. Another study [8] showed good results using sparsity-based methods. Sparse coding assumes any image can be sparsely represented in a transform * Primary authors domain, which can then be learned through a training mechanism that tries to relate the LR and HR images. Yang et al. [9], [10] introduced another approach by clustering the patch spaces and learning the corresponding functions. Dong et al. [11], [12] proposed SRCNN, the first deep learning-based image SR method. Since then, various CNN model architectures have been studied for image SR in recent years. Extending this further, other studies [13], [14] have also used Residual neural networks [15] for achieving better performances. They employ deeper neural network architectures and show that using skip connections and recursive convolutions improve SR networks by carrying forward the identity information ahead in the network. Mao et al.
[16] used encoder-decoder networks and symmetric skip connections to tackle the problem as image restoration. They show that the skip connections help the model in converging faster. Stacked collaborative autoencoders are also studied in [17]. Generative Adversarial Networks (GANs) [18] introduce adversarial loss to generate impressive results in various tasks. SRGAN [19] is the first work to apply GANs to image SR.
The above mentioned SR frameworks have focussed on learning the texture present in the LR image and reproducing it in the predicted HR with refined details. So, they leverage deeper neural networks to learn hierarchical features for preserving the texture. Reconstruction of texture details is of lesser importance in improving OCR confidence than learning sharper character outline edges.
In this paper, we propose a novel text image SR solution that runs on device in real-time. Our proposed network with very less number of parameters produces comparable results with existing state-of-the-art networks on ICDAR 2015 TextSR 1 datasets in terms of OCR accuracy. The feature extraction pipeline pools high-level textual features for finner edge reconstruction. Our model learns upon the bicubic interpolation hence reducing model parameters to a significant extent. It shows significant improvement in text clarity compared to bicubic interpolation on device.

II. RELATED WORK
Earliest works in text image super-resolution include [20] and [21]. Capel et al. [21] proposed the enhancement of text images using multiple-frame SR. They introduced a MAP estimator based on Huber prior and utilized Total Variation for regularization. Extending their work, Nasonov [21] combined Bilateral Total Variation [22] and a penalty function based on bimodal prior that forces the pixel intensities of the reconstructed image to be either close to the background or the foreground (text). However, these methods need many LR observations for effective estimation and were only restricted to 2× upscaling. Banerjee et al. [23] utilized the tangent field at character edges for reconstructing sharper edges in grayscale document LR images. A Lat et al. [24] improved OCR accuracy by super-resolving document images using SRGAN [19]. Another closely related work, [25] uses deep neural network architectures for Binary Document Image Super-Resolution (BDISR) in Tamil script. These works are only restricted to document images, whereas our method solves a broader problem of text image SR while improving OCR confidence. [19] produces HR image with higher fidelity incorporating finer edge details but has used GANs which are not suitable for a smartphone environment. [26] has proposed MergeNet for enhancing the edges in the HR output from their version of EDSR [27]. Their pipelined architecture has huge memory constraints and can not be run in real-time on device.
C Dong et al. in [28] had trained 11 different variants of SRCNN on the ICDAR2015 TextSR dataset. They used Model combination [29], following "Greedy search strategy [28]" to obtain 14-best model combinations evaluated on peak signalto-noise ratio (PSNR). The 14-model combination achieves state-of-the-art performance on the test set. More recent works, driven by the powerful capability of deep neural networks, has led to dramatic improvements in SR. Other works in text image SR [30]- [32], have trained deeper neural networks that have shown state-of-the-art performance in image super-resolution like LapSRN [33], VDSR [13] with loss functions tailored for reconstructing sharper letter edges. However, these solutions can not be deployed on the device due to their large number of parameters.
MobiSR [34] introduced hardware optimization to perform efficient image SR on mobile platforms by minimizing processing latency. Their novel scheduler estimates the upscaling difficulty patch-wise and accordingly sends them to modelengines. Model compression techniques like Knowledge Distillation [35], pruning and quantization have been utilized to reduce the inference time of the network. However, they may also result in a significant loss of high-frequency features that further affect the sharpness of reconstructed edges in the HR image. Therefore, we introduce a shallow network that focuses on learning sharper character edges for enhanced readability and faster inference time on device. To the best of our knowledge, we are the first to perform text image SR on device.

III. METHODOLOGY
Mean Squared Error (MSE) loss tends to induce smoothness in the reconstructed HR image which results in blurry edges. H Zhang et al. [31] have trained VDSR [13] with the proposed edge-based Weighted Mean Squared error (WMSE) loss. The weight at any pixel is the value of some function f of the gradient magnitude at that pixel, where f is any monotonously increasing function. This has shown a slight improvement in OCR confidence on ICDAR 2015 TextSR test set. In our initial experiments, we tried to add edge information using different loss functions [31], [32], [36]. We found that shallower models are unable to reflect this impact in the reconstructed HR image. Our architecture is based on residual learning and thus, it learns the residual between bicubic interpolated HR and the ground truth. Various components of the model are described in detail as follows:

A. Feature Extraction
Pre-upsampling SR networks like SRCNN [37], DRRN [38], DRCN [14] extract a set of features from bicubic interpolated LR image. A couple of convolution layers are then leveraged to perform non-linear mapping of the extracted feature maps and reconstruct the HR image. Text images suffer a significant loss in edge information due to blurring and noise amplification resulted from bicubic upsampling (Fig.  2). Reconstructing HR from the feature maps extracted from the upsampled bicubic text image does not produce expected results. Moreover, it also increases the space and time complexity as the operations are performed in the high dimensional space. So, we adopt the post-upsampling SR approach [27], [39] as shown in the Fig. 1. High frequency detailing like sharper edge transitions between text and the background is crucial for enhanced readability. For faster inference on device, we convert the RGB input to Y C b C r space and only Y channel is fed to the network for training.
We use four CNN layers having 32, 24, 16, 8 filters respectively each with kernel size 3×3 to extract features from the LR input image. All the feature maps except the third layer are concatenated via skip connections to generate a total of 64 feature maps. Though, skip connections were introduced to eliminate the vanishing gradient problem in very deep neural networks. [39] has shown improved results over SRCNN, VDSR, and DRCN using dense skip connections. [40] also used skip connections in their feature extraction pipeline to extract both local and global features. Decreasing order of filters and skip connections from the outputs of initial layers ensure that high-frequency features are well incorporated. Our idea behind pooling features from initial layers is to add more emphasis on broad edges that outline the character boundaries in text images. Our shallow model has only 57K parameters.
Additionally, we have also extracted features from Sobel edge maps of the input LR using a convolution layer having 16 filters and a kernel size of 3×3 as shown in Fig. 1. Edge feature maps are then concatenated with the existing ones. This helps in emphasizing weaker edges and in turn, fills the fine

B. Upsampling Layer
The generated feature maps are further passed to two convolution layers having 32 and s 2 filters respectively, where s is the scale of resolution. Assuming input images shape is h × w, the resultant input to the pixel shuffler layer is h × w × s 2 . The reshaping operation is performed through pixel shuffle [41] generates the final HR image of the Y-channel input LR having the shape hs × ws.

C. Loss Function
Bicubic upsampled C b and C r channels of input LR are appended to the reconstructed Y channel. This is the residual HR image. Now, bicubic upsampled input LR image is added to it to form reconstructed HR image. Loss function is L2, which measures the mean squared pixel-wise difference between the ground truth and the reconstructed HR image.

IV. EXPERIMENTS A. Experimental Setup
For all the experiments, we used Synth90k [42] dataset as the training data. It consists of 93K images. The color images were converted to Y C b C r and only Y-channel is processed. LR images are created by downsizing the images using bicubic kernel at both scales (2× and 4×). 16x16 patches were generated and 20 patches are used as a mini-batch to train the model. This is the only pre-processing step.
We implemented the proposed architectures in the Tensorflow framework and all of the experiments were conducted on a GeForce GTX 1080ti GPU. We have used Adam [43] optimizer with momentum term 0.9. The initial learning rate is 2e-3 and it is halved after every epoch. Training is stopped once the learning rate reaches 2e-5.

B. Evaluation
We have examined the quality of character outline-edges in the reconstructed HR images, by passing canny edge maps of the text LR image as input to the model. Fig. 2 shows the sharpness of reconstructed edge maps with a scale of 4×. The performance is extensively evaluated on eight popular benchmark datasets to cover various scenarios of scenic text. TABLE II draws a comparison between bicubic upsampling and our approach using the obtained PSNR and SSIM metrics for scale 2 and scale 4. These metrics have been calculated on the entire dataset, not just the on test set. These are listed as : ICDAR 2015 TextSR, ICDAR 2003 (IC03) [44], ICDAR 2013 (IC13) [45], ICDAR 2015 (IC15) [46], SVT [47], IIIT5K [48], CUTE80 [49], MLT 2 .
HTM Tran et al. [30] have trained LapSRN [33] with Gradient Difference Loss [36]. They have proposed a new dataset Text330 3 which contains plain text document images. Apart from scenic text images, our model also performs well on document images. This is illustrated in TABLE I. Fig.3 demonstrates sharper character edges in the reconstructed HR images from the Text330 test set as compared to bicubic upsampling. The given results confirm enhanced readability.

V. CONCLUSION
In this work, we have addressed the problem of enhancing text clarity in LR images, which is very common in mobile devices, and optimized our network for running on the edge. To the best of our knowledge, there are not many works trying to solve the problem of text readability with SR methods on device. Our evaluation on PSNR, SSIM, on-device inference time and OCR accuracy shows that we have gained significant improvement compared to the existing Bicubic upsampling. We have also shown impressive results on document images. Unlike previous SR solutions, our proposed method focuses on SR of the text present in the image, rather than background or texture. This makes our model the very first lightweight model that is capable of text image SR in real-time on device.