{"notes":[{"id":"text-recognition/abinet","category":"text-recognition","legacyPath":"text-recognition/2103-abinet","legacySlug":"2103-abinet","legacyPaths":[],"title":"ABINet","subtitle":"Thinking more!","author":"Z. Yuan","paperDate":"2021-03-11","publishedOn":"2024-11-04","paperTitle":"Read Like Humans: Autonomous, Bidirectional and Iterative Language Modeling for Scene Text Recognition","paperUrl":"https://arxiv.org/abs/2103.06495","bibliography":{"title":"Read Like Humans: Autonomous, Bidirectional and Iterative Language Modeling for Scene Text Recognition","authors":["Shancheng Fang","Hongtao Xie","Yuxin Wang","Zhendong Mao","Yongdong Zhang"],"url":"https://arxiv.org/abs/2103.06495","pdfUrl":"https://arxiv.org/pdf/2103.06495","codeUrl":null,"preprint":{"id":"2103.06495","submittedOn":"2021-03-11","url":"https://arxiv.org/abs/2103.06495"},"publication":{"venue":"CVPR","year":2021,"kind":"conference","url":"https://arxiv.org/abs/2103.06495"},"citation":"@misc{textrecognitionabinet2021,\n  title = {{Read Like Humans: Autonomous, Bidirectional and Iterative Language Modeling for Scene Text Recognition}},\n  author = {Shancheng Fang and Hongtao Xie and Yuxin Wang and Zhendong Mao and Yongdong Zhang},\n  year = {2021},\n  eprint = {2103.06495},\n  archivePrefix = {arXiv},\n  url = {https://arxiv.org/abs/2103.06495}\n}\n","citationPath":"/content/papers/citations/text-recognition/abinet.73bc0bb60d4e.bib"},"thumbnail":{"src":"/content/papers/assets/dd3f71609a9aed29caa0b237880c58e2582197f57faa202b18ed16033f22d0b0.jpg","width":1706,"height":694},"locale":"en","path":"/content/papers/en/text-recognition/abinet.90f599e77ebf.md","headings":[{"id":"problem-definition","text":"Problem Definition","depth":2},{"id":"solution","text":"Solution","depth":2},{"id":"visual-model","text":"Visual Model","depth":3},{"id":"language-model","text":"Language Model","depth":3},{"id":"implementation-details","text":"Implementation Details","depth":3},{"id":"discussion","text":"Discussion","depth":2},{"id":"comparison-with-other-methods","text":"Comparison with Other Methods","depth":3},{"id":"ablation-study---visual-model","text":"Ablation Study - Visual Model","depth":3},{"id":"ablation-study---language-model","text":"Ablation Study - Language Model","depth":3},{"id":"ablation-study---bidirectional-strategy","text":"Ablation Study - Bidirectional Strategy","depth":3},{"id":"visualization-analysis","text":"Visualization Analysis","depth":3},{"id":"conclusion","text":"Conclusion","depth":2}],"anchorAliases":{},"guide":null,"relatedReading":[{"id":"text-recognition/seed","relation":"comparison","topic":"Using linguistic context in text recognition"}]},{"id":"text-recognition/seed","category":"text-recognition","legacyPath":"text-recognition/2005-seed","legacySlug":"2005-seed","legacyPaths":[],"title":"SEED","subtitle":"The Seed of Language","author":"Z. Yuan","paperDate":"2020-05-22","publishedOn":"2024-11-09","paperTitle":"SEED: Semantics Enhanced Encoder-Decoder Framework for Scene Text Recognition","paperUrl":"https://arxiv.org/abs/2005.10977","bibliography":{"title":"SEED: Semantics Enhanced Encoder-Decoder Framework for Scene Text Recognition","authors":["Zhi Qiao","Yu Zhou","Dongbao Yang","Yucan Zhou","Weiping Wang"],"url":"https://arxiv.org/abs/2005.10977","pdfUrl":"https://arxiv.org/pdf/2005.10977","codeUrl":null,"preprint":{"id":"2005.10977","submittedOn":"2020-05-22","url":"https://arxiv.org/abs/2005.10977"},"publication":{"venue":"CVPR","year":2020,"kind":"conference","url":"https://arxiv.org/abs/2005.10977"},"citation":"@misc{textrecognitionseed2020,\n  title = {{SEED: Semantics Enhanced Encoder-Decoder Framework for Scene Text Recognition}},\n  author = {Zhi Qiao and Yu Zhou and Dongbao Yang and Yucan Zhou and Weiping Wang},\n  year = {2020},\n  eprint = {2005.10977},\n  archivePrefix = {arXiv},\n  url = {https://arxiv.org/abs/2005.10977}\n}\n","citationPath":"/content/papers/citations/text-recognition/seed.e2689e3c957c.bib"},"thumbnail":{"src":"/content/papers/assets/8592487550270e392307478d6a0274ab54b2ab602f077b32b5bc63cfbeec32a0.jpg","width":964,"height":736},"locale":"en","path":"/content/papers/en/text-recognition/seed.ca3ae1a0a780.md","headings":[{"id":"problem-definition","text":"Problem Definition","depth":2},{"id":"solution","text":"Solution","depth":2},{"id":"model-architecture","text":"Model Architecture","depth":3},{"id":"pre-trained-language-model","text":"Pre-trained Language Model","depth":3},{"id":"loss-function","text":"Loss Function","depth":3},{"id":"implementation-details","text":"Implementation Details","depth":3},{"id":"discussion","text":"Discussion","depth":2},{"id":"comparison-with-recent-methods","text":"Comparison with Recent Methods","depth":3},{"id":"visualization-of-results","text":"Visualization of Results","depth":3},{"id":"conclusion","text":"Conclusion","depth":2}],"anchorAliases":{},"guide":null,"relatedReading":[{"id":"text-recognition/abinet","relation":"comparison","topic":"Using linguistic context in text recognition"}]}],"text":"Visual recognition seems to have reached its limit. People began thinking about how to make a model understand and read text more like a person.\n\n## Problem Definition\n\nPrevious research has often relied solely on visual features for text recognition. However, when text is blurred, occluded, or distorted, models struggle to recognize it accurately. This is because visual features are compromised, making it difficult for the model to detect text reliably.\n\nTo address this limitation, researchers have begun incorporating language models to help models understand text contextually. For instance, if we see a blurred text like “APP?E,” a language model can help us infer that the intended word is likely “APPLE.”\n\nHuman reading behavior is generally characterized by:\n\n1. **Autonomy**: Humans can learn from both visual and linguistic cues independently, with language knowledge supporting visual understanding of text.\n2. **Bidirectionality**: When text is unclear, humans use surrounding context to fill in the blanks.\n3. **Iterative Process**: Humans can continuously refine their understanding through repeated reasoning and correction.\n\nThis paper’s authors propose that models should replicate these human reading characteristics:\n\n1. **Autonomy**: The model uses separate vision and language modules to model text independently by its visual and linguistic features.\n2. **Bidirectionality**: The authors introduce a “Bidirectional Cloze Network” that learns from context on both sides of the text.\n3. **Iterative Process**: The model refines its predictions iteratively, gradually improving its accuracy.\n\nWith this approach in mind, the authors have defined the conceptual foundation. The remaining step is to prove its effectiveness through experimentation!\n\n## Solution\n\nThe authors propose a new model architecture: **ABINet**, designed to tackle the challenges of scene text recognition.\n\n### Visual Model\n\n![ABINet analysis](/content/papers/assets/04addfa93915e9c31cb0d622433d764af40f09acba5bdf06405217e87e92949e.jpg)\n\nThe visual model follows a familiar architecture: it uses ResNet to extract features and a Transformer to model the sequence, transforming an input image $x$ into a feature representation:\n\n$$\nF_b = \\tau(R(x)) \\in \\mathbb{R}^{\\frac{H}{4} \\times \\frac{W}{4} \\times C}\n$$\n\nwhere $H$ and $W$ represent the image dimensions, and $C$ is the feature dimension.\n\nPositional attention converts the spatial features $F_b$ into per-position visual features $F_v$; a classification head then produces character probabilities:\n\n$$\nF_v = \\text{softmax}\\left(\\frac{QK^T}{\\sqrt{C}}\\right)V\n$$\n\nHere's a breakdown of each component in the attention calculation:\n\n- **$Q \\in \\mathbb{R}^{T \\times C}$**: This is the positional encoding of the character sequence, encoding each character's position in the sequence to help the model understand the order of characters. Specifically, $T$ represents the sequence length, or the number of characters to be processed, while $C$ denotes the feature dimension.\n\n- **$K = G(F_b) \\in \\mathbb{R}^{\\frac{HW}{16} \\times C}$**: The \"key\" $K$ is derived from $F_b$ through a function $G(\\cdot)$, which in this case is implemented as a mini U-Net structure. The mini U-Net enriches spatial context. The number of keys remains $HW/16$, while the number of queries is $T$; these need not be equal.\n\n- **$V = H(F_b) \\in \\mathbb{R}^{\\frac{HW}{16} \\times C}$**: The \"value\" $V$ is obtained by applying an identity mapping $H(\\cdot)$ on $F_b$, meaning that $F_b$ is passed directly without additional transformations. This gives $V$ the same dimensions as $K$, preserving consistency in feature space and spatial resolution.\n\nThe attention matrix has shape $T \\times HW/16$. It weights the spatial features separately for each output position, producing $F_v \\in \\mathbb{R}^{T \\times C}$. These are feature vectors, not character probabilities.\n\n\n> [!TIP]\n> \n> Positional queries gather image features for each potential character position. Classification and softmax then convert those features into probabilities over the character set.\n\n\n### Language Model\n\n![ABINet analysis](/content/papers/assets/dd3f71609a9aed29caa0b237880c58e2582197f57faa202b18ed16033f22d0b0.jpg)\n\nThe language model in ABINet is integrated after the visual model, using several key strategies to improve text recognition performance:\n\n1. **Autonomous Strategy**:\n\n   As shown in the diagram, the language model functions independently as a spelling correction model. It takes character probability vectors as input and outputs the probability distribution for each character. This independence allows the language model to be trained on unlabeled text data separately, enhancing the model's interpretability and modularity. Replacing the language model still requires a compatible character set, input/output representation, and training setup.\n\n   To ensure this autonomy, the authors introduce a technique called Blocking Gradient Flow (BGF), which detaches the language model’s input probabilities: gradients from the language branch cannot flow back through those inputs into the visual prediction branch.\n\n   This modular design allows linguistic pretraining to be studied separately, but does not make arbitrary pretrained language models drop-in replacements.\n\n2. **Bidirectional Strategy**:\n\n   ![Bidirectional strategy](/content/papers/assets/3f8595df860b16b202c42301bf760388038bdf0ba91c596971bc9d55e7d94fda.jpg)\n\n   The language model calculates conditional probabilities for bidirectional and unidirectional representations, denoted as $P(y_i | y_n, \\dots, y_{i+1}, y_{i-1}, \\dots, y_1)$ for bidirectional and $P(y_i | y_{i-1}, \\dots, y_1)$ for unidirectional. Bidirectional modeling provides richer semantic information by considering both left and right contexts.\n\n   For a strict leave-one-position-out prediction, a straightforward use of a BERT-style masked language model would require separate masks for the target positions. BCN implements these cloze queries in parallel. This comparison concerns that use case; MLM training in general can mask multiple positions at once.\n\n   BCN adopts a Transformer decoder-like structure but with unique modifications. Instead of causal masking, BCN uses a custom attention mask to prevent each character from \"seeing\" itself. At each layer, the keys and values come from the input character probabilities, while the queries use positional encodings or the previous layer's output; this also prevents information from leaking across layers.\n\n   The mask matrix $M$ in BCN’s multi-head attention block is constructed as follows:\n\n   $$\n   M_{ij} =\n   \\begin{cases}\n     0, & i \\neq j \\\\\n     -\\infty, & i = j\n   \\end{cases}\n   $$\n\n   Here, $K_i = V_i = P(y_i) W_l$, where $P(y_i) \\in \\mathbb{R}^c$ is the probability distribution of character $y_i$, and $W_l \\in \\mathbb{R}^{c \\times C}$ is a linear mapping matrix.\n\n   The multi-head attention computation is given by:\n\n   $$\n   F_{\\text{mha}} = \\text{softmax}\\left(\\frac{QK^T}{\\sqrt{C}} + M\\right)V\n   $$\n\n   In this, $Q \\in \\mathbb{R}^{T \\times C}$ represents positional encodings in the first layer and outputs from the previous layer in subsequent layers, while $K$ and $V \\in \\mathbb{R}^{T \\times C}$ come from the linear mapping of character probabilities $P(y_i)$.\n\n   The BCN’s cloze-like attention mask enables the model to learn a stronger bidirectional representation, capturing more complete semantic context than unidirectional models.\n\n\n> [!TIP]\n> \n> Key Points:\n> \n> 1. BCN uses a decoder structure but without causal masking, enabling parallel decoding.\n> 2. Instead of [MASK], BCN applies a diagonal mask to improve computational efficiency.\n\n\n3. **Iterative Strategy**:\n\n   The authors propose an Iterative Correction strategy to address noise in the visual model’s input, which can lower prediction confidence during Transformer’s parallel decoding. In the first iteration, $y_{i_1}$ represents the visual model's probability predictions. In subsequent iterations, $y_{i \\geq 2}$ comes from the previous fusion model's predictions.\n\n\n> [!TIP]\n> \n> The language and fusion modules are applied repeatedly, feeding each fused probability prediction into the next correction round. This is distinct from merely stacking more Transformer layers.\n\n\n4. **Fusion**\n\n   Since the visual model is trained on image data and the language model on text data, these two sources of information need to be aligned. The authors employ a \"gated mechanism\" to fuse the visual and language features effectively, balancing their contributions in the final prediction.\n\n   Visual features $F_v$ and language features $F_l$ are concatenated, and a linear mapping $W_f \\in \\mathbb{R}^{2C \\times C}$ compresses the concatenated features to match the dimensions of $F_v$ and $F_l$.\n\n   The gated vector $G$ is calculated as:\n\n   $$\n   G = \\sigma([F_v, F_l] W_f)\n   $$\n\n   Here, $\\sigma$ is the Sigmoid function, which bounds $G$ between 0 and 1, controlling the balance between the visual and language features in the final output.\n\n   The fused feature $F_f$ is obtained by weighted combining $F_v$ and $F_l$ as follows:\n\n   $$\n   F_f = G \\odot F_v + (1 - G) \\odot F_l\n   $$\n\n   where $\\odot$ represents element-wise multiplication. When $G$ is close to 1, visual features $F_v$ have a stronger influence, while a value close to 0 gives more weight to language features $F_l$.\n\n5. **Supervised Training**\n\n   ABINet is trained end-to-end with a multi-task objective, combining the losses from the visual, language, and fused features.\n\n   The objective function is:\n\n   $$\n   L = \\lambda_v L_v + \\frac{\\lambda_l}{M} \\sum_{i=1}^{M} L_l^i + \\frac{1}{M} \\sum_{i=1}^{M} L_f^i\n   $$\n\n   where:\n\n   - **$L_v$**: Cross-entropy loss for visual features $F_v$.\n   - **$L_l$**: Cross-entropy loss for language features $F_l$.\n   - **$L_f$**: Cross-entropy loss for fused features $F_f$.\n   - **$L_l^i$** and **$L_f^i$**: Losses at iteration $i$ for language and fused features, respectively.\n   - **$\\lambda_v$** and **$\\lambda_l$**: Balancing factors for adjusting the contributions of each loss term, ensuring a balanced influence from visual and language features in training.\n\n### Implementation Details\n\n- **Training Datasets**: The model is trained on two synthetic datasets, MJSynth (MJ) and SynthText (ST).\n- **Testing Datasets**: The evaluation is conducted on six standard benchmark datasets: ICDAR 2013 (IC13), ICDAR 2015 (IC15), IIIT 5K-Words (IIIT), Street View Text (SVT), Street View Text-Perspective (SVTP), and CUTE80 (CUTE).\n- **Unlabeled Data for Semi-supervised Learning**: The Uber-Text dataset (with labels removed) is used to assess the effectiveness of semi-supervised learning.\n- **Model Configuration**: The model dimension $C$ is set to 512, with the Bidirectional Cloze Network (BCN) comprising 4 layers and 8 attention heads per layer. The balancing factors $\\lambda_v$ and $\\lambda_l$ are both set to 1.\n- **Image Preprocessing**: Images are resized to 32×128 and augmented with techniques such as geometric transformations, image quality degradation, and color jittering to improve robustness.\n- **Training Environment**: The training is conducted on four NVIDIA 1080Ti GPUs with a batch size of 384. The ADAM optimizer is used with an initial learning rate of $1 \\times 10^{-4}$, which decays to $1 \\times 10^{-5}$ after the sixth epoch.\n\n## Discussion\n\n### Comparison with Other Methods\n\n![ABINet analysis](/content/papers/assets/46022258a4e0a3d7deb35a512fb259acedbdff9563d1176748b68b1919dae54b.jpg)\n\nTo ensure a fair and rigorous comparison, the authors re-implemented the SOTA algorithm SRN using the same experimental configuration as ABINet. Two re-implemented versions of SRN were tested with different visual models (VMs), alongside several adjustments, such as replacing the VM, removing the side effects of multi-scale training, and applying learning rate decay. These modifications resulted in improved performance compared to the original SRN as reported.\n\n- **Comparison between ABINet-SV and SRN-SV**: ABINet-SV outperformed SRN-SV across multiple datasets.\n- **Performance of ABINet-LV**: With a stronger VM, ABINet-LV outperformed the corresponding SRN-LV on five of the six datasets; IIIT is the exception, at 96.2% versus 96.3%.\n\nABINet trained on MJ and ST performed particularly well on challenging datasets like SVT, SVTP, and IC15, which contain numerous low-quality images with noise and blur. ABINet leveraged linguistic information to significantly enhance recognition accuracy, especially under these difficult conditions.\n\nFurthermore, ABINet was able to recognize irregular fonts and non-standard layouts effectively, thanks to the complementary role of language information in visual feature processing. Even without image rectification, ABINet achieved second-best performance on the CUTE dataset, showing its robust ability to handle irregular text.\n\n### Ablation Study - Visual Model\n\n![ABINet analysis](/content/papers/assets/6e4b699c9b5e81f0c76bdef3518680a41effcd5d77da7cf6159a2aaaa8a9e6f8.jpg)\n\nIn this ablation study, the authors mainly compared different feature extraction and sequence modeling methods.\n\nThe proposed \"positional attention\" technique demonstrated a stronger capacity for representing key-value vectors compared to common parallel attention methods.\n\nAdditionally, upgrading the visual model (VM) significantly improved accuracy, albeit at the cost of additional parameters and computational overhead. Alternatively, performance can be enhanced by using positional attention for feature extraction and employing a deeper Transformer for sequence modeling in the VM.\n\n### Ablation Study - Language Model\n\n![ABINet analysis](/content/papers/assets/bdcb94a6e1726b026106d236738911a763675b50fd7d919e40dfee838ee9c240.jpg)\n\n- **PVM**: Indicates supervised pre-training of the visual model (VM) on the MJ and ST datasets.\n- **$\\text{PLM}_{in}$**: Refers to self-supervised pre-training of the language model (LM) on the MJ and ST datasets.\n- **$\\text{PLM}_{out}$**: Refers to self-supervised pre-training of the language model on the large-scale WikiText-103 dataset.\n- **AGF (Allowing Gradient Flow)**: This setting allows gradient flow between the visual model and the language model.\n\n---\n\n**Findings**:\n\n- **PVM**: Supervised pre-training of the VM (PVM) results in an average accuracy improvement of 0.6–0.7 percentage points, showing that pre-training the visual model significantly enhances its text recognition performance.\n\n- **$\\text{PLM}_{in}$**: The effect of $\\text{PLM}_{in}$ is limited, likely because the MJ and ST datasets lack the diversity and language structure needed to provide comprehensive linguistic information.\n\n- **$\\text{PLM}_{out}$**: Pre-training the LM on the larger and more diverse WikiText-103 dataset ($\\text{PLM}_{out}$) leads to a significant improvement, as this dataset enriches the LM's understanding of textual context, enhancing performance even when accuracy is already high.\n\n- **AGF**: Allowing gradients through the language model’s input probabilities lowers mean accuracy from 92.3% to 91.4%, a drop of 0.9 percentage points, while training loss falls quickly. The authors interpret this as possible overfitting: the language model may use information from the visual model to \"cheat\" during training. BGF blocks this backward path and supports more independent language modeling.\n\n### Ablation Study - Bidirectional Strategy\n\n![ABINet analysis](/content/papers/assets/eb4e49cc09c4ea660e6e57c22ed65c31d68ddb0fcf8763c94d54e3c8a1fc1e9a.jpg)\n\nSince BCN is a Transformer-based variant, it was compared to SRN, another Transformer-based model.\n\nTo ensure fairness, the experiments were conducted under identical conditions except for network structure. SV and LV were used as visual models (VMs) to evaluate BCN's effectiveness at different accuracy levels.\n\n- **BCN vs. SRN-U**: BCN, when compared to SRN's unidirectional version (SRN-U), has similar parameters and inference speed but demonstrates a competitive advantage in accuracy across different VMs.\n\n- **BCN vs. Bidirectional SRN**: BCN outperforms the bidirectional SRN, especially on challenging datasets like IC15 and CUTE. In the table, inference time falls from 24.2 to 19.5 ms with SV and from 26.9 to 22.0 ms with LV; accuracy for each configuration should be compared alongside speed.\n\n### Visualization Analysis\n\n![ABINet analysis](/content/papers/assets/1c05dc645fd5c0cd3aa73957f695e698ad899a15a5afdaf1ab04176848ef8868.jpg)\n\nTo understand how BCN operates within ABINet, the authors visualized the top-5 prediction probabilities for the word \"today,\" as shown in the figure above.\n\n- When the input is “-oday” or “tod-y,” BCN confidently predicts “t” and “a,” contributing positively to the final fusion predictions.\n- For erroneous characters like “l” and “o,” BCN’s confidence is low, minimizing their impact on the final prediction.\n- When multiple erroneous characters are present, BCN struggles to restore the correct text due to insufficient contextual support.\n\nThis visualization demonstrates BCN’s ability to leverage context for accurate predictions and highlights its limitations when handling extensive errors in the input text.\n\n## Conclusion\n\nThis paper introduces a language model branch into text recognition models. Through the autonomous, bidirectional, and iterative design, ABINet effectively improves text recognition accuracy and generalization. Experimental results demonstrate that ABINet achieves outstanding performance across multiple benchmark datasets, particularly excelling in irregular text and low-quality images.\n\n\n> [!TIP]\n> \n> This approach is reminiscent of early text recognition models, which often used a \"dictionary\" to refine output predictions by matching them to the closest valid word. However, as models like CRNN became popular, the use of dictionaries declined due to limitations: dictionaries couldn’t be jointly trained with the model, and they constrained the diversity of output due to their fixed size.\n> \n> In a way, we’ve come full circle, but now the dictionary concept has been replaced with a language model that aids in text interpretation. The significant advantage here is that the language model can be trained jointly with the visual model. However, similar to dictionary-based methods, language models are constrained by the diversity of training data. For instance, they might struggle with texts lacking semantic meaning, such as license plates or serial numbers, where the language model may not be beneficial. Additionally, for text containing puns or phonetic variations, the language model might introduce misinterpretations.\n> \n> Despite these limitations, integrating language models remains an important attempt. In the years that followed, much text recognition research centered on language models. We will keep following this field's development.\n","imageSizes":{"/content/papers/assets/04addfa93915e9c31cb0d622433d764af40f09acba5bdf06405217e87e92949e.jpg":{"width":1020,"height":580},"/content/papers/assets/dd3f71609a9aed29caa0b237880c58e2582197f57faa202b18ed16033f22d0b0.jpg":{"width":1706,"height":694},"/content/papers/assets/3f8595df860b16b202c42301bf760388038bdf0ba91c596971bc9d55e7d94fda.jpg":{"width":804,"height":836},"/content/papers/assets/46022258a4e0a3d7deb35a512fb259acedbdff9563d1176748b68b1919dae54b.jpg":{"width":1548,"height":590},"/content/papers/assets/6e4b699c9b5e81f0c76bdef3518680a41effcd5d77da7cf6159a2aaaa8a9e6f8.jpg":{"width":1004,"height":370},"/content/papers/assets/bdcb94a6e1726b026106d236738911a763675b50fd7d919e40dfee838ee9c240.jpg":{"width":904,"height":544},"/content/papers/assets/eb4e49cc09c4ea660e6e57c22ed65c31d68ddb0fcf8763c94d54e3c8a1fc1e9a.jpg":{"width":902,"height":522},"/content/papers/assets/1c05dc645fd5c0cd3aa73957f695e698ad899a15a5afdaf1ab04176848ef8868.jpg":{"width":1224,"height":432}}}
