{"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-hant","path":"/content/papers/zh-hant/text-recognition/satrn.8f41eaebf918.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-hant","path":"/content/papers/zh-hant/text-recognition/crnn.9acace1ba8b1.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-hant","path":"/content/papers/zh-hant/text-recognition/parseq.25276933da01.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![model arch](/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![comp](/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![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![multi](/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![multi](/content/papers/assets/eaf68f8b52b2cdebb85d90e90d87384627ad3ec18a02e3f7e54839def966a4d0.jpg)\n\n### 消融研究\n\n![ablation](/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}}}
