{"notes":[{"id":"text-recognition/satrn","category":"text-recognition","legacyPath":"text-recognition/1910-satrn","legacySlug":"1910-satrn","legacyPaths":[],"title":"SATRN","subtitle":"Transformer 抵达战场","author":"Z. Yuan","paperDate":"2019-10-10","publishedOn":"2024-10-13","paperTitle":"On Recognizing Texts of Arbitrary Shapes with 2D Self-Attention","paperUrl":"https://arxiv.org/abs/1910.04396","bibliography":{"title":"On Recognizing Texts of Arbitrary Shapes with 2D Self-Attention","authors":["Junyeop Lee","Sungrae Park","Jeonghun Baek","Seong Joon Oh","Seonghyeon Kim","Hwalsuk Lee"],"url":"https://arxiv.org/abs/1910.04396","pdfUrl":"https://arxiv.org/pdf/1910.04396","codeUrl":null,"preprint":{"id":"1910.04396","submittedOn":"2019-10-10","url":"https://arxiv.org/abs/1910.04396"},"publication":{"venue":"CVPR Workshops","year":2020,"kind":"workshop","url":"https://doi.org/10.1109/cvprw50498.2020.00281"},"citation":"@misc{textrecognitionsatrn2019,\n  title = {{On Recognizing Texts of Arbitrary Shapes with 2D Self-Attention}},\n  author = {Junyeop Lee and Sungrae Park and Jeonghun Baek and Seong Joon Oh and Seonghyeon Kim and Hwalsuk Lee},\n  year = {2019},\n  eprint = {1910.04396},\n  archivePrefix = {arXiv},\n  url = {https://arxiv.org/abs/1910.04396}\n}\n","citationPath":"/content/papers/citations/text-recognition/satrn.1f218ed8cb52.bib"},"thumbnail":{"src":"/content/papers/assets/30eedea70bdfcce81cbdde80e181f20fe6b6887ab2f147bec508540a92a678d4.jpg","width":944,"height":1080},"locale":"zh-hans","path":"/content/papers/zh-hans/text-recognition/satrn.1abe5afa0002.md","headings":[{"id":"定义问题","text":"定义问题","depth":2},{"id":"解决问题","text":"解决问题","depth":2},{"id":"模型架构","text":"模型架构","depth":3},{"id":"讨论","text":"讨论","depth":2},{"id":"和先前方法的比较","text":"和先前方法的比较","depth":3},{"id":"和-sar-模型的比较","text":"和 SAR 模型的比较","depth":3},{"id":"多行文本辨识","text":"多行文本辨识","depth":3},{"id":"消融研究","text":"消融研究","depth":3},{"id":"结论","text":"结论","depth":2}],"anchorAliases":{},"guide":null,"relatedReading":[{"id":"text-recognition/crnn","relation":"background","topic":"从循环式文字识别到注意力"},{"id":"text-recognition/parseq","relation":"next","topic":"从循环式文字识别到注意力"}]},{"id":"text-recognition/crnn","category":"text-recognition","legacyPath":"text-recognition/1507-crnn","legacySlug":"1507-crnn","legacyPaths":[],"title":"CRNN","subtitle":"我全都要！","author":"Z. Yuan","paperDate":"2017","publishedOn":"2024-10-07","paperTitle":"An End-to-End Trainable Neural Network for Image-based Sequence Recognition and Its Application to Scene Text Recognition","paperUrl":"https://doi.org/10.1109/tpami.2016.2646371","bibliography":{"title":"An End-to-End Trainable Neural Network for Image-based Sequence Recognition and Its Application to Scene Text Recognition","authors":["Baoguang Shi","Xiang Bai","Cong Yao"],"url":"https://doi.org/10.1109/tpami.2016.2646371","pdfUrl":null,"codeUrl":null,"preprint":null,"publication":{"venue":"IEEE Transactions on Pattern Analysis and Machine Intelligence","shortVenue":"IEEE TPAMI","year":2017,"kind":"journal","url":"https://doi.org/10.1109/tpami.2016.2646371"},"citation":"@article{textrecognitioncrnn2017,\n  title = {{An End-to-End Trainable Neural Network for Image-based Sequence Recognition and Its Application to Scene Text Recognition}},\n  author = {Baoguang Shi and Xiang Bai and Cong Yao},\n  year = {2017},\n  journal = {IEEE Transactions on Pattern Analysis and Machine Intelligence},\n  url = {https://doi.org/10.1109/tpami.2016.2646371},\n  doi = {10.1109/tpami.2016.2646371}\n}\n","citationPath":"/content/papers/citations/text-recognition/crnn.1b8f44a91ef1.bib"},"thumbnail":{"src":"/content/papers/assets/3eab698b0f22c3bd4a66aebe62707ef15cb44b313611f4772c224e3f9916f395.jpg","width":900,"height":1080},"locale":"zh-hans","path":"/content/papers/zh-hans/text-recognition/crnn.f23fe1096f97.md","headings":[{"id":"定义问题","text":"定义问题","depth":2},{"id":"1-定义词典","text":"1. 定义词典","depth":3},{"id":"2-字符序列编码","text":"2. 字符序列编码","depth":3},{"id":"3-n-gram-编码","text":"3. N-gram 编码","depth":3},{"id":"解决问题","text":"解决问题","depth":2},{"id":"模型架构","text":"模型架构","depth":3},{"id":"卷积网络层","text":"卷积网络层","depth":3},{"id":"循环神经网络层","text":"循环神经网络层","depth":3},{"id":"未对齐的序列标注","text":"未对齐的序列标注","depth":3},{"id":"训练策略","text":"训练策略","depth":3},{"id":"评估指针","text":"评估指针","depth":3},{"id":"讨论","text":"讨论","depth":2},{"id":"模型多方位比较","text":"模型多方位比较","depth":3},{"id":"与过去方法比较","text":"与过去方法比较","depth":3},{"id":"广义拓展","text":"广义拓展","depth":3},{"id":"结论","text":"结论","depth":2}],"anchorAliases":{},"guide":null,"relatedReading":[{"id":"text-recognition/satrn","relation":"next","topic":"从循环式文字识别到注意力"}]},{"id":"text-recognition/parseq","category":"text-recognition","legacyPath":"text-recognition/2207-parseq","legacySlug":"2207-parseq","legacyPaths":[],"title":"PARSeq","subtitle":"文字的序顺不影阅响读","author":"Z. Yuan","paperDate":"2022-07-14","publishedOn":"2024-11-11","paperTitle":"Scene Text Recognition with Permuted Autoregressive Sequence Models","paperUrl":"https://arxiv.org/abs/2207.06966","bibliography":{"title":"Scene Text Recognition with Permuted Autoregressive Sequence Models","authors":["Darwin Bautista","Rowel Atienza"],"url":"https://arxiv.org/abs/2207.06966","pdfUrl":"https://arxiv.org/pdf/2207.06966","codeUrl":null,"preprint":{"id":"2207.06966","submittedOn":"2022-07-14","url":"https://arxiv.org/abs/2207.06966"},"publication":{"venue":"ECCV","year":2022,"kind":"conference","url":"https://arxiv.org/abs/2207.06966"},"citation":"@misc{textrecognitionparseq2022,\n  title = {{Scene Text Recognition with Permuted Autoregressive Sequence Models}},\n  author = {Darwin Bautista and Rowel Atienza},\n  year = {2022},\n  eprint = {2207.06966},\n  archivePrefix = {arXiv},\n  url = {https://arxiv.org/abs/2207.06966}\n}\n","citationPath":"/content/papers/citations/text-recognition/parseq.25b72ce7d047.bib"},"thumbnail":{"src":"/content/papers/assets/4806e51ccf1023de1b23554938c1a59d93ac53a37d1525402f90f0425dadf59b.jpg","width":1224,"height":388},"locale":"zh-hans","path":"/content/papers/zh-hans/text-recognition/parseq.49ba57cc37d2.md","headings":[{"id":"定义问题","text":"定义问题","depth":2},{"id":"解决问题","text":"解决问题","depth":2},{"id":"模型架构","text":"模型架构","depth":3},{"id":"编码器设计","text":"编码器设计","depth":3},{"id":"解码器设计","text":"解码器设计","depth":3},{"id":"回顾一下","text":"回顾一下","depth":3},{"id":"排列语言建模","text":"排列语言建模","depth":3},{"id":"解码方法","text":"解码方法","depth":3},{"id":"损失函数","text":"损失函数","depth":3},{"id":"实验配置","text":"实验配置","depth":3},{"id":"讨论","text":"讨论","depth":2},{"id":"训练排列数量影响分析","text":"训练排列数量影响分析","depth":3},{"id":"与现有方法的比较","text":"与现有方法的比较","depth":3},{"id":"结论","text":"结论","depth":2}],"anchorAliases":{},"guide":null,"relatedReading":[{"id":"text-recognition/satrn","relation":"background","topic":"从循环式文字识别到注意力"}]}],"text":"Transformer 在发表后的几年间，这阵风也陆续吹进了不同的领域。\n\n这篇论文是 Clova AI 发表的，他们也想将 Transformer 的优势引入 Scene Text Recognition (STR) 领域，或许能解决一些问题。\n\n## 定义问题\n\n任意形状的文字仍困扰著广大的研究者们。\n\n虽然在过去几年间，陆续有人提出一些解决方案，但这些方法的表现仍然不够理想。特别是多数研究都还是基于文字水平排列的假设，这导致模型泛化能力有限。\n\n此时此刻，Transformer 已经发表了两年多，BERT 已经在 NLP 领域大杀四方，作者想著：或许 Transformer 的注意力机制能够帮助我们解决这个问题。\n\n\n> [!TIP]\n> \n> 这篇论文发表时，ViT 还没有问世呢！\n\n\n## 解决问题\n\n### 模型架构\n\n\n\n![模型架构](/content/papers/assets/30eedea70bdfcce81cbdde80e181f20fe6b6887ab2f147bec508540a92a678d4.jpg)\n\n\n\n作者提出了模型架构，看起来就是一个标准的 Transformer，但针对 STR 任务进行了一些改良。Transformer 的架构我们不再重复讨论了，如果你对它不熟悉，可以参考：\n\n- [**[17.06] Transformer: 新世界的起点**](/blog/papers/transformers/transformer)\n\n在编码器的部分，输入图像首先经过浅层卷积神经网络 (CNN) 提取局部图像模式与纹理，以减轻自注意力模块的计算负担。此 CNN 包含两个 $3 \\times 3$ 卷积层，每层后面各接一个步长为 2 的 $2 \\times 2$ 最大池化层。\n\n自注意力模块基于 Transformer 自注意力，并使用自适应 2D 位置编码，以处理文字的随机排列问题。\n\nFFN 的部分，作者提出了一个新的局部感知前馈层 (Locality-aware Feedforward Layer)，以增强对局部结构的关注：在原生的点对点前馈层中加入 $3 \\times 3$ 深度卷积，保留 $1 \\times 1$ 卷积来处理通道。\n\n解码器的部分，从编码器的 2D 特征图中提取文字序列。\n\n解码过程中，图像输入与文字输出的跨模态在第二个多头注意力模块中实现。解码器的结构大部分与 Transformer 解码器相同，主要使用多头注意力和点对点前馈层。\n\n\n> [!TIP]\n> \n> **自适应 2D 位置编码**\n> \n> 原文为：Adaptive 2D Positional Encoding (A2DPE)。\n> \n> 作者为了解决文字随机排列的问题，依输入图像特徵调整高、宽两个方向位置编码的权重。A2DPE 通过以下公式动态调整位置编码：\n> \n> $$\n> p_{hw} = \\alpha(E) p_{\\text{sinu}}^h + \\beta(E) p_{\\text{sinu}}^w\n> $$\n> \n> 其中 $p_{\\text{sinu}}^h$ 和 $p_{\\text{sinu}}^w$ 是正弦位置编码，$E$ 是图像特征，$ \\alpha(E) $ 和 $ \\beta(E) $ 分别由图像特征 $E$ 通过两层感知机 (perceptron) 计算，并利用 sigmoid 函数控制相对比率。\n\n\n## 讨论\n\n### 和先前方法的比较\n\n![方法比较](/content/papers/assets/5fc99e7dd10f19e0d00a352225c8e75220b848cc11401024fdf68d904b115979.jpg)\n\nSATRN 相较于表中其他 2D 特征图方法，在有报告成绩的基准测试上表现更佳。三个不规则文字测试集 IC15、SVTP、CT80，相对各栏先前最高成绩分别提升 2.1、6.9、4.5 个百分点。\n\n这个架构在处理任意形状的文字辨识上具有优势；但在一般文字的 IIIT5K 和 SVT，使用空间变换网络（STN）的 ASTER 成绩仍高于 SATRN。\n\n### 和 SAR 模型的比较\n\n\n> [!TIP]\n> \n> 之前我们看 SAR 模型的时候有提到后续的研究比较，就是这篇论文。\n> \n> - [**[18.11] SAR: 二维注意力图**](/blog/papers/text-recognition/sar)\n\n\n![SATRN 与 SAR 比较](/content/papers/assets/756aaf6db9b8ba2856e0dbba18b93e84a8a7ebe4ee9e3c1ae0891701378528d0.jpg)\n\nSATRN 与 SAR 模型在编码器（自注意力 vs 卷积网络）与解码器（自注意力 vs LSTM）上有显著区别。SAR 使用 ResNet 编码器与 LSTM 解码器，而 SATRN 采用了自注意力编码器与解码器。\n\n只将 SAR 的 ResNet 编码器换成 SATRN 编码器时，搭配 LSTM 或 SATRN 解码器，准确率分别提升 1.0 和 0.9 个百分点，且都减少了 1200 万参数和 5.5B FLOPs。完整 SATRN 相比 SAR 则是 89.2% 对 87.9%，但 FLOPs 从 21.9B 增至 35.9B。\n\n### 多行文本辨识\n\n![多行文本识别](/content/papers/assets/f4b068fc342457b5da69ecc77b25c547b6153eabb425ec3b95b1c6f6089442de.jpg)\n\n为了更具体地评估模型在不同形状扭曲下的表现，作者另外测试了旋转与多行文字。\n\n旋转文字的部分，作者使用了从 0° 到 360° 均匀分布的旋转进行训练，并将输入图像调整为 64×64 尺寸；多行文字的部分，作者使用合成文字数据集（SynthText 与 MJSynth）进行模型训练，并从 IC13 中手动裁剪出多行文字图像用于测试。\n\n在实验中，SATRN 在所有旋转角度下的表现都优于基准模型 FAN 和 SAR，并且在各种旋转角度下保持稳定的性能。在多行文字辨识上，SATRN 在推理过程中能够进行大范围跳转，从当前行转移到下一行，展现了其优异的表现。\n\n下图展示 SATRN 解码器在提取 2D 特征时的注意力图：\n\n![多行文本识别](/content/papers/assets/eaf68f8b52b2cdebb85d90e90d87384627ad3ec18a02e3f7e54839def966a4d0.jpg)\n\n### 消融研究\n\n![消融研究](/content/papers/assets/9ad54b361130e4c6536cd2a5666a5ba04660bfa62e3021dec53738888418c991.jpg)\n\n- **自适应 2D 位置编码 (A2DPE)**：相比不使用位置编码、1D 位置编码和 2D 拼接编码，A2DPE 在这组消融中准确率最高（86.5%），会依图像特徵调整高、宽位置编码的权重。\n- **特征图高度的影响**：随着特征图的尺寸缩减，运算量与准确度均下降，尤其当高度下采样率超过 1/8 时，准确度急剧下降，这强调了在计算过程中保持 2D 特征图的重要性。\n\n## 结论\n\nSATRN 验证了在 STR 任务中使用 Transformer 的有效性，并且在多项基准测试中都达到了新的最先进表现，平均提升 5.7 个百分点。\n\n虽然 SATRN 提升了准确度，但自注意力层的使用导致模型在记忆体和运算需求上有所增加，特别是解码器部分增加了显著的 FLOPs 和参数量，但这显然不是问题！\n\n后续研究可以进一步研究如何减少模型的计算量，以应用于更多的实际应用场景。\n","imageSizes":{"/content/papers/assets/30eedea70bdfcce81cbdde80e181f20fe6b6887ab2f147bec508540a92a678d4.jpg":{"width":944,"height":1080},"/content/papers/assets/5fc99e7dd10f19e0d00a352225c8e75220b848cc11401024fdf68d904b115979.jpg":{"width":1622,"height":530},"/content/papers/assets/756aaf6db9b8ba2856e0dbba18b93e84a8a7ebe4ee9e3c1ae0891701378528d0.jpg":{"width":1148,"height":360},"/content/papers/assets/f4b068fc342457b5da69ecc77b25c547b6153eabb425ec3b95b1c6f6089442de.jpg":{"width":1072,"height":284},"/content/papers/assets/eaf68f8b52b2cdebb85d90e90d87384627ad3ec18a02e3f7e54839def966a4d0.jpg":{"width":1056,"height":268},"/content/papers/assets/9ad54b361130e4c6536cd2a5666a5ba04660bfa62e3021dec53738888418c991.jpg":{"width":1044,"height":396}}}
