{'fraction_non_alphanumeric': 0.0335593220338983, 'fraction_numerical': 0.01152542372881356, 'mean_word_length': 5.0500078876794445, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
TextAdaIN: Paying Attention to Shortcut Learning in Text Recognizers

Leveraging the characteristics of convolutional layers, neural networks are extremely effective for pattern recognition tasks. However in some cases, their decisions are based on unintended information leading to high performance on standard benchmarks but also to a lack of generalization to challenging testing conditions and unintuitive failures. Recent work has termed this"shortcut learning"and addressed its presence in multiple domains. In text recognition, we reveal another such shortcut, whereby recognizers overly depend on local image statistics. Motivated by this, we suggest an approach to regulate the reliance on local statistics that improves text recognition performance. Our method, termed TextAdaIN, creates local distortions in the feature map which prevent the network from overfitting to local statistics. It does so by viewing each feature map as a sequence of elements and deliberately mismatching fine-grained feature statistics between elements in a mini-batch. Despite TextAdaIN's simplicity, extensive experiments show its effectiveness compared to other, more complicated methods. TextAdaIN achieves state-of-the-art results on standard handwritten text recognition benchmarks. It generalizes to multiple architectures and to the domain of scene text recognition. Furthermore, we demonstrate that integrating TextAdaIN improves robustness towards more challenging testing conditions. The official Pytorch implementation can be found at https://github.com/amazon-research/textadain-robust-recognition.


Introduction
Reading someone else's handwriting is often a challenging task; some of the characters are unclear, the text is cursive, there is background clutter and the image quality can be low. When deciphering each character, we often rely on the surrounding area to compensate for the occasional obscurity of the text. The automation of reading text images has been a thriving field of research in computer vision for decades. Recent deep learning methods have significantly improved recognition results [6,67,42,38,2,1].
However, previous works suggest that despite their super-human capabilities, deep learning methods are limited by their tendency to err even when introducing small (in some cases even invisible) modifications to the input. Numerous works have touched on this subject from various angles [10,50,59,58,23,45] and propose tailored solutions. Geirhos et al. [22] view each of these as a symptom of the same underlying problem, and terms this phenomenon shortcut learning -decision rules that perform well on independent and identically distributed (i.i.d.) test data but fail on tests that are outof-distribution (o.o.d). Shortcut learning occurs when there is an easy way to learn attributes which are highly correlated with the label (i.e., "it stands on a grass lawn =⇒ it is a cow"). Thus, shortcuts are inherent in the data [23,28]. Yet, as they can depend on other various factors such as the architecture [15], and the optimization procedure [64,16] as well, revealing an instance of shortcut learning is non-trivial task. The fact that a model learned a shortcut can be discovered at test time when it encounters examples that the shortcut heuristic fails on (i.e., a cow on the beach).
In this work, we reveal a shortcut pertaining to text recognizers, specifically, we reveal the unhealthy reliance of text recognizers on local statistics. Based on the observation that text recognizers operate on a local level, we hypothesize that they are susceptible to overly rely on local information which may even be indistinguishable to the naked eye (i.e., a certain level of curvature is unique and highly correlated with the character "f"). As such in this case it is difficult to identify the exact shortcut heuristic, thus we provide intuition through quantitative and qualitative analyses. Fig. 1(a) illustrates the decoder's attention maps for a state-of-the-art [38] recognizer before and after applying local corruptions to the image. In the first row, additive Gaussian noise is applied, which distorts local information while maintaining semantic information. As a consequence, the model diverges completely. In the second row, motion blur is applied, artificially imitating object motion. In this case, in order to successfully decode the corrupted image, global context is necessary (imagine reading the blurred image character by character without access to the surrounding characters). As one can tell from the attention maps, the model fails to do so and is unable to correctly decode the image. An in-depth analysis reveals that this phenomenon is apparent in standard text recognizers across both scene text and handwritten domains, as further elaborated in Section 3.
To prevent the model from using the aforementioned shortcut, we propose a simple, yet powerful, technique for moderating the reliance on local statistics. The key idea of our approach is to probabilistically swap fine-grained feature statistics in a manner that is adjusted to the task at hand. To that end, we propose TextAdaIN, a local variation of AdaIN [29], depicted in Fig. 2. In contrast to AdaIN which operates on the entire image, TextAdaIN splits the feature map into a sequence of elements and operates on each element independently. Furthermore, the normalization is performed over multiple dimensions. Both modifications increase the granularity level in which the statistics are modified and enable the usage of multiple donor images. Effectively, the representation space undergoes distortions derived from an induced distribution, namely other text images, at a sub-word level. Thus, forcing the encoder to account for information in surrounding areas as the local information cannot always be depended on. This is observed in Fig. 1(b), where in contrast to the baseline model, TextAdaIN successfully utilizes global context and properly decodes the images despite the corruptions. We validate our method by comparing its performance with state-of-the-art approaches on several handwritten text benchmarks. TextAdaIN achieves state-of-the-art results, reducing the word error rate by 11.8% and 16.4% on IAM and RIMES, respectively. Furthermore, our method shows a consistent improvement across multiple architectures and in the domain of scene text recognition. Not only does our model surpass other, more complicated methods ( [9,20,67,42,2]), but it is simple to implement and can effortlessly be integrated into any mini-batch training procedure. To summarize, the key contributions of our work are: 1. We reveal an instance of shortcut learning in text recognizers in the form of a heavy dependence on local statistics and suggest to regulate it. 2. We introduce TextAdaIN, a simple yet effective normalization approach to remediate the reliance on local statistics in text recognizers. 3. Extensive experimental validation shows our method achieves state-of-the-art results on several popular handwritten text benchmarks. In addition, it is applicable to the domain of scene text and can be used independent of the chosen architecture. 4. We demonstrate that our method leads to improved performance on challenging testing conditions.

Related Work
Shortcut learning. An extensive amount of research has been conducted at understanding the behaviour of neural networks. One behavioural aspect under investigation is their unintended solutions, whereby a decision is made based on misleading information, thus limiting the performance under general conditions. A typical example of this is an intriguing discovery made by Szegedy et al. [58]. They showed the susceptibility of neural networks to adversarial examples, which are samples that undergo minimal, or even unnoticeable, modifications capable of altering model predictions. More recent works show other ill-desired sensitivities, [23] for texture, [3] for color constancy, [45,49] for global statistics and [8] for image background. These phenomena were classified by Geirhos et al. [22] as instances of the same underlying problem that they termed shortcut learning. So far, for shortcut learning in the domain of text recognition, we are only aware of [61], which exposed the decoder's high reliance on vocabulary.
Normalization and style transfer. Normalizing feature tensors is an effective and powerful technique that has been explored and developed over the years for a variety of tasks. Ioffe & Szegedy [30] were the first to introduce Batch Normalization, which inspired a series of normalization-based methods such as Layer Normalization [5], Instance Normalization [60], and Group Normalization [65]. The style of an image was characterized by [21] to be the statistics of activation maps in intermediate layers of convolutional neural networks. Instance Normalization (IN) [60] is a normalization layer which normalizes these statistics, removing the style representation from the activation map. Subsequently, Adaptive Instance Normalization (AdaIN) was proposed by [29] for real-time arbitrary style transfer. AdaIN changes the style of an image by incorporating statistics from an additional image.
Leveraging the benefits of this operation, Geirhos et al. [23] created Stylized-ImageNet, a stylized version of ImageNet. They demonstrated that classifiers trained on this dataset rely more on shape than on texture. More recently, Zhou et al. [68] proposed to probabilistically mix instance-level feature statistics during training across different domains, thus increasing the generalizability of the model. Furthermore, Nuriel et al. [45] demonstrated that a similar approach can reduce classifiers' reliance on global statistics, therefore increasing classification performance.
In this work we reveal a shortcut learning phenomenon in text recognizers. To remediate this problem, we also leverage AdaIN. However, instead of operating on a word (instance) level, we swap fine-grained statistics on a sub-word level. We do so by treating every few consecutive frames in the sequential feature map as individual elements.
Text Recognition. Text recognition has attracted considerable attention over the past few years. In particular, deep learning approaches have achieved remarkable results [51,6,38,56,18,19,1]. Still, current state-of-the-art methods struggle to train robust models when the amount of data is insufficient to capture the magnitude of styles. Various methods have been suggested to cope with this problem. Bhunia et al. [9] proposed an adversarial feature deformation module that learns ways to elastically warp extracted features, boosting the network's capability to learn highly informative features. Luo et al. [42] introduced an agent network that learns from the output of the recognizer. The agent controls a set of fiducial points on the image and uses a spatial transformer to generate "harder" training samples.
Unlike previous methods, our method does not require additional data, new models or complex training paradigms. Instead, we suggest a normalization-based method adjusted to text images and to sequence-to-sequence approaches. TextAdaIN is extremely easy to implement and can fit into any encoder as part of a mini-batch training process.
Throughout this work, unless mentioned otherwise, we integrate our proposed method with a state-of-the-art recognizer named SCATTER [38]. The SCATTER architecture consists of four main components: spatial transformation, feature extraction, visual feature refinement and a selective-contextual refinement block. For further details about the baseline architecture, we refer the reader to Appendix A. As elaborated on in [22], shortcuts are dependent on various factors, including the architecture of the model and the data. We therefore draw our motivation for suspecting local statistics as a potential instance of shortcut learning in text recognizers based on two key observations pertaining to both the architecture and the nature of the data. First, the characters appear across a series of frames along the width axis of the image. Therefore, text recognition approaches define the recognition task as a sequence character classification problem. This leads us to the second observation, the model's predictions are mostly based on local information which lies in consecutive frames [52,46]. Local information is referred to, in our work, as local feature statistics.

Shortcut Learning in Text Recognizers
As illustrated in Figure 1, when applying slight local modifications to the image distorting local information in a way which does not affect human reading capabilities (see Appendix B), the baseline model is unable to predict the words correctly. Table 1 quantitatively exemplifies this phenomenon, whereby the models fail to generalize to images under challenging testing conditions in the form of local corruptions. The table shows the performance of three different text recognition architectures -Baek et al. [6] with CTC and attention heads and SCATTER [38]. All models have been tested on the original scene-text and IAM datasets and on corrupted versions of these datasets. The corruptions used are the local-masking and pixel-wise distortions described in Table 6. All of the models suffer from a large decline in performance when adding the corruptions, and especially on handwriting where the training data is scarce.
An additional experiment validating text recognizers' sensitivity to local distortions is shown in Section 5.5, where we empirically demonstrate that text recognizers heavily rely on local information. Specifically, we show that profusely distorting global statistics has little to no effect on performance (unlike in classification models [45]). However, intensely distorting local statistics substantially degrades performance, which leads to the understanding that text recognizers do indeed rely on such information. The local statistics are an important cue, although they are not a determining factor. Thus, to regulate this ill-desired model bias, we propose TextAdaIN, a sequence-aware local variation of AdaIN.  To define AdaIN, we first begin with formally describing Instance Normalization (IN) [60]. Given an instance x ∈ R C×H×W , where C, H and W are the channels, height, and width respectively, IN is defined to be:

AdaIN
(1) Where γ, β ∈ R C are learned parameters and µ(x), σ(x) ∈ R C are calculated by taking the mean and standard deviation over H, W of x.
Adaptive Instance Normalization (AdaIN), proposed in [29], is built upon IN. Given two image representations, x a , x b ∈ R C×H×W , AdaIN shifts the statistics of the representation of x a to the representation of x b . This is done in two steps. First, Instance Normalization is applied on x a to remove x a 's style information. Then, the normalized activation map is scaled and shifted to match x b 's statistics. This operation is perceived to transfer AdaIN c denotes the standard AdaIN operation in which σ, µ are calculated over the spatial dimensions, resulting in shifting corresponding channel statistics.

TextAdaIN
We wish to design a method that produces model decision rules which are not overly reliant on local information. To this end, we propose a method which distorts local feature statistics during training. Leveraging the recent development proposed by [45,68], we suggest two modifications to the vanilla AdaIN operation that correspond to the aforementioned observations: 1. Viewing the feature map as a sequence of individual elements and swapping the feature statistics between elements instead of entire images. 2. Modifying AdaIN to operate on two dimensions -the height and channels of the feature map. These modifications increase the granularity level in which statistics are calculated and modified, thus regulating the reliance on local statistics. In addition, the sequential view enables the utilization of multiple donor images. Both are crucial for our method's success, as shown in Section 5.
Formally, given an image representation x ∈ R C×H×W , we define µ c,h , σ c,h to be the following: Therefore, a local variation of AdaIN c can be defined as: This variant of AdaIN swaps statistics for every corresponding channel and height, thus impacting the feature map's statistics at a higher level of granularity. We note that backpropagating gradients only occur through µ c,h (x a ), σ c,h (x a ). The reason behind this is to avoid gradient flow from input image labels to the donor images. Given the definitions above, we formulate the TextAdaIN operation used during training.
denote a mini-batch of B feature maps. We divide each sample x i into K windows along its width. The result is a batch of elements pertaining to B · K windows. This operation can be defined as a mapping: Then, we employ a similar procedure to the one used in [45]. We randomly draw a permutation of the modified batch X and apply AdaIN c,h between the modified batch and the permuted one. Namely, let denote applying a permutation π : Then the output of TextAdaIN on the i th window of X is defined by: Subsequently, the batch of windows is rearranged back to its original form using the inverse mapping operation. TextAdaIN is applied batch-wise with probability p after every convolutional layer in the encoder, as illustrated in Fig. 3(b). The permutation π is sampled uniformly, and p is a hyperparameter fixed ahead of training. TextAdaIN is only applied during training and not during inference.

Experiments
In this section, we begin by comparing our method's performance against state-of-theart methods on several public handwriting datasets. Then, we demonstrate that Tex-tAdaIN can be integrated into additional recognition architectures and applied to natural scene text images. Datasets We conduct experiments on several public handwriting and scene text datasets. For handwriting, we consider the English datasets IAM [43] and CVL [36], and the French dataset RIMES [26]. For scene text, we train on the synthetic datasets Synth-Text [27] and MJSynth [31] and test on four real-world regular text datasets: IIT5K [44], SVT [63], IC03 [41], IC13 [35] and three real-world irregular text datasets: ICDAR2015 [34], SVTP [47] and CUTE 80 [48]. We present samples from each dataset and include more details in Appendix C.
Metrics To evaluate recognition performance, word-level accuracy is measured. For handwritten text recognition state-of-the-art comparison, Word Error Rate (WER) and Character Error Rate (CER) are adopted, similar to the convention used in [57,67,2].
Implementation Details Unless mentioned otherwise, in all of our experiments, Tex-tAdaIN is fused into the backbone of SCATTER [38]. The experimental settings, including the optimizer, learning rate, image size, and training datasets, are identical to SCATTER [38]. Full implementation details are described in Appendix D.

Comparison to State-of-the-Art
In Table 2, we measure the accuracy of our proposed method on public handwritten text benchmarks. Our method achieves state-of-the-art results across all datasets. Compared to current state-of-the-art methods, incorporating TextAdaIN achieves a performance increase of +1.4 pp (85.9% vs. 87.3%) on IAM, +2.0 pp (92.4% vs. 94.4%) on RIMES and +0.4 pp (77.8% vs. 78.2%) on CVL. We wish to emphasize that previous methods, such as [9,33,42,2], introduced complex modifications to the training phase, including adversarial learning and contrastive pre-training. In contrast, TextAdaIN can be easily implemented in a few lines of code and seamlessly fit into any mini-batch training procedure. In addition, the effect of applying MixStyle [68] and pAdaIN [45] is displayed in Table 2. Both have little to no effect on the results, indicating that handwritten text recognizers are already invariant to changes in global statistics. We refer the reader to Appendix E to see failure cases of the model.

Generalization of Proposed Method
In this subsection, we explore our method's transferability to both the domain of scene text and to different recognition architectures. In addition to the SCATTER and AbiNet [18] architectures, we utilize the Baek et al. [6] framework, which can describe the building blocks of many text recognizers, including [52,55,51,53,40,62,13,14,67,38,20,66]. We choose to present TextAdaIN's performance when integrated into Baek et al. [6] framework while employing either a CTC [24] or an attention decoder [14,53]. As in [38], weighted (by size) average word accuracy is adopted where regular and irregular text datasets are distinguished.
In Table 3, we present the reproduced performance of the above methods. Tex-tAdaIN shows consistent improvement on both scene and handwritten text benchmarks independent of the chosen architecture. The results are competitive with recent stateof-the-art methods. In this section, we conduct a series of experiments to further understand the performance improvements and analyze the impact of our key contributions. For this purpose, we adopt the IAM dataset, and the baseline model is the SCATTER architecture [38]. Similar to our previous experiments, implementation details are described in Appendix D. We begin by exploring the different variants of AdaIN, demonstrating that our method significantly outperforms other variants. Then, we show the compatibility of our method with other augmentation pipelines demonstrating its unique benefit as a complimentary method. To analyze the performance as a function of the granularity level, we then measure the accuracy while varying the number of windows. Subsequently, we demonstrate the reliance of text recognizers on local feature statistics by increasing the hyperparameter p. Lastly, we perform an analysis of our method's robustness towards challenging testing conditions, demonstrating its effectiveness on relieving the model of this shortcut.

Input
Baseline AdaIN CW AdaIN C TextAdaIN AdaIN HW Fig. 4: Information encompassed in each dimension. Intensity maps of the features after the first convolution layer of the encoder are visualized. Each dimension of the feature space represents different information, hence, operating on different dimensions can influence the model accordingly. TextAdaIN has two noticeable effects: (1) injecting background distortions drawn from an induced distribution and (2) introducing masking on a local scale. Both regulate the reliance on local feature statistics, as further investigated in Section 5.4

AdaIN Variations
Each dimension of the feature space represents different information about the input. Hence, modifying AdaIN to operate across different dimensions can influence the model accordingly. Our method is employed over both the channel and height dimensions between different elements of samples in a batch. Each element consists of a pre-defined number of consecutive frames in the sequential feature map. As seen in Table 4, TextAdaIN significantly improves recognition performance as opposed to all other AdaIN variations.
To better understand the information encompassed in each of the dimensions, we visualize the feature maps of a trained baseline model in Fig. 4. For this purpose, we apply PCA on the spatial dimensions of the first convolutional layer's output, thus obtaining an H × W × 1 intensity map. An image depicting the spatial intensities is displayed after normalization.
As depicted in Fig. 4, applying AdaIN c , the vanilla variation, has almost no effect on the learned features. This is in alignment with the quantitative results indicating that text recognizers are relatively invariant to changes in global statistics. As for AdaIN c,w , modifying individual vertical frames introduces subtle changes to the feature map. The network can easily compensate for these distortions, leading to minimal impact on the training process. Interestingly, applying AdaIN h,w injects text from the donor image into the feature map. This phenomenon originates from shifting each corresponding spatial location in the representation space. Clearly, without the modification of the labels, this effect will not improve the performance.
TextAdaIN has two major effects, as visualized in Fig. 4. The first is injecting local perturbations drawn from an induced distribution into the feature space. The distribution is induced from the manner in which TextAdaIN operates, providing a correct balance between the coarse to fine distortion level. Namely, TextAdaIN's impact is more local than AdaIN c , yet more global in the sequence dimension than AdaIN c,w . Therefore, the impact aligns with both the nature of the data and sequence-to-sequence approaches.
Occasionally, statistics of smooth areas (without text) are injected into regions of the feature space which represent text. This generates the second effect of local masking, in which part of the textual features undergo masking. We hypothesize that this forces the model to rely on semi-semantic information, which compensates for the missing visual cues. This was partially observed by Aberdam et al. [2] while applying horizontal cropping and in the context of speech recognition by Baevski et al. [7]. As this analysis was performed on the feature space, we also show the influence of TextAdaIN on the input space in Section 5.4. Moreover, to see the importance of the induced distribution causing these effects, see Appendix F.

Compatibility with Augmentation Strategies
Similarly to TextAdaIN, data augmentation strategies can be used to relieve a model's propensity to shortcuts and increase their robustness. Hence, they have a similar effect, yet they operate at different levels. One at the input space and the other at the feature space. To validate the compatibility of our method with augmentation strategies, we apply a variety of augmentation strategies on top of the same architecture [38] with and without TextAdaIN. We choose augmentation strategies ranging from other text recognition frameworks [19,18], pseudo character-level augmentations [42] and stateof-the-art augmentation pipelines [17]. Table 5 displays the word accuracy for each augmentation pipeline with and without TextAdaIN. Applying TextAdaIN in conjunction with other augmentation strategies consistently improves performance and thus the contribution of TextAdaIN is complimentary to the chosen augmentation strategy. Furthermore, applying TextAdaIN without any augmentation outperforms all other independent augmentation pipelines, indicating the effectiveness and impact of our method over the most common regularization technique.

Number of Windows
TextAdaIN splits the feature map into windows along the width axis. Each window is perceived as an individual element in the AdaIN operation. As the features vary in size at different layers, we define K to represent the number of elements created per sample. Thus, K determines the window size at each layer. Modifying K has several different effects. For example, it controls the granularity level in which the statistics are calculated and modified and the number of donors. Therefore, an optimal value of K can be found to balance the different effects. In Appendix G, we plot the performance as a function of K. The best result is achieved when using K = 5. We note that the average length of English words is 4.7 characters. Thus, when K = 5, the statistics are normalized per character on average.

Challenging Testing Conditions
Notice that our approach leads to a similar boost on each of the datasets across all tested architectures and augmentation settings (for example ≈ +1% on IAM). This suggests that this gap indeed stems from the shortcuts in the data and is not model dependent. Thus, we expect our method to perform similarly even on future and better-performing architectures. Moreover, we remind that one can detect shortcut learning at test time, given an image that violates the shortcut hypothesis (i.e., an "f" with a different level of curvature than in the train). Thus, there are potentially even more undiscovered shortcuts than our improvements on standard test benchmarks reveal. To better demonstrate the existence of unrevealed shortcut learning, we perturb the test data in a way that changes its local style without modifying the semantic content. If the models are independent of the local style, one would expect that they will be robust to such modifications. Nevertheless, the significant performance drop (Table 1) reveals that these models are highly prone to shortcut learning, much more than discovered on the unperturbed test sets. To demonstrate that TextAdaIN indeed improves robustness towards challenging testing conditions, in Table 6, we evaluate its performance on several types of corruptions, comparing it to the baseline model. The corruptions are divided into three categories: (1) local masking, (2) pixel-wise methods and (3) geometric transformations. For each corruption, we display the gap between the performance of the baseline versus the TextAdaIN model. To accentuate the improvement provided by our method, we also display the normalized gap -the ratio between the gap on the corrupted data and the gap on the original data. This normalization removes the performance advantage of TextAdaIN on the original data. The results indicate that TextAdaIN improves the model's robustness towards o.o.d testing scenario. For example, the gap on additive noise is 10%. We note that the normalized gap, which represents TextAdaIN's robustness gains, is substantially higher in localbased corruptions rather than geometric corruptions which are applied globally. This provides further evidence that TextAdaIN regulates the reliance on local statistics in text recognizers. Despite the benefits of our method, Table 6 indicates that there are potentially even more undiscovered shortcuts as a significant gap exists when comparing to the original unperturbed test set. In this subsection, we wish to further assert text recognizers' reliance on local statistics. Nuriel et al. [45] observed that applying AdaIN at high values of p resulted in a significant degradation of classification performance. We can thus infer that image classifiers depend on global statistics. For text recognizers, as shown in Table 7, this is not the case. Increasing the value of p, when applying AdaIN, only slightly affects the results. This indicates that global statistics are less significant in text recognition. In contrast, applying Tex-tAdaIN with a high value of p decreases performance substantially. This implies that profusely applying TextAdaIN distorts important information that the model relies on. Therefore, text recognizers are prone to develop an unintended shortcut solution in the form of local statistics. If applied correctly, with the right p, TextAdaIN can alleviate this shortcut.

Conclusion
Text recognizers leverage convolutional layers to extract rich visual features, and hence are extremely powerful. However, in this work, we expose their propensity towards learning an unintended "shortcut" strategy, whereby they overly rely on local statistics. Consequently, exhibiting a sensitivity towards subtle modifications that preserve image content. To relieve text recognizers' shortcut learning, we introduce TextAdaIN, a normalization-based method which distorts the feature space in a local manner and effectively regulates the reliance on local statistics. Our method achieves state-of-the-art results on handwritten text recognition benchmarks and improves robustness towards challenging testing conditions. TextAdaIN is also applicable to various recognition architectures and to the domain of scene text images. Furthermore, it can be implemented simply in a few lines of code and effortlessly integrated into a mini-batch training procedure. By taking into account the nature of the data and the archictectural characteristics, this shortcut was exposed. Yet, as we have seen, the prevalence of shortcuts is still at large. As future work, we wish to explore other shortcuts pertaining to text recognizers.

A SCATTER -Baseline Architecture
As mentioned in the paper, throughout this work our baseline architecture is a state-ofthe-art recognizer named SCATTER [38]. The SCATTER architecture consists of four main components: 1. Transformation: A rectification module that aligns the input text image using a Thin Plate Spline (TPS) transformation [39,53]

C Datasets
In this work, we consider the following public datasets for handwriting and scene text. Samples from the different datasets are depicted in Fig. 6.

C.1 Handwritten text
For handwriting recognition, we consider three datasets: -IAM [43] handwritten English text dataset, written by 657 different writers. This dataset contains 101,400 correctly segmented words, partitioned into writer independent training, validation and test. -CVL [36] handwritten English text dataset, written by 310 different writers. 27 of the writers wrote 7 texts, and the other 283 writers wrote 5 texts. This dataset contains 84,990 correctly segmented words, partitioned into writer independent training and test. We use the same partitions as in [20,2], in which the 310 writers are used for training and the additional 27 writers are considered test. -RIMES [26] handwritten French text dataset, written by 1300 different writers.
This dataset contains 66,480 correctly segmented words, partitioned into training, validation and test sets that are independent of writers.

C.2 Scene text
For training the scene text models, we utilized only synthetic datasets: -MJSynth (MJ) [31] a synthetic text in image dataset which contains 9 million word-box images, generated from a lexicon of 90K English words. -SynthText (ST) [27] a synthetic text in image dataset, containing 5.5 million words, designed for scene text detection and recognition. -SynthAdd (SA) [37] only when training SCATTER for scene text, as in the original paper [38], SA was also utilized for training data. This dataset was generated using the same synthetic engine as in ST and contains 1.2 million word box images. SA is used for compensating the lack of non-alphanumeric characters in the training data.  Aligned with many scene text recognition manuscripts (e.g. [54,6,37,38]

D Implementation Details
In our experiments, we utilize four types of architectures. The first is SCATTER, the second and third are two other are variants of the Baek et al. [6] framework and the last is AbiNet [18]. All models are trained and tested using the PyTorch framework on a Tesla V100 GPU with 16GB memory. We follow the training procedure performed in [38]. Accordingly, models are trained using the AdaDelta optimizer with: a decay rate of 0.95, gradient clipping with a magnitude of 5 and batch size of 128. During training, 40% of the input images are augmented by randomly resizing them and adding extra distortion. Models trained on handwriting and scene text datasets are trained for 200k iterations and 600k iterations, respectively. Model selection is performed on the validation set, which for scene text is the union of the IC13, IC15, IIIT5K and SVT training splits and for handwriting is the predefined validation sets. When utilizing SCATTER, all images are resized to 32 × 128 and are in RGB format. For evaluation, word accuracy measured is case insensitive. We refer the reader for any additional implementation details, both during inference and training, to the original papers [6,38].
To reproduce the results for AbiNet we downloaded the pretrained models from the official open source implementation (https://github.com/FangShancheng/ ABINet) and re-ran the fine-tune step. When adding TextAdaIN, we apply it in both phases, in the pre-training step as well as in the fine-tuning step. We use the default configurations as defined in the repository. For handwriting, we use the default configurations but run for 100 epochs and adjust the learning rate schedule to 60, 25, 15. For TextAdaIN, we use p = 0.01 and split images into K = 5 windows. In the cases where the number of windows does not divide the width, we use the maximum width that can be divided and ignore the remainder.

E Failure Cases
In Fig. 7, we display failure cases of our method on the IAM dataset. The failure cases are mostly composed of highly cursive text, unclear handwriting styles and ambiguous cases. Adding additional context by employing a line-level approach can assist in rectifying these types of errors, nevertheless, line-level recognition has its own caveats. Fig. 7: Failure cases. Samples of failure cases on the IAM dataset. GT stands for the ground truth annotation, and Pred is the predicted result. Prediction errors are marked in red, and missing characters are annotated by strike-through.

F The importance of an induced distribution
We show the importance of sampling from an induced distribution, specifically the distribution derived by the representation spaces of natural text images. As shown in Table 8, using Gaussian noise or background images only slightly increases performances. In contrast, TextAdaIN, which samples from the appropriate induced distribution, shows the highest increase in performance.

G Number of Windows
As mentioned in the main paper, TextAdaIN splits the feature map into windows along the width axis. As the features vary in size at different layers, we define K to represent the number of elements created per sample. Thus, K determines the window size at each layer. Modifying K has several different effects. For example, it controls the granularity level in which the statistics are calculated and modified and the number of donors. Therefore, an optimal value of K can be found to balance the different effects. In Fig. 8, we plot the performance as a function of K. The best result is achieved when using K = 5.

H TextAdaIN Pseudo-Code
In this section, we provide pseudo-code for TextAdaIN. The code includes two functions not explicitly implemented: create windows from tensor, revert windowed tensor. The first function represents the mapping: and the second represents the corresponding inverse mapping. As mentioned in the paper, we do not backpropogate through µ c,h (x π(i) ), σ c,h (x π(i) ) and thus, detach is used. 1 def TextAdaIN(x, p=0.01, k=5, eps=1e-4):