duyongkun commited on
Commit
5de2f8f
·
1 Parent(s): 0b5fee8

update app

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitignore +39 -0
  2. .pre-commit-config.yaml +45 -0
  3. LICENSE +201 -0
  4. README.md +283 -14
  5. README_ch.md +273 -0
  6. __init__.py +11 -0
  7. app.py +117 -0
  8. configs/dataset/rec/evaluation.yaml +41 -0
  9. configs/dataset/rec/ltb.yaml +9 -0
  10. configs/dataset/rec/mjsynth.yaml +11 -0
  11. configs/dataset/rec/openvino.yaml +25 -0
  12. configs/dataset/rec/ost.yaml +17 -0
  13. configs/dataset/rec/synthtext.yaml +7 -0
  14. configs/dataset/rec/test.yaml +77 -0
  15. configs/dataset/rec/textocr.yaml +13 -0
  16. configs/dataset/rec/textocr_horizontal.yaml +13 -0
  17. configs/dataset/rec/union14m_b.yaml +47 -0
  18. configs/dataset/rec/union14m_l_filtered.yaml +35 -0
  19. configs/det/dbnet/repvit_db.yml +171 -0
  20. configs/rec/abinet/resnet45_trans_abinet_lang.yml +94 -0
  21. configs/rec/abinet/resnet45_trans_abinet_wo_lang.yml +93 -0
  22. configs/rec/abinet/svtrv2_abinet_lang.yml +130 -0
  23. configs/rec/abinet/svtrv2_abinet_wo_lang.yml +128 -0
  24. configs/rec/aster/resnet31_lstm_aster_tps_on.yml +93 -0
  25. configs/rec/aster/svtrv2_aster.yml +127 -0
  26. configs/rec/aster/svtrv2_aster_tps_on.yml +102 -0
  27. configs/rec/autostr/autostr_lstm_aster_tps_on.yml +95 -0
  28. configs/rec/busnet/svtrv2_busnet.yml +135 -0
  29. configs/rec/busnet/svtrv2_busnet_pretraining.yml +134 -0
  30. configs/rec/busnet/vit_busnet.yml +104 -0
  31. configs/rec/busnet/vit_busnet_pretraining.yml +104 -0
  32. configs/rec/cam/convnextv2_cam_tps_on.yml +118 -0
  33. configs/rec/cam/convnextv2_tiny_cam_tps_on.yml +118 -0
  34. configs/rec/cam/svtrv2_cam_tps_on.yml +123 -0
  35. configs/rec/cdistnet/resnet45_trans_cdistnet.yml +93 -0
  36. configs/rec/cdistnet/svtrv2_cdistnet.yml +139 -0
  37. configs/rec/cppd/svtr_base_cppd.yml +123 -0
  38. configs/rec/cppd/svtr_base_cppd_ch.yml +126 -0
  39. configs/rec/cppd/svtr_base_cppd_h8.yml +123 -0
  40. configs/rec/cppd/svtr_base_cppd_syn.yml +124 -0
  41. configs/rec/cppd/svtrv2_cppd.yml +150 -0
  42. configs/rec/dan/resnet45_fpn_dan.yml +98 -0
  43. configs/rec/dan/svtrv2_dan.yml +130 -0
  44. configs/rec/dptr/dptr_parseq_pretrain.yml +88 -0
  45. configs/rec/focalsvtr/focalsvtr_ctc.yml +137 -0
  46. configs/rec/gtc/svtrv2_lnconv_nrtr_gtc.yml +168 -0
  47. configs/rec/gtc/svtrv2_lnconv_smtr_gtc_long_infer.yml +151 -0
  48. configs/rec/gtc/svtrv2_lnconv_smtr_gtc_smtr_long.yml +150 -0
  49. configs/rec/gtc/svtrv2_lnconv_smtr_gtc_stream.yml +152 -0
  50. configs/rec/igtr/readme.md +192 -0
.gitignore ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ .ipynb_checkpoints/
4
+ *.py[cod]
5
+ *$py.class
6
+
7
+ # C extensions
8
+ *.so
9
+
10
+ inference/
11
+ inference_results/
12
+ output/
13
+ e2e_results/
14
+ rec_results/
15
+ det_results/
16
+ train_data/
17
+ log/
18
+ *.DS_Store
19
+ *.vs
20
+ *.user
21
+ *~
22
+ *.vscode
23
+ *.idea
24
+
25
+ *.log
26
+ .clang-format
27
+ .clang_format.hook
28
+
29
+ build/
30
+ dist/
31
+ paddleocr.egg-info/
32
+ /deploy/android_demo/app/OpenCV/
33
+ /deploy/android_demo/app/PaddleLite/
34
+ /deploy/android_demo/app/.cxx/
35
+ /deploy/android_demo/app/cache/
36
+ test_tipc/web/models/
37
+ test_tipc/web/node_modules/
38
+ ppocr/
39
+ .idea/
.pre-commit-config.yaml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ exclude: ^tools/utils/
2
+ repos:
3
+ - repo: https://github.com/PyCQA/flake8
4
+ rev: 5.0.4
5
+ hooks:
6
+ - id: flake8
7
+ args: ["--max-line-length=150", "--ignore=E303,E731,W191,W504,E402,E722,E501,E203,E741,E265,E262,E126", "--exclude=__init__.py"]
8
+ - repo: https://github.com/pre-commit/mirrors-yapf
9
+ rev: v0.32.0
10
+ hooks:
11
+ - id: yapf
12
+ - repo: https://github.com/pre-commit/pre-commit-hooks
13
+ rev: v4.3.0
14
+ hooks:
15
+ - id: trailing-whitespace
16
+ exclude: |
17
+ (?x)^(
18
+ dicts/|
19
+ projects/.*?/dicts/
20
+ )
21
+ - id: check-yaml
22
+ - id: end-of-file-fixer
23
+ exclude: |
24
+ (?x)^(
25
+ dicts/|
26
+ projects/.*?/dicts/
27
+ )
28
+ - id: requirements-txt-fixer
29
+ - id: double-quote-string-fixer
30
+ - id: check-merge-conflict
31
+ - id: fix-encoding-pragma
32
+ args: ["--remove"]
33
+ - id: mixed-line-ending
34
+ args: ["--fix=lf"]
35
+ - id: mixed-line-ending
36
+ args: ["--fix=lf"]
37
+ - repo: https://github.com/executablebooks/mdformat
38
+ rev: 0.7.9
39
+ hooks:
40
+ - id: mdformat
41
+ args: ["--number", "--table-width", "200"]
42
+ additional_dependencies:
43
+ - mdformat-openmmlab
44
+ - mdformat_frontmatter
45
+ - linkify-it-py
LICENSE ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
README.md CHANGED
@@ -1,14 +1,283 @@
1
- ---
2
- title: OpenOCR UniRec Demo
3
- emoji: 🏢
4
- colorFrom: red
5
- colorTo: pink
6
- sdk: gradio
7
- sdk_version: 6.0.1
8
- app_file: app.py
9
- pinned: false
10
- license: apache-2.0
11
- short_description: Unified Text and Formula Recognition with 0.1B Parameters
12
- ---
13
-
14
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div align="center">
2
+
3
+ <h1> OpenOCR: A general OCR system with accuracy and efficiency </h1>
4
+
5
+ <h5 align="center"> If you find this project useful, please give us a star🌟. </h5>
6
+
7
+ <a href="https://github.com/Topdu/OpenOCR/blob/main/LICENSE"><img alt="license" src="https://img.shields.io/github/license/Topdu/OpenOCR"></a>
8
+ <a href='https://arxiv.org/abs/2411.15858'><img src='https://img.shields.io/badge/Paper-Arxiv-red'></a>
9
+ <a href="https://huggingface.co/spaces/topdu/OpenOCR-Demo" target="_blank"><img src="https://img.shields.io/badge/%F0%9F%A4%97-Hugging Face Demo-blue"></a>
10
+ <a href="https://modelscope.cn/studios/topdktu/OpenOCR-Demo" target="_blank"><img src="https://img.shields.io/badge/魔搭-Demo-blue"></a>
11
+ <a href=""><img src="https://img.shields.io/badge/OS-Linux%2C%20Win%2C%20Mac-pink.svg"></a>
12
+ <a href="https://github.com/Topdu/OpenOCR/graphs/contributors"><img src="https://img.shields.io/github/contributors/Topdu/OpenOCR?color=9ea"></a>
13
+ <a href="https://pepy.tech/project/openocr"><img src="https://static.pepy.tech/personalized-badge/openocr?period=total&units=abbreviation&left_color=grey&right_color=blue&left_text=Clone%20downloads"></a>
14
+ <a href="https://github.com/Topdu/OpenOCR/stargazers"><img src="https://img.shields.io/github/stars/Topdu/OpenOCR?color=ccf"></a>
15
+ <a href="https://pypi.org/project/openocr-python/"><img alt="PyPI" src="https://img.shields.io/pypi/v/openocr-python"><img src="https://img.shields.io/pypi/dm/openocr-python?label=PyPI%20downloads"></a>
16
+
17
+ <a href="#quick-start"> 🚀 Quick Start </a> | English | [简体中文](./README_ch.md)
18
+
19
+ </div>
20
+
21
+ ______________________________________________________________________
22
+
23
+ We aim to establish a unified benchmark for training and evaluating models in scene text detection and recognition. Building on this benchmark, we introduce a general OCR system with accuracy and efficiency, **OpenOCR**. This repository also serves as the official codebase of the OCR team from the [FVL Laboratory](https://fvl.fudan.edu.cn), Fudan University.
24
+
25
+ We sincerely welcome the researcher to recommend OCR or relevant algorithms and point out any potential factual errors or bugs. Upon receiving the suggestions, we will promptly evaluate and critically reproduce them. We look forward to collaborating with you to advance the development of OpenOCR and continuously contribute to the OCR community!
26
+
27
+ ## Features
28
+
29
+ - 🔥**UniRec: Unified Text and Formula Recognition Across Granularities**
30
+
31
+ - ⚡\[[Doc](./docs/unirec.md)\] \[[Model](https://huggingface.co/topdu/unirec_100m)\] \[[ModelScope Demo](https://www.modelscope.cn/studios/topdktu/OpenOCR-UniRec-Demo)\] \[[Hugging Face Demo](https://huggingface.co/spaces/topdu/OpenOCR-UniRec-Demo)\] \[[Local Demo](./docs/unirec.md#local-demo)\] \[Paper coming soon\]
32
+ - Recognizing plain text (words, lines, paragraphs), formulas (single-line, multi-line), and mixed text-and-formulas content.
33
+ - 0.1B parameters.
34
+ - Trained from scratch on 50M data without pre-training.
35
+
36
+ - 🔥**OpenOCR: A general OCR system with accuracy and efficiency**
37
+
38
+ - ⚡\[[Quick Start](#quick-start)\] \[[Model](https://github.com/Topdu/OpenOCR/releases/tag/develop0.0.1)\] \[[ModelScope Demo](https://modelscope.cn/studios/topdktu/OpenOCR-Demo)\] \[[Hugging Face Demo](https://huggingface.co/spaces/topdu/OpenOCR-Demo)\] \[[Local Demo](#local-demo)\] \[[PaddleOCR Implementation](https://paddlepaddle.github.io/PaddleOCR/latest/algorithm/text_recognition/algorithm_rec_svtrv2.html)\]
39
+ - [Introduction](./docs/openocr.md)
40
+ - A practical OCR system building on SVTRv2.
41
+ - Outperforms [PP-OCRv4](https://paddlepaddle.github.io/PaddleOCR/latest/ppocr/model_list.html) baseline by 4.5% on the [OCR competition leaderboard](https://aistudio.baidu.com/competition/detail/1131/0/leaderboard) in terms of accuracy, while preserving quite similar inference speed.
42
+ - [x] Supports Chinese and English text detection and recognition.
43
+ - [x] Provides server model and mobile model.
44
+ - [x] Fine-tunes OpenOCR on a custom dataset: [Fine-tuning Det](./docs/finetune_det.md), [Fine-tuning Rec](./docs/finetune_rec.md).
45
+ - [x] [ONNX model export for wider compatibility](#export-onnx-model).
46
+
47
+ - 🔥**SVTRv2: CTC Beats Encoder-Decoder Models in Scene Text Recognition (ICCV 2025)**
48
+
49
+ - \[[Paper](https://arxiv.org/abs/2411.15858)\] \[[Doc](./configs/rec/svtrv2/)\] \[[Model](./configs/rec/svtrv2/readme.md#11-models-and-results)\] \[[Datasets](./docs/svtrv2.md#downloading-datasets)\] \[[Config, Training and Inference](./configs/rec/svtrv2/readme.md#3-model-training--evaluation)\] \[[Benchmark](./docs/svtrv2.md#results-benchmark--configs--checkpoints)\]
50
+ - [Introduction](./docs/svtrv2.md)
51
+ - A unified training and evaluation benchmark (on top of [Union14M](https://github.com/Mountchicken/Union14M?tab=readme-ov-file#3-union14m-dataset)) for Scene Text Recognition
52
+ - Supports 24 Scene Text Recognition methods trained from scratch on the large-scale real dataset [Union14M-L-Filter](./docs/svtrv2.md#dataset-details), and will continue to add the latest methods.
53
+ - Improves accuracy by 20-30% compared to models trained based on synthetic datasets.
54
+ - Towards Arbitrary-Shaped Text Recognition and Language modeling with a Single Visual Model.
55
+ - Surpasses Attention-based Encoder-Decoder Methods across challenging scenarios in terms of accuracy and speed
56
+ - [Get Started](./docs/svtrv2.md#get-started-with-training-a-sota-scene-text-recognition-model-from-scratch) with training a SOTA Scene Text Recognition model from scratch.
57
+
58
+ ## Ours STR algorithms
59
+
60
+ - [**SVTRv2**](./configs/rec/svtrv2) (*Yongkun Du, Zhineng Chen\*, Hongtao Xie, Caiyan Jia, Yu-Gang Jiang. SVTRv2: CTC Beats Encoder-Decoder Models in Scene Text Recognition,* ICCV 2025. [Doc](./configs/rec/svtrv2/), [Paper](https://arxiv.org/abs/2411.15858))
61
+ - [**IGTR**](./configs/rec/igtr/) (*Yongkun Du, Zhineng Chen\*, Yuchen Su, Caiyan Jia, Yu-Gang Jiang. Instruction-Guided Scene Text Recognition,* TPAMI 2025. [Doc](./configs/rec/igtr), [Paper](https://ieeexplore.ieee.org/document/10820836))
62
+ - [**CPPD**](./configs/rec/cppd/) (*Yongkun Du, Zhineng Chen\*, Caiyan Jia, Xiaoting Yin, Chenxia Li, Yuning Du, Yu-Gang Jiang. Context Perception Parallel Decoder for Scene Text Recognition,* TPAMI 2025. [PaddleOCR Doc](https://github.com/PaddlePaddle/PaddleOCR/blob/main/docs/algorithm/text_recognition/algorithm_rec_cppd.en.md), [Paper](https://ieeexplore.ieee.org/document/10902187))
63
+ - [**SMTR&FocalSVTR**](./configs/rec/smtr/) (*Yongkun Du, Zhineng Chen\*, Caiyan Jia, Xieping Gao, Yu-Gang Jiang. Out of Length Text Recognition with Sub-String Matching,* AAAI 2025. [Doc](./configs/rec/smtr/), [Paper](https://ojs.aaai.org/index.php/AAAI/article/view/32285))
64
+ - [**DPTR**](./configs/rec/dptr/) (*Shuai Zhao, Yongkun Du, Zhineng Chen\*, Yu-Gang Jiang. Decoder Pre-Training with only Text for Scene Text Recognition,* ACM MM 2024. [Paper](https://dl.acm.org/doi/10.1145/3664647.3681390))
65
+ - [**CDistNet**](./configs/rec/cdistnet/) (*Tianlun Zheng, Zhineng Chen\*, Shancheng Fang, Hongtao Xie, Yu-Gang Jiang. CDistNet: Perceiving Multi-Domain Character Distance for Robust Text Recognition,* IJCV 2024. [Paper](https://link.springer.com/article/10.1007/s11263-023-01880-0))
66
+ - **MRN** (*Tianlun Zheng, Zhineng Chen\*, Bingchen Huang, Wei Zhang, Yu-Gang Jiang. MRN: Multiplexed Routing Network for Incremental Multilingual Text Recognition,* ICCV 2023. [Paper](https://openaccess.thecvf.com/content/ICCV2023/html/Zheng_MRN_Multiplexed_Routing_Network_for_Incremental_Multilingual_Text_Recognition_ICCV_2023_paper.html), [Code](https://github.com/simplify23/MRN))
67
+ - **TPS++** (*Tianlun Zheng, Zhineng Chen\*, Jinfeng Bai, Hongtao Xie, Yu-Gang Jiang. TPS++: Attention-Enhanced Thin-Plate Spline for Scene Text Recognition,* IJCAI 2023. [Paper](https://arxiv.org/abs/2305.05322), [Code](https://github.com/simplify23/TPS_PP))
68
+ - [**SVTR**](./configs/rec/svtr/) (*Yongkun Du, Zhineng Chen\*, Caiyan Jia, Xiaoting Yin, Tianlun Zheng, Chenxia Li, Yuning Du, Yu-Gang Jiang. SVTR: Scene Text Recognition with a Single Visual Model,* IJCAI 2022 (Long). [PaddleOCR Doc](https://github.com/Topdu/PaddleOCR/blob/main/doc/doc_ch/algorithm_rec_svtr.md), [Paper](https://www.ijcai.org/proceedings/2022/124))
69
+ - [**NRTR**](./configs/rec/nrtr/) (*Fenfen Sheng, Zhineng Chen, Bo Xu. NRTR: A No-Recurrence Sequence-to-Sequence Model For Scene Text Recognition,* ICDAR 2019. [Paper](https://arxiv.org/abs/1806.00926))
70
+
71
+ ## Recent Updates
72
+
73
+ - **2025.07.10**: Our paper [SVTRv2](https://arxiv.org/abs/2411.15858) is accepted by ICCV 2025. Accessible in [Doc](./configs/rec/svtrv2/).
74
+
75
+ - **2025.03.24**: 🔥 Releasing the feature of fine-tuning OpenOCR on a custom dataset: [Fine-tuning Det](./docs/finetune_det.md), [Fine-tuning Rec](./docs/finetune_rec.md)
76
+
77
+ - **2025.03.23**: 🔥 Releasing the feature of [ONNX model export for wider compatibility](#export-onnx-model).
78
+
79
+ - **2025.02.22**: Our paper [CPPD](https://ieeexplore.ieee.org/document/10902187) is accepted by TPAMI. Accessible in [Doc](./configs/rec/cppd/) and [PaddleOCR Doc](https://github.com/PaddlePaddle/PaddleOCR/blob/main/docs/algorithm/text_recognition/algorithm_rec_cppd.en.md).
80
+
81
+ - **2024.12.31**: Our paper [IGTR](https://ieeexplore.ieee.org/document/10820836) is accepted by TPAMI. Accessible in [Doc](./configs/rec/igtr/).
82
+
83
+ - **2024.12.16**: Our paper [SMTR](https://ojs.aaai.org/index.php/AAAI/article/view/32285) is accepted by AAAI 2025. Accessible in [Doc](./configs/rec/smtr/).
84
+
85
+ - **2024.12.03**: The pre-training code for [DPTR](https://dl.acm.org/doi/10.1145/3664647.3681390) is merged.
86
+
87
+ - **🔥 2024.11.23 release notes**:
88
+
89
+ - **OpenOCR: A general OCR system with accuracy and efficiency**
90
+ - ⚡\[[Quick Start](#quick-start)\] \[[Model](https://github.com/Topdu/OpenOCR/releases/tag/develop0.0.1)\] \[[ModelScope Demo](https://modelscope.cn/studios/topdktu/OpenOCR-Demo)\] \[[Hugging Face Demo](https://huggingface.co/spaces/topdu/OpenOCR-Demo)\] \[[Local Demo](#local-demo)\] \[[PaddleOCR Implementation](https://paddlepaddle.github.io/PaddleOCR/latest/algorithm/text_recognition/algorithm_rec_svtrv2.html)\]
91
+ - [Introduction](./docs/openocr.md)
92
+ - **SVTRv2: CTC Beats Encoder-Decoder Models in Scene Text Recognition**
93
+ - \[[Paper](https://arxiv.org/abs/2411.15858)\] \[[Doc](./configs/rec/svtrv2/)\] \[[Model](./configs/rec/svtrv2/readme.md#11-models-and-results)\] \[[Datasets](./docs/svtrv2.md#downloading-datasets)\] \[[Config, Training and Inference](./configs/rec/svtrv2/readme.md#3-model-training--evaluation)\] \[[Benchmark](./docs/svtrv2.md#results--configs--checkpoints)\]
94
+ - [Introduction](./docs/svtrv2.md)
95
+ - [Get Started](./docs/svtrv2.md#get-started-with-training-a-sota-scene-text-recognition-model-from-scratch) with training a SOTA Scene Text Recognition model from scratch.
96
+
97
+ ## Quick Start
98
+
99
+ **Note**: OpenOCR supports inference using both the ONNX and Torch frameworks, with the dependency environments for the two frameworks being isolated. When using ONNX for inference, there is no need to install Torch, and vice versa.
100
+
101
+ ### 1. ONNX Inference
102
+
103
+ #### Install OpenOCR and Dependencies:
104
+
105
+ ```shell
106
+ pip install openocr-python
107
+ pip install onnxruntime
108
+ ```
109
+
110
+ #### Usage:
111
+
112
+ ```python
113
+ from openocr import OpenOCR
114
+ onnx_engine = OpenOCR(backend='onnx', device='cpu')
115
+ img_path = '/path/img_path or /path/img_file'
116
+ result, elapse = onnx_engine(img_path)
117
+ ```
118
+
119
+ ### 2. Pytorch inference
120
+
121
+ #### Dependencies:
122
+
123
+ - [PyTorch](http://pytorch.org/) version >= 1.13.0
124
+ - Python version >= 3.7
125
+
126
+ ```shell
127
+ conda create -n openocr python==3.8
128
+ conda activate openocr
129
+ # install gpu version torch
130
+ conda install pytorch==2.2.0 torchvision==0.17.0 torchaudio==2.2.0 pytorch-cuda=11.8 -c pytorch -c nvidia
131
+ # or cpu version
132
+ conda install pytorch torchvision torchaudio cpuonly -c pytorch
133
+ ```
134
+
135
+ After installing dependencies, the following two installation methods are available. Either one can be chosen.
136
+
137
+ #### 2.1. Python Modules
138
+
139
+ **Install OpenOCR**:
140
+
141
+ ```shell
142
+ pip install openocr-python
143
+ ```
144
+
145
+ **Usage**:
146
+
147
+ ```python
148
+ from openocr import OpenOCR
149
+ engine = OpenOCR()
150
+ img_path = '/path/img_path or /path/img_file'
151
+ result, elapse = engine(img_path)
152
+
153
+ # Server mode
154
+ # engine = OpenOCR(mode='server')
155
+ ```
156
+
157
+ #### 2.2. Clone this repository:
158
+
159
+ ```shell
160
+ git clone https://github.com/Topdu/OpenOCR.git
161
+ cd OpenOCR
162
+ pip install -r requirements.txt
163
+ wget https://github.com/Topdu/OpenOCR/releases/download/develop0.0.1/openocr_det_repvit_ch.pth
164
+ wget https://github.com/Topdu/OpenOCR/releases/download/develop0.0.1/openocr_repsvtr_ch.pth
165
+ # Rec Server model
166
+ # wget https://github.com/Topdu/OpenOCR/releases/download/develop0.0.1/openocr_svtrv2_ch.pth
167
+ ```
168
+
169
+ **Usage**:
170
+
171
+ ```shell
172
+ # OpenOCR system: Det + Rec model
173
+ python tools/infer_e2e.py --img_path=/path/img_fold or /path/img_file
174
+ # Det model
175
+ python tools/infer_det.py --c ./configs/det/dbnet/repvit_db.yml --o Global.infer_img=/path/img_fold or /path/img_file
176
+ # Rec model
177
+ python tools/infer_rec.py --c ./configs/rec/svtrv2/repsvtr_ch.yml --o Global.infer_img=/path/img_fold or /path/img_file
178
+ ```
179
+
180
+ ##### Export ONNX model
181
+
182
+ ```shell
183
+ pip install onnx
184
+ python tools/toonnx.py --c configs/rec/svtrv2/repsvtr_ch.yml --o Global.device=cpu
185
+ python tools/toonnx.py --c configs/det/dbnet/repvit_db.yml --o Global.device=cpu
186
+ ```
187
+
188
+ ##### Inference with ONNXRuntime
189
+
190
+ ```shell
191
+ pip install onnxruntime
192
+ # OpenOCR system: Det + Rec model
193
+ python tools/infer_e2e.py --img_path=/path/img_fold or /path/img_file --backend=onnx --device=cpu
194
+ # Det model
195
+ python tools/infer_det.py --c ./configs/det/dbnet/repvit_db.yml --o Global.backend=onnx Global.device=cpu Global.infer_img=/path/img_fold or /path/img_file
196
+ # Rec model
197
+ python tools/infer_rec.py --c ./configs/rec/svtrv2/repsvtr_ch.yml --o Global.backend=onnx Global.device=cpu Global.infer_img=/path/img_fold or /path/img_file
198
+ ```
199
+
200
+ #### Local Demo
201
+
202
+ ```shell
203
+ pip install gradio==4.20.0
204
+ wget https://github.com/Topdu/OpenOCR/releases/download/develop0.0.1/OCR_e2e_img.tar
205
+ tar xf OCR_e2e_img.tar
206
+ # start demo
207
+ python demo_gradio.py
208
+ ```
209
+
210
+ ## Reproduction schedule:
211
+
212
+ ### Scene Text Recognition
213
+
214
+ | Method | Venue | Training | Evaluation | Contributor |
215
+ | --------------------------------------------- | ---------------------------------------------------------------------------------------------- | -------- | ---------- | ------------------------------------------- |
216
+ | [CRNN](./configs/rec/svtrs/) | [TPAMI 2016](https://arxiv.org/abs/1507.05717) | ✅ | ✅ | |
217
+ | [ASTER](./configs/rec/aster/) | [TPAMI 2019](https://ieeexplore.ieee.org/document/8395027) | ✅ | ✅ | [pretto0](https://github.com/pretto0) |
218
+ | [NRTR](./configs/rec/nrtr/) | [ICDAR 2019](https://arxiv.org/abs/1806.00926) | ✅ | ✅ | |
219
+ | [SAR](./configs/rec/sar/) | [AAAI 2019](https://aaai.org/papers/08610-show-attend-and-read-a-simple-and-strong-baseline-for-irregular-text-recognition/) | ✅ | ✅ | [pretto0](https://github.com/pretto0) |
220
+ | [MORAN](./configs/rec/moran/) | [PR 2019](https://www.sciencedirect.com/science/article/abs/pii/S0031320319300263) | ✅ | ✅ | |
221
+ | [DAN](./configs/rec/dan/) | [AAAI 2020](https://arxiv.org/pdf/1912.10205) | ✅ | ✅ | |
222
+ | [RobustScanner](./configs/rec/robustscanner/) | [ECCV 2020](https://www.ecva.net/papers/eccv_2020/papers_ECCV/html/3160_ECCV_2020_paper.php) | ✅ | ✅ | [pretto0](https://github.com/pretto0) |
223
+ | [AutoSTR](./configs/rec/autostr/) | [ECCV 2020](https://www.ecva.net/papers/eccv_2020/papers_ECCV/papers/123690732.pdf) | ✅ | ✅ | |
224
+ | [SRN](./configs/rec/srn/) | [CVPR 2020](https://openaccess.thecvf.com/content_CVPR_2020/html/Yu_Towards_Accurate_Scene_Text_Recognition_With_Semantic_Reasoning_Networks_CVPR_2020_paper.html) | ✅ | ✅ | [pretto0](https://github.com/pretto0) |
225
+ | [SEED](./configs/rec/seed/) | [CVPR 2020](https://openaccess.thecvf.com/content_CVPR_2020/html/Qiao_SEED_Semantics_Enhanced_Encoder-Decoder_Framework_for_Scene_Text_Recognition_CVPR_2020_paper.html) | ✅ | ✅ | |
226
+ | [ABINet](./configs/rec/abinet/) | [CVPR 2021](https://openaccess.thecvf.com//content/CVPR2021/html/Fang_Read_Like_Humans_Autonomous_Bidirectional_and_Iterative_Language_Modeling_for_CVPR_2021_paper.html) | ✅ | ✅ | [YesianRohn](https://github.com/YesianRohn) |
227
+ | [VisionLAN](./configs/rec/visionlan/) | [ICCV 2021](https://openaccess.thecvf.com/content/ICCV2021/html/Wang_From_Two_to_One_A_New_Scene_Text_Recognizer_With_ICCV_2021_paper.html) | ✅ | ✅ | [YesianRohn](https://github.com/YesianRohn) |
228
+ | PIMNet | [ACM MM 2021](https://dl.acm.org/doi/10.1145/3474085.3475238) | | | TODO |
229
+ | [SVTR](./configs/rec/svtrs/) | [IJCAI 2022](https://www.ijcai.org/proceedings/2022/124) | ✅ | ✅ | |
230
+ | [PARSeq](./configs/rec/parseq/) | [ECCV 2022](https://www.ecva.net/papers/eccv_2022/papers_ECCV/papers/136880177.pdf) | ✅ | ✅ | |
231
+ | [MATRN](./configs/rec/matrn/) | [ECCV 2022](https://www.ecva.net/papers/eccv_2022/papers_ECCV/papers/136880442.pdf) | ✅ | ✅ | |
232
+ | [MGP-STR](./configs/rec/mgpstr/) | [ECCV 2022](https://www.ecva.net/papers/eccv_2022/papers_ECCV/papers/136880336.pdf) | ✅ | ✅ | |
233
+ | [LPV](./configs/rec/lpv/) | [IJCAI 2023](https://www.ijcai.org/proceedings/2023/0189.pdf) | ✅ | ✅ | |
234
+ | [MAERec](./configs/rec/maerec/)(Union14M) | [ICCV 2023](https://openaccess.thecvf.com/content/ICCV2023/papers/Jiang_Revisiting_Scene_Text_Recognition_A_Data_Perspective_ICCV_2023_paper.pdf) | ✅ | ✅ | |
235
+ | [LISTER](./configs/rec/lister/) | [ICCV 2023](https://openaccess.thecvf.com/content/ICCV2023/papers/Cheng_LISTER_Neighbor_Decoding_for_Length-Insensitive_Scene_Text_Recognition_ICCV_2023_paper.pdf) | ✅ | ✅ | |
236
+ | [CDistNet](./configs/rec/cdistnet/) | [IJCV 2024](https://link.springer.com/article/10.1007/s11263-023-01880-0) | ✅ | ✅ | [YesianRohn](https://github.com/YesianRohn) |
237
+ | [BUSNet](./configs/rec/busnet/) | [AAAI 2024](https://ojs.aaai.org/index.php/AAAI/article/view/28402) | ✅ | ✅ | |
238
+ | DCTC | [AAAI 2024](https://ojs.aaai.org/index.php/AAAI/article/view/28575) | | | TODO |
239
+ | [CAM](./configs/rec/cam/) | [PR 2024](https://arxiv.org/abs/2402.13643) | ✅ | ✅ | |
240
+ | [OTE](./configs/rec/ote/) | [CVPR 2024](https://openaccess.thecvf.com/content/CVPR2024/html/Xu_OTE_Exploring_Accurate_Scene_Text_Recognition_Using_One_Token_CVPR_2024_paper.html) | ✅ | ✅ | |
241
+ | CFF | [IJCAI 2024](https://arxiv.org/abs/2407.05562) | | | TODO |
242
+ | [DPTR](./configs/rec/dptr/) | [ACM MM 2024](https://dl.acm.org/doi/10.1145/3664647.3681390) | | | [fd-zs](https://github.com/fd-zs) |
243
+ | VIPTR | [ACM CIKM 2024](https://arxiv.org/abs/2401.10110) | | | TODO |
244
+ | [IGTR](./configs/rec/igtr/) | [TPAMI 2025](https://ieeexplore.ieee.org/document/10820836) | ✅ | ✅ | |
245
+ | [SMTR](./configs/rec/smtr/) | [AAAI 2025](https://ojs.aaai.org/index.php/AAAI/article/view/32285) | ✅ | ✅ | |
246
+ | [CPPD](./configs/rec/cppd/) | [TPAMI 2025](https://ieeexplore.ieee.org/document/10902187) | ✅ | ✅ | |
247
+ | [FocalSVTR-CTC](./configs/rec/svtrs/) | [AAAI 2025](https://ojs.aaai.org/index.php/AAAI/article/view/32285) | ✅ | ✅ | |
248
+ | [SVTRv2](./configs/rec/svtrv2/) | [ICCV 2025](https://arxiv.org/abs/2411.15858) | ✅ | ✅ | |
249
+ | [ResNet+Trans-CTC](./configs/rec/svtrs/) | | ✅ | ✅ | |
250
+ | [ViT-CTC](./configs/rec/svtrs/) | | ✅ | ✅ | |
251
+
252
+ #### Contributors
253
+
254
+ ______________________________________________________________________
255
+
256
+ Yiming Lei ([pretto0](https://github.com/pretto0)), Xingsong Ye ([YesianRohn](https://github.com/YesianRohn)), and Shuai Zhao ([fd-zs](https://github.com/fd-zs)) from the [FVL Laboratory](https://fvl.fudan.edu.cn), Fudan University, with guidance from Dr. Zhineng Chen ([Homepage](https://zhinchenfd.github.io/)), completed the majority work of the algorithm reproduction. Grateful for their outstanding contributions.
257
+
258
+ ### Scene Text Detection (STD)
259
+
260
+ TODO
261
+
262
+ ### Text Spotting
263
+
264
+ TODO
265
+
266
+ ______________________________________________________________________
267
+
268
+ ## Citation
269
+
270
+ If you find our method useful for your reserach, please cite:
271
+
272
+ ```bibtex
273
+ @inproceedings{Du2024SVTRv2,
274
+ title={SVTRv2: CTC Beats Encoder-Decoder Models in Scene Text Recognition},
275
+ author={Yongkun Du and Zhineng Chen and Hongtao Xie and Caiyan Jia and Yu-Gang Jiang},
276
+ booktitle={ICCV},
277
+ year={2025}
278
+ }
279
+ ```
280
+
281
+ # Acknowledgement
282
+
283
+ This codebase is built based on the [PaddleOCR](https://github.com/PaddlePaddle/PaddleOCR), [PytorchOCR](https://github.com/WenmuZhou/PytorchOCR), and [MMOCR](https://github.com/open-mmlab/mmocr). Thanks for their awesome work!
README_ch.md ADDED
@@ -0,0 +1,273 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div align="center">
2
+
3
+ <h1> OpenOCR: A general OCR system with accuracy and efficiency </h1>
4
+
5
+ <h5 align="center"> 如果您觉得本项目有帮助,请为我们点亮Star🌟 </h5>
6
+
7
+ <a href="https://github.com/Topdu/OpenOCR/blob/main/LICENSE"><img alt="license" src="https://img.shields.io/github/license/Topdu/OpenOCR"></a>
8
+ <a href='https://arxiv.org/abs/2411.15858'><img src='https://img.shields.io/badge/论文-Arxiv-red'></a>
9
+ <a href="https://huggingface.co/spaces/topdu/OpenOCR-Demo" target="_blank"><img src="https://img.shields.io/badge/%F0%9F%A4%97-Hugging Face Demo-blue"></a>
10
+ <a href="https://modelscope.cn/studios/topdktu/OpenOCR-Demo" target="_blank"><img src="https://img.shields.io/badge/魔搭-Demo-blue"></a>
11
+ <a href=""><img src="https://img.shields.io/badge/OS-Linux%2C%20Win%2C%20Mac-pink.svg"></a>
12
+ <a href="https://github.com/Topdu/OpenOCR/graphs/contributors"><img src="https://img.shields.io/github/contributors/Topdu/OpenOCR?color=9ea"></a>
13
+ <a href="https://pepy.tech/project/openocr"><img src="https://static.pepy.tech/personalized-badge/openocr?period=total&units=abbreviation&left_color=grey&right_color=blue&left_text=Clone%20下载量"></a>
14
+ <a href="https://github.com/Topdu/OpenOCR/stargazers"><img src="https://img.shields.io/github/stars/Topdu/OpenOCR?color=ccf"></a>
15
+ <a href="https://pypi.org/project/openocr-python/"><img alt="PyPI" src="https://img.shields.io/pypi/v/openocr-python"><img src="https://img.shields.io/pypi/dm/openocr-python?label=PyPI%20下载量"></a>
16
+
17
+ <a href="#快速开始"> 🚀 快速开始 </a> | 简体中文 | [English](./README.md)
18
+
19
+ </div>
20
+
21
+ ______________________________________________________________________
22
+
23
+ 我们致力于构建场景文本检测与识别模型的统一训练评估基准。基于此基准,我们推出了兼顾精度与效率的通用OCR系统——**OpenOCR**。本仓库同时作为复旦大学[FVL实验室](https://fvl.fudan.edu.cn)OCR团队的官方代码库。
24
+
25
+ 我们诚挚欢迎研究者推荐OCR相关算法,并指出潜在的事实性错误或代码缺陷。收到建议后,我们将及时评估并严谨复现。期待与您携手推进OpenOCR发展,持续为OCR社区贡献力量!
26
+
27
+ ## 核心特性
28
+
29
+ - 🔥**UniRec: Unified Text and Formula Recognition Across Granularities**
30
+
31
+ - ⚡\[[使用文档](./docs/unirec.md)\] \[[模型下载](https://huggingface.co/topdu/unirec_100m)\] \[[ModelScope Demo](https://www.modelscope.cn/studios/topdktu/OpenOCR-UniRec-Demo)\] \[[Hugging Face Demo](https://huggingface.co/spaces/topdu/OpenOCR-UniRec-Demo)\] \[[本地Demo](./docs/unirec.md#local-demo)\] \[论文coming soon\]
32
+ - 识别纯文本(单词、行、段落)、公式(单行、多行)、以及文本与公式混合的内容
33
+ - 0.1B 参数量
34
+ - 在 5000 万数据上从零开始训练,不使用任何预训练
35
+
36
+ - 🔥**OpenOCR: A general OCR system with accuracy and efficiency**
37
+
38
+ - ⚡\[[快速开始](#快速开始)\] \[[模型下载](https://github.com/Topdu/OpenOCR/releases/tag/develop0.0.1)\] \[[ModelScope Demo](https://modelscope.cn/studios/topdktu/OpenOCR-Demo)\] \[[Hugging Face Demo](https://huggingface.co/spaces/topdu/OpenOCR-Demo)\] \[[本地Demo](#本地Demo)\] \[[PaddleOCR实现](https://paddlepaddle.github.io/PaddleOCR/latest/algorithm/text_recognition/algorithm_rec_svtrv2.html)\]
39
+ - [技术文档](./docs/openocr.md)
40
+ - 基于SVTRv2构建的实用OCR系统
41
+ - 在[OCR竞赛榜单](https://aistudio.baidu.com/competition/detail/1131/0/leaderboard)上,精度超越[PP-OCRv4](https://paddlepaddle.github.io/PaddleOCR/latest/ppocr/model_list.html)基线4.5%,推理速度保持相近
42
+ - [x] 支持中英文文本检测与识别
43
+ - [x] 提供服务器端(Server)与移动端(mobile)模型
44
+ - [x] 支持自定义数据集微调: [检测模型微调](./docs/finetune_det.md), [识别模型微调](./docs/finetune_rec.md)
45
+ - [x] [支持导出ONNX模型](#导出onnx模型)
46
+
47
+ - 🔥**SVTRv2: CTC Beats Encoder-Decoder Models in Scene Text Recognition (ICCV 2025)**
48
+
49
+ - \[[论文](https://arxiv.org/abs/2411.15858)\] \[[文档](./configs/rec/svtrv2/)\] \[[模型](./configs/rec/svtrv2/readme.md#11-models-and-results)\] \[[数据集](./docs/svtrv2.md#downloading-datasets)\] \[[配置/训练/推理](./configs/rec/svtrv2/readme.md#3-model-training--evaluation)\] \[[基准测试](./docs/svtrv2.md#results-benchmark--configs--checkpoints)\]
50
+ - [技术文档](./docs/svtrv2.md)
51
+ - 基于[Union14M](https://github.com/Mountchicken/Union14M)构建的场景文本识别统一训练评估基准
52
+ - 支持24种场景文本识别方法在大规模真实数据集[Union14M-L-Filter](./docs/svtrv2.md#数据集详情)上的训练,将持续集成前沿方法
53
+ - 相比基于合成数据训练的模型,精度提升20-30%
54
+ - 单一视觉模型实现任意形状文本识别与语言建模
55
+ - 在精度与速度上全面超越基于Attention的编解码模型
56
+ - [从零训练SOTA模型指南](./docs/svtrv2.md#get-started-with-training-a-sota-scene-text-recognition-model-from-scratch)
57
+
58
+ ## 自研STR算法
59
+
60
+ - [**SVTRv2**](./configs/rec/svtrv2) (*Yongkun Du, Zhineng Chen\*, Hongtao Xie, Caiyan Jia, Yu-Gang Jiang. SVTRv2: CTC Beats Encoder-Decoder Models in Scene Text Recognition,* ICCV 2025. [Doc](./configs/rec/svtrv2/), [Paper](https://arxiv.org/abs/2411.15858))
61
+ - [**IGTR**](./configs/rec/igtr/) (*Yongkun Du, Zhineng Chen\*, Yuchen Su, Caiyan Jia, Yu-Gang Jiang. Instruction-Guided Scene Text Recognition,* TPAMI 2025. [Doc](./configs/rec/igtr), [Paper](https://ieeexplore.ieee.org/document/10820836))
62
+ - [**CPPD**](./configs/rec/cppd/) (*Yongkun Du, Zhineng Chen\*, Caiyan Jia, Xiaoting Yin, Chenxia Li, Yuning Du, Yu-Gang Jiang. Context Perception Parallel Decoder for Scene Text Recognition,* TPAMI 2025. [PaddleOCR Doc](https://github.com/PaddlePaddle/PaddleOCR/blob/main/docs/algorithm/text_recognition/algorithm_rec_cppd.en.md), [Paper](https://ieeexplore.ieee.org/document/10902187))
63
+ - [**SMTR&FocalSVTR**](./configs/rec/smtr/) (*Yongkun Du, Zhineng Chen\*, Caiyan Jia, Xieping Gao, Yu-Gang Jiang. Out of Length Text Recognition with Sub-String Matching,* AAAI 2025. [Doc](./configs/rec/smtr/), [Paper](https://ojs.aaai.org/index.php/AAAI/article/view/32285))
64
+ - [**DPTR**](./configs/rec/dptr/) (*Shuai Zhao, Yongkun Du, Zhineng Chen\*, Yu-Gang Jiang. Decoder Pre-Training with only Text for Scene Text Recognition,* ACM MM 2024. [Paper](https://dl.acm.org/doi/10.1145/3664647.3681390))
65
+ - [**CDistNet**](./configs/rec/cdistnet/) (*Tianlun Zheng, Zhineng Chen\*, Shancheng Fang, Hongtao Xie, Yu-Gang Jiang. CDistNet: Perceiving Multi-Domain Character Distance for Robust Text Recognition,* IJCV 2024. [Paper](https://link.springer.com/article/10.1007/s11263-023-01880-0))
66
+ - **MRN** (*Tianlun Zheng, Zhineng Chen\*, Bingchen Huang, Wei Zhang, Yu-Gang Jiang. MRN: Multiplexed Routing Network for Incremental Multilingual Text Recognition,* ICCV 2023. [Paper](https://openaccess.thecvf.com/content/ICCV2023/html/Zheng_MRN_Multiplexed_Routing_Network_for_Incremental_Multilingual_Text_Recognition_ICCV_2023_paper.html), [Code](https://github.com/simplify23/MRN))
67
+ - **TPS++** (*Tianlun Zheng, Zhineng Chen\*, Jinfeng Bai, Hongtao Xie, Yu-Gang Jiang. TPS++: Attention-Enhanced Thin-Plate Spline for Scene Text Recognition,* IJCAI 2023. [Paper](https://arxiv.org/abs/2305.05322), [Code](https://github.com/simplify23/TPS_PP))
68
+ - [**SVTR**](./configs/rec/svtr/) (*Yongkun Du, Zhineng Chen\*, Caiyan Jia, Xiaoting Yin, Tianlun Zheng, Chenxia Li, Yuning Du, Yu-Gang Jiang. SVTR: Scene Text Recognition with a Single Visual Model,* IJCAI 2022 (Long). [PaddleOCR Doc](https://github.com/Topdu/PaddleOCR/blob/main/doc/doc_ch/algorithm_rec_svtr.md), [Paper](https://www.ijcai.org/proceedings/2022/124))
69
+ - [**NRTR**](./configs/rec/nrtr/) (*Fenfen Sheng, Zhineng Chen, Bo Xu. NRTR: A No-Recurrence Sequence-to-Sequence Model For Scene Text Recognition,* ICDAR 2019. [Paper](https://arxiv.org/abs/1806.00926))
70
+
71
+ ## 近期更新
72
+
73
+ - **2025.07.10**: [SVTRv2](https://arxiv.org/abs/2411.15858)被ICCV 2025接收. 详见[文档](./configs/rec/svtrv2/)
74
+ - **2025.03.24**: 🔥 发布自定义数据集微调功能: [检测模型微调](./docs/finetune_det.md), [识别模型微调](./docs/finetune_rec.md)
75
+ - **2025.03.23**: 🔥 新增[ONNX模型导出功能](#导出onnx模型)
76
+ - **2025.02.22**: [CPPD](https://ieeexplore.ieee.org/document/10902187)论文被TPAMI录用,详见[文档](./configs/rec/cppd/)与[PaddleOCR文档](https://github.com/PaddlePaddle/PaddleOCR/blob/main/docs/algorithm/text_recognition/algorithm_rec_cppd.en.md)
77
+ - **2024.12.31**: [IGTR](https://ieeexplore.ieee.org/document/10820836)论文被TPAMI录用,详见[文档](./configs/rec/igtr/)
78
+ - **2024.12.16**: [SMTR](https://ojs.aaai.org/index.php/AAAI/article/view/32285)论文被AAAI 2025录用,详见[文档](./configs/rec/smtr/)
79
+ - **2024.12.03**: [DPTR](https://dl.acm.org/doi/10.1145/3664647.3681390)预训练代码合并
80
+ - **🔥 2024.11.23 重大更新**:
81
+ - **OpenOCR通用OCR系统发布**
82
+ - ⚡\[[快速开始](#快速开始)\] \[[模型下载](https://github.com/Topdu/OpenOCR/releases/tag/develop0.0.1)\] \[[ModelScopeDemo](https://modelscope.cn/studios/topdktu/OpenOCR-Demo)\] \[[Hugging FaceDemo](https://huggingface.co/spaces/topdu/OpenOCR-Demo)\] \[[本地Demo](#本地Demo)\] \[[PaddleOCR实现](https://paddlepaddle.github.io/PaddleOCR/latest/algorithm/text_recognition/algorithm_rec_svtrv2.html)\]
83
+ - [技术文档](./docs/openocr.md)
84
+ - **SVTRv2论文发布**
85
+ - \[[论文](https://arxiv.org/abs/2411.15858)\] \[[文档](./configs/rec/svtrv2/)\] \[[模型](./configs/rec/svtrv2/readme.md#11-models-and-results)\] \[[数据集](./docs/svtrv2.md#downloading-datasets)\] \[[配置/训练/推理](./configs/rec/svtrv2/readme.md#3-model-training--evaluation)\] \[[基准测试](./docs/svtrv2.md#results-benchmark--configs--checkpoints)\]
86
+ - [技术文档](./docs/svtrv2.md)
87
+ - [从零训练SOTA模型指南](./docs/svtrv2.md#get-started-with-training-a-sota-scene-text-recognition-model-from-scratch)
88
+
89
+ ## 快速开始
90
+
91
+ **注意**: OpenOCR支持ONNX和PyTorch双框架推理,环境相互独立。使用ONNX推理时无需安装PyTorch,反之亦然。
92
+
93
+ ### 1. ONNX推理
94
+
95
+ #### 安装OpenOCR及依赖:
96
+
97
+ ```shell
98
+ pip install openocr-python
99
+ pip install onnxruntime
100
+ ```
101
+
102
+ #### 使用示例:
103
+
104
+ ```python
105
+ from openocr import OpenOCR
106
+ onnx_engine = OpenOCR(backend='onnx', device='cpu')
107
+ img_path = '/path/img_path or /path/img_file'
108
+ result, elapse = onnx_engine(img_path)
109
+ ```
110
+
111
+ ### 2. PyTorch推理
112
+
113
+ #### 环境依赖:
114
+
115
+ - [PyTorch](http://pytorch.org/) >= 1.13.0
116
+ - Python >= 3.7
117
+
118
+ ```shell
119
+ conda create -n openocr python==3.8
120
+ conda activate openocr
121
+ # 安装GPU版本
122
+ conda install pytorch==2.2.0 torchvision==0.17.0 torchaudio==2.2.0 pytorch-cuda=11.8 -c pytorch -c nvidia
123
+ # 或CPU版本
124
+ conda install pytorch torchvision torchaudio cpuonly -c pytorch
125
+ ```
126
+
127
+ #### 2.1 Python包安装
128
+
129
+ **安装OpenOCR**:
130
+
131
+ ```shell
132
+ pip install openocr-python
133
+ ```
134
+
135
+ **使用示例**:
136
+
137
+ ```python
138
+ from openocr import OpenOCR
139
+ engine = OpenOCR()
140
+ img_path = '/path/img_path or /path/img_file'
141
+ result, elapse = engine(img_path)
142
+
143
+ # Server模式
144
+ # engine = OpenOCR(mode='server')
145
+ ```
146
+
147
+ #### 2.2 源码安装
148
+
149
+ ```shell
150
+ git clone https://github.com/Topdu/OpenOCR.git
151
+ cd OpenOCR
152
+ pip install -r requirements.txt
153
+ wget https://github.com/Topdu/OpenOCR/releases/download/develop0.0.1/openocr_det_repvit_ch.pth
154
+ wget https://github.com/Topdu/OpenOCR/releases/download/develop0.0.1/openocr_repsvtr_ch.pth
155
+ # Server识别模型
156
+ # wget https://github.com/Topdu/OpenOCR/releases/download/develop0.0.1/openocr_svtrv2_ch.pth
157
+ ```
158
+
159
+ **使用命令**:
160
+
161
+ ```shell
162
+ # 端到端OCR系统: 检测+识别
163
+ python tools/infer_e2e.py --img_path=/path/img_path or /path/img_file
164
+ # 单独检测模型
165
+ python tools/infer_det.py --c ./configs/det/dbnet/repvit_db.yml --o Global.infer_img=/path/img_path or /path/img_file
166
+ # 单独识别模型
167
+ python tools/infer_rec.py --c ./configs/rec/svtrv2/repsvtr_ch.yml --o Global.infer_img=/path/img_path or /path/img_file
168
+ ```
169
+
170
+ ##### 导出ONNX模型
171
+
172
+ ```shell
173
+ pip install onnx
174
+ python tools/toonnx.py --c configs/rec/svtrv2/repsvtr_ch.yml --o Global.device=cpu
175
+ python tools/toonnx.py --c configs/det/dbnet/repvit_db.yml --o Global.device=cpu
176
+ ```
177
+
178
+ ##### ONNXRuntime推理
179
+
180
+ ```shell
181
+ pip install onnxruntime
182
+ # 端到端OCR系统
183
+ python tools/infer_e2e.py --img_path=/path/img_path or /path/img_file --backend=onnx --device=cpu
184
+ # 检测模型
185
+ python tools/infer_det.py --c ./configs/det/dbnet/repvit_db.yml --o Global.backend=onnx Global.device=cpu Global.infer_img=/path/img_path or /path/img_file
186
+ # 识别模型
187
+ python tools/infer_rec.py --c ./configs/rec/svtrv2/repsvtr_ch.yml --o Global.backend=onnx Global.device=cpu Global.infer_img=/path/img_path or /path/img_file
188
+ ```
189
+
190
+ #### 本地Demo
191
+
192
+ ```shell
193
+ pip install gradio==4.20.0
194
+ wget https://github.com/Topdu/OpenOCR/releases/download/develop0.0.1/OCR_e2e_img.tar
195
+ tar xf OCR_e2e_img.tar
196
+ # 启动Demo
197
+ python demo_gradio.py
198
+ ```
199
+
200
+ ## 算法复现计划
201
+
202
+ ### 场景文本识别(STR)
203
+
204
+ | 方法 | 会议/期刊 | 训练支持 | 评估支持 | 贡献者 |
205
+ | --------------------------------------------- | ------------------------------------------------------------------------------------------------ | -------- | -------- | ------------------------------------------- |
206
+ | [CRNN](./configs/rec/svtrs/) | [TPAMI 2016](https://arxiv.org/abs/1507.05717) | ✅ | ✅ | |
207
+ | [ASTER](./configs/rec/aster/) | [TPAMI 2019](https://ieeexplore.ieee.org/document/8395027) | ✅ | ✅ | [pretto0](https://github.com/pretto0) |
208
+ | [NRTR](./configs/rec/nrtr/) | [ICDAR 2019](https://arxiv.org/abs/1806.00926) | ✅ | ✅ | |
209
+ | [SAR](./configs/rec/sar/) | [AAAI 2019](https://aaai.org/papers/08610-show-attend-and-read-a-simple-and-strong-baseline-for-irregular-text-recognition/) | ✅ | ✅ | [pretto0](https://github.com/pretto0) |
210
+ | [MORAN](./configs/rec/moran/) | [PR 2019](https://www.sciencedirect.com/science/article/abs/pii/S0031320319300263) | ✅ | ✅ | |
211
+ | [DAN](./configs/rec/dan/) | [AAAI 2020](https://arxiv.org/pdf/1912.10205) | ✅ | ✅ | |
212
+ | [RobustScanner](./configs/rec/robustscanner/) | [ECCV 2020](https://www.ecva.net/papers/eccv_2020/papers_ECCV/html/3160_ECCV_2020_paper.php) | ✅ | ✅ | [pretto0](https://github.com/pretto0) |
213
+ | [AutoSTR](./configs/rec/autostr/) | [ECCV 2020](https://www.ecva.net/papers/eccv_2020/papers_ECCV/papers/123690732.pdf) | ✅ | ✅ | |
214
+ | [SRN](./configs/rec/srn/) | [CVPR 2020](https://openaccess.thecvf.com/content_CVPR_2020/html/Yu_Towards_Accurate_Scene_Text_Recognition_With_Semantic_Reasoning_Networks_CVPR_2020_paper.html) | ✅ | ✅ | [pretto0](https://github.com/pretto0) |
215
+ | [SEED](./configs/rec/seed/) | [CVPR 2020](https://openaccess.thecvf.com/content_CVPR_2020/html/Qiao_SEED_Semantics_Enhanced_Encoder-Decoder_Framework_for_Scene_Text_Recognition_CVPR_2020_paper.html) | ✅ | ✅ | |
216
+ | [ABINet](./configs/rec/abinet/) | [CVPR 2021](https://openaccess.thecvf.com//content/CVPR2021/html/Fang_Read_Like_Humans_Autonomous_Bidirectional_and_Iterative_Language_Modeling_for_CVPR_2021_paper.html) | ✅ | ✅ | [YesianRohn](https://github.com/YesianRohn) |
217
+ | [VisionLAN](./configs/rec/visionlan/) | [ICCV 2021](https://openaccess.thecvf.com/content/ICCV2021/html/Wang_From_Two_to_One_A_New_Scene_Text_Recognizer_With_ICCV_2021_paper.html) | ✅ | ✅ | [YesianRohn](https://github.com/YesianRohn) |
218
+ | PIMNet | [ACM MM 2021](https://dl.acm.org/doi/10.1145/3474085.3475238) | | | TODO |
219
+ | [SVTR](./configs/rec/svtrs/) | [IJCAI 2022](https://www.ijcai.org/proceedings/2022/124) | ✅ | ✅ | |
220
+ | [PARSeq](./configs/rec/parseq/) | [ECCV 2022](https://www.ecva.net/papers/eccv_2022/papers_ECCV/papers/136880177.pdf) | ✅ | ✅ | |
221
+ | [MATRN](./configs/rec/matrn/) | [ECCV 2022](https://www.ecva.net/papers/eccv_2022/papers_ECCV/papers/136880442.pdf) | ✅ | ✅ | |
222
+ | [MGP-STR](./configs/rec/mgpstr/) | [ECCV 2022](https://www.ecva.net/papers/eccv_2022/papers_ECCV/papers/136880336.pdf) | ✅ | ✅ | |
223
+ | [LPV](./configs/rec/lpv/) | [IJCAI 2023](https://www.ijcai.org/proceedings/2023/0189.pdf) | ✅ | ✅ | |
224
+ | [MAERec](./configs/rec/maerec/)(Union14M) | [ICCV 2023](https://openaccess.thecvf.com/content/ICCV2023/papers/Jiang_Revisiting_Scene_Text_Recognition_A_Data_Perspective_ICCV_2023_paper.pdf) | ✅ | ✅ | |
225
+ | [LISTER](./configs/rec/lister/) | [ICCV 2023](https://openaccess.thecvf.com/content/ICCV2023/papers/Cheng_LISTER_Neighbor_Decoding_for_Length-Insensitive_Scene_Text_Recognition_ICCV_2023_paper.pdf) | ✅ | ✅ | |
226
+ | [CDistNet](./configs/rec/cdistnet/) | [IJCV 2024](https://link.springer.com/article/10.1007/s11263-023-01880-0) | ✅ | ✅ | [YesianRohn](https://github.com/YesianRohn) |
227
+ | [BUSNet](./configs/rec/busnet/) | [AAAI 2024](https://ojs.aaai.org/index.php/AAAI/article/view/28402) | ✅ | ✅ | |
228
+ | DCTC | [AAAI 2024](https://ojs.aaai.org/index.php/AAAI/article/view/28575) | | | TODO |
229
+ | [CAM](./configs/rec/cam/) | [PR 2024](https://arxiv.org/abs/2402.13643) | ✅ | ✅ | |
230
+ | [OTE](./configs/rec/ote/) | [CVPR 2024](https://openaccess.thecvf.com/content/CVPR2024/html/Xu_OTE_Exploring_Accurate_Scene_Text_Recognition_Using_One_Token_CVPR_2024_paper.html) | ✅ | ✅ | |
231
+ | CFF | [IJCAI 2024](https://arxiv.org/abs/2407.05562) | | | TODO |
232
+ | [DPTR](./configs/rec/dptr/) | [ACM MM 2024](https://dl.acm.org/doi/10.1145/3664647.3681390) | | | [fd-zs](https://github.com/fd-zs) |
233
+ | VIPTR | [ACM CIKM 2024](https://arxiv.org/abs/2401.10110) | | | TODO |
234
+ | [IGTR](./configs/rec/igtr/) | [TPAMI 2025](https://ieeexplore.ieee.org/document/10820836) | ✅ | ✅ | |
235
+ | [SMTR](./configs/rec/smtr/) | [AAAI 2025](https://ojs.aaai.org/index.php/AAAI/article/view/32285) | ✅ | ✅ | |
236
+ | [CPPD](./configs/rec/cppd/) | [TPAMI 2025](https://ieeexplore.ieee.org/document/10902187) | ✅ | ✅ | |
237
+ | [FocalSVTR-CTC](./configs/rec/svtrs/) | [AAAI 2025](https://ojs.aaai.org/index.php/AAAI/article/view/32285) | ✅ | ✅ | |
238
+ | [SVTRv2](./configs/rec/svtrv2/) | [ICCV 2025](https://arxiv.org/abs/2411.15858) | ✅ | ✅ | |
239
+ | [ResNet+Trans-CTC](./configs/rec/svtrs/) | | ✅ | ✅ | |
240
+ | [ViT-CTC](./configs/rec/svtrs/) | | ✅ | ✅ | |
241
+
242
+ #### 核心贡献者
243
+
244
+ ______________________________________________________________________
245
+
246
+ 复旦大学[FVL实验室](https://fvl.fudan.edu.cn)的Yiming Lei ([pretto0](https://github.com/pretto0)), Xingsong Ye ([YesianRohn](https://github.com/YesianRohn)), and Shuai Zhao ([fd-zs](https://github.com/fd-zs))在Zhineng Chen老师([个人主页](https://zhinchenfd.github.io/))指导下完成了主要算法复现工作,感谢他们的贡献。
247
+
248
+ ### 场景文本检测(STD)
249
+
250
+ 开发中
251
+
252
+ ### 端到端文本识别(Text Spotting)
253
+
254
+ 开发中
255
+
256
+ ______________________________________________________________________
257
+
258
+ ## 引用
259
+
260
+ 如果我们的工作对您的研究有所帮助,请引用:
261
+
262
+ ```bibtex
263
+ @inproceedings{Du2024SVTRv2,
264
+ title={SVTRv2: CTC Beats Encoder-Decoder Models in Scene Text Recognition},
265
+ author={Yongkun Du and Zhineng Chen and Hongtao Xie and Caiyan Jia and Yu-Gang Jiang},
266
+ booktitle={ICCV},
267
+ year={2025}
268
+ }
269
+ ```
270
+
271
+ ## 致谢
272
+
273
+ 本代码库基于[PaddleOCR](https://github.com/PaddlePaddle/PaddleOCR)、[PytorchOCR](https://github.com/WenmuZhou/PytorchOCR)和[MMOCR](https://github.com/open-mmlab/mmocr)构建,感谢他们的出色工作!
__init__.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import absolute_import
2
+ from __future__ import division
3
+ from __future__ import print_function
4
+ import os
5
+ import sys
6
+
7
+ __dir__ = os.path.dirname(os.path.abspath(__file__))
8
+ sys.path.append(__dir__)
9
+ sys.path.insert(0, os.path.abspath(os.path.join(__dir__, '..')))
10
+
11
+ from tools.infer_e2e import OpenOCR, OpenDetector, OpenRecognizer
app.py ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import torch
3
+ from threading import Thread
4
+
5
+ import numpy as np
6
+ from openrec.postprocess.unirec_postprocess import clean_special_tokens
7
+ from openrec.preprocess import create_operators, transform
8
+ from tools.engine.config import Config
9
+ from tools.utils.ckpt import load_ckpt
10
+ from tools.infer_rec import build_rec_process
11
+
12
+
13
+ def set_device(device):
14
+ if device == 'gpu' and torch.cuda.is_available():
15
+ device = torch.device(f'cuda:0')
16
+ else:
17
+ device = torch.device('cpu')
18
+ return device
19
+
20
+
21
+ cfg = Config('configs/rec/unirec/focalsvtr_ardecoder_unirec.yml')
22
+ cfg = cfg.cfg
23
+ global_config = cfg['Global']
24
+
25
+ from openrec.modeling.transformers_modeling.modeling_unirec import UniRecForConditionalGenerationNew
26
+ from openrec.modeling.transformers_modeling.configuration_unirec import UniRecConfig
27
+ from transformers import AutoTokenizer, TextIteratorStreamer
28
+
29
+ tokenizer = AutoTokenizer.from_pretrained(global_config['vlm_ocr_config'])
30
+ cfg_model = UniRecConfig.from_pretrained(global_config['vlm_ocr_config'])
31
+ # cfg_model._attn_implementation = "flash_attention_2"
32
+ cfg_model._attn_implementation = 'eager'
33
+
34
+ model = UniRecForConditionalGenerationNew(config=cfg_model)
35
+ load_ckpt(model, cfg)
36
+ device = set_device(cfg['Global']['device'])
37
+ model.eval()
38
+ model.to(device=device)
39
+
40
+ transforms, ratio_resize_flag = build_rec_process(cfg)
41
+ ops = create_operators(transforms, global_config)
42
+
43
+
44
+ # --- 2. Streaming generation function ---
45
+ def stream_chat_with_image(input_image, history):
46
+ if input_image is None:
47
+ yield history + [('🖼️(empty)', 'Please upload an image first.')]
48
+ return
49
+
50
+ # Create TextIteratorStreamer
51
+ streamer = TextIteratorStreamer(
52
+ tokenizer,
53
+ skip_prompt=True,
54
+ skip_special_tokens=False
55
+ )
56
+
57
+ data = {'image': input_image}
58
+ batch = transform(data, ops[1:])
59
+ images = np.expand_dims(batch[0], axis=0)
60
+ images = torch.from_numpy(images).to(device=device)
61
+ inputs = {
62
+ 'pixel_values': images,
63
+ 'input_ids': None,
64
+ 'attention_mask': None
65
+ }
66
+ generation_kwargs = dict(inputs, streamer=streamer, max_new_tokens=1024)
67
+ # Running generation in background thread
68
+ thread = Thread(target=model.generate, kwargs=generation_kwargs)
69
+ thread.start()
70
+
71
+ # Stream output
72
+ generated_text = ''
73
+ history = history + [('🖼️(image)', '')]
74
+ for new_text in streamer:
75
+ new_text = clean_special_tokens(new_text)
76
+ generated_text += new_text
77
+ history[-1] = ('🖼️(image)', generated_text)
78
+ yield history
79
+
80
+
81
+ # --- 3. Gradio UI ---
82
+ with gr.Blocks(theme=gr.themes.Soft()) as demo:
83
+ gr.HTML("""
84
+ <h1 style='text-align: center;'>
85
+ <a href="https://github.com/Topdu/OpenOCR">
86
+ UniRec-0.1B: Unified Text and Formula Recognition with 0.1B Parameters
87
+ </a>
88
+ </h1>
89
+ <p style='text-align: center;'>
90
+ A ultralight unified text and formula recognition model
91
+ (Created by <a href="https://fvl.fudan.edu.cn">FVL Lab</a>,
92
+ <a href="https://github.com/Topdu/OpenOCR">OCR Team</a>)
93
+ </p>
94
+ <p style='text-align: center;'>
95
+ <a href="https://github.com/Topdu/OpenOCR/blob/main/docs/unirec.md">[Local GPU Deployment]</a>
96
+ for fast recognition experience
97
+ </p>"""
98
+ )
99
+ gr.Markdown('Upload an image, and the system will automatically recognize text and formulas.')
100
+ with gr.Row():
101
+ with gr.Column(scale=1): # Left column: image + clear button
102
+ image_input = gr.Image(label='Upload Image or Paste Screenshot', type='pil')
103
+ clear = gr.ClearButton([image_input], value='Clear')
104
+ with gr.Column(scale=2):
105
+ chatbot = gr.Chatbot(
106
+ label='Result (Use LaTeX renderer to display formulas)',
107
+ show_copy_button=True,
108
+ height='auto'
109
+ )
110
+ clear.add([chatbot])
111
+
112
+ # Trigger after upload
113
+ image_input.upload(stream_chat_with_image, [image_input, chatbot], chatbot)
114
+
115
+ # --- 4. Launch app ---
116
+ if __name__ == '__main__':
117
+ demo.queue().launch(share=True)
configs/dataset/rec/evaluation.yaml ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ root: ../evaluation
2
+ task: str
3
+ download_links:
4
+ # IC15_1811
5
+ - https://drive.usercontent.google.com/download?id=1eGY0kXNV1qVxeUpoGzs-ioUO-ky7msH6&authuser=0&confirm=t
6
+ - https://drive.usercontent.google.com/download?id=1BWv7aLoLAT7avY326gXP3GJF48UZpuBC&authuser=0&confirm=t
7
+ # SVT
8
+ - https://drive.usercontent.google.com/download?id=1ecEZ4cJ7dIbTCZRltE0s5KzUotQWagH-&authuser=0&confirm=t
9
+ - https://drive.usercontent.google.com/download?id=1OygBP7i9R-3Pwi6WodCcW31J8CUMugOJ&authuser=0&confirm=t
10
+ # IIIT5k
11
+ - https://drive.usercontent.google.com/download?id=1PJ9_IvIGZTS5hHdGLnpKuYKZcCO8jE0E&authuser=0&confirm=t
12
+ - https://drive.usercontent.google.com/download?id=10P3MixSBt1v8k8_6aFfziC33Z5IlM6Uf&authuser=0&confirm=t
13
+ # IC13_857
14
+ - https://drive.usercontent.google.com/download?id=1-wMHOFBXJaOaY-UD00nDn6qw2s_8R4Vd&authuser=0&confirm=t
15
+ - https://drive.usercontent.google.com/download?id=1J1QCFtOFxFKiLJIgTqZ6eRo9Y5QGqHpA&authuser=0&confirm=t
16
+ # SVTP
17
+ - https://drive.usercontent.google.com/download?id=1kckwfZkdaHG8k_FW5IIJKUaYZkF21Hza&authuser=0&confirm=t
18
+ - https://drive.usercontent.google.com/download?id=1x61lm_ea7lvIdxNPMG-jy-5W0MxtdH0N&authuser=0&confirm=t
19
+ # CUTE80
20
+ - https://drive.usercontent.google.com/download?id=1Zv_91c81tinLy5Je89HPr-5wUSnqXKIB&authuser=0&confirm=t
21
+ - https://drive.usercontent.google.com/download?id=1OuJ6QoJ9AlyNHIM9j2WedAPxTnac7kyY&authuser=0&confirm=t
22
+ filenames:
23
+ # IC15_1811
24
+ - ../evaluation/IC15_1811/data.mdb
25
+ - ../evaluation/IC15_1811/lock.mdb
26
+ # SVT
27
+ - ../evaluation/SVT/data.mdb
28
+ - ../evaluation/SVT/lock.mdb
29
+ # IIIT5k
30
+ - ../evaluation/IIIT5k/data.mdb
31
+ - ../evaluation/IIIT5k/lock.mdb
32
+ # IC13_857
33
+ - ../evaluation/IC13_857/data.mdb
34
+ - ../evaluation/IC13_857/lock.mdb
35
+ # SVTP
36
+ - ../evaluation/SVTP/data.mdb
37
+ - ../evaluation/SVTP/lock.mdb
38
+ # CUTE80
39
+ - ../evaluation/CUTE80/data.mdb
40
+ - ../evaluation/CUTE80/lock.mdb
41
+ check_validity: true
configs/dataset/rec/ltb.yaml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ root: ../ltb
2
+ task: str
3
+ download_links:
4
+ - https://drive.usercontent.google.com/download?id=16AEA1YGTsyVB44uEjKi4ZUV1snjCYBr4&authuser=0&confirm=t
5
+ - https://drive.usercontent.google.com/download?id=1xU4OStrOaI23bPG4flWAPWn2YrQe2bmY&authuser=0&confirm=t
6
+ filenames:
7
+ - ../ltb/data.mdb
8
+ - ../ltb/lock.mdb
9
+ check_validity: true
configs/dataset/rec/mjsynth.yaml ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ root: ../synth
2
+ task: str
3
+ download_links:
4
+ - https://drive.usercontent.google.com/download?id=1FIoplSFZ-BKQoRDHDXsVMKa844e-K8PD&authuser=0&confirm=t
5
+ - https://drive.usercontent.google.com/download?id=1eckTvaeRtlTZvbO2orrVz-cIuIk6i87K&authuser=0&confirm=t
6
+ - https://drive.usercontent.google.com/download?id=1PBXTf-2PnmEvJBsqzJqxxRwzhAZGTiMG&authuser=0&confirm=t
7
+ filenames:
8
+ - ../synth/MJ_train.zip
9
+ - ../synth/MJ_val.zip
10
+ - ../synth/MJ_test.zip
11
+ check_validity: true
configs/dataset/rec/openvino.yaml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ root: ../OpenVINO
2
+ task: str
3
+ download_links:
4
+ # train_1
5
+ - https://drive.usercontent.google.com/download?id=1q23QAIRTyG0t-bBm4aAwRwiqB6VUfphw&authuser=0&confirm=
6
+ # train_2
7
+ - https://drive.usercontent.google.com/download?id=1AtbaJljM68cbZqi5lcM92d9VkQUCbSqI&authuser=0&confirm=
8
+ # train_5
9
+ - https://drive.usercontent.google.com/download?id=1dejstYnJ8_sESuO_uvwi__jT1B8gPxf3&authuser=0&confirm=t
10
+ # train_f
11
+ - https://drive.usercontent.google.com/download?id=1C4akchTc7-yi1OS_sJ3KP693UKcnecke&authuser=0&confirm=t
12
+ # validation
13
+ - https://drive.usercontent.google.com/download?id=17TRzSQhuK_juAxAv3KmX0y13pQP2cz6R&authuser=0&confirm=t
14
+ filenames:
15
+ # train_1
16
+ - ../OpenVINO/train_1.zip
17
+ # train_2
18
+ - ../OpenVINO/train_2.zip
19
+ # train_5
20
+ - ../OpenVINO/train_5.zip
21
+ # train_f
22
+ - ../OpenVINO/train_f.zip
23
+ # validation
24
+ - ../OpenVINO/validation.zip
25
+ check_validity: true
configs/dataset/rec/ost.yaml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ root: ../OST
2
+ task: str
3
+ download_links:
4
+ # OST heavy
5
+ - https://drive.usercontent.google.com/download?id=1RGpIFbD_SRlrzZFBoVF_LGvetNx1-5pg&authuser=0&confirm=t
6
+ - https://drive.usercontent.google.com/download?id=1Th4MfDf44k0EBpIqCLqVoGRu6G-FP1hq&authuser=0&confirm=t
7
+ # OST weak
8
+ - https://drive.usercontent.google.com/download?id=1z5CTDJucUnvALG12Q4UXk1DDKJDd8WJn&authuser=0&confirm=t
9
+ - https://drive.usercontent.google.com/download?id=1V17TTkX3sjpV7v0km_F2SDCK0tL3k_ls&authuser=0&confirm=t
10
+ filenames:
11
+ # OST heavy
12
+ - ../OST/heavy/data.mdb
13
+ - ../OST/heavy/lock.mdb
14
+ # OST weak
15
+ - ../OST/weak/data.mdb
16
+ - ../OST/weak/lock.mdb
17
+ check_validity: true
configs/dataset/rec/synthtext.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ root: ../synth
2
+ task: str
3
+ download_links:
4
+ - https://drive.usercontent.google.com/download?id=1T-enqkq6_l2HqrsV3da_h0oJ7CUKu_oc&authuser=0&confirm=t
5
+ filenames:
6
+ - ../synth/ST.zip
7
+ check_validity: true
configs/dataset/rec/test.yaml ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ root: ../test
2
+ task: str
3
+ download_links:
4
+ # IC13_857
5
+ - https://drive.usercontent.google.com/download?id=1PZSCbe6_DI8MlCqCRWXGT2PP92_frIXq&authuser=0&confirm=t
6
+ - https://drive.usercontent.google.com/download?id=1qkN7NDg0zUHxUiZHAeEatDTqlsgpFWp3&authuser=0&confirm=t
7
+ # IC15_2077
8
+ - https://drive.usercontent.google.com/download?id=1dFkY3DNbr-Mepn3TWBiA9COEJ63fGFcp&authuser=0&confirm=t
9
+ - https://drive.usercontent.google.com/download?id=1UvVwLNZ3tS1YdTBa8MulPzjeVezKaDro&authuser=0&confirm=t
10
+ # SVTP
11
+ - https://drive.usercontent.google.com/download?id=1aofeerilxJ7J3S7QxuCEXbmXTpz8Xshx&authuser=0&confirm=t
12
+ - https://drive.usercontent.google.com/download?id=1rJ1KoO4K_VUxEAUN_bMgBGzK8_JZAAno&authuser=0&confirm=t
13
+ # IIIT5k
14
+ - https://drive.usercontent.google.com/download?id=1XFO2M1Kbgwv3-iTNTmhQXAEjNmKYOeoT&authuser=0&confirm=t
15
+ - https://drive.usercontent.google.com/download?id=1stwK2hFsyaV7HHsEG9EYgnUQebNb2_nG&authuser=0&confirm=t
16
+ # COCOv1.4
17
+ - https://drive.usercontent.google.com/download?id=1Se2QSGS19xx7Gfy-SUdX9mlAOr2eYsfA&authuser=0&confirm=t
18
+ - https://drive.usercontent.google.com/download?id=1xvekFi389QfkH7yS0JIVV0QzjhUspjDv&authuser=0&confirm=t
19
+ # IC15_1811
20
+ - https://drive.usercontent.google.com/download?id=1pHsw8wrThD9EGEE6AusQLZozefSj4iyR&authuser=0&confirm=t
21
+ - https://drive.usercontent.google.com/download?id=1TXZ1qHuKAksaAlvd3qMv4IHKnN-IJW9a&authuser=0&confirm=t
22
+ # Uber
23
+ - https://drive.usercontent.google.com/download?id=1L2j6BZeLTGQ1FIl8HB_D3AFiWLltGV5r&authuser=0&confirm=t
24
+ - https://drive.usercontent.google.com/download?id=12DUj28yzLWxFO_gfMfSjTkRujYD5MNEE&authuser=0&confirm=t
25
+ # IC13_1095
26
+ - https://drive.usercontent.google.com/download?id=1fu8onMt3Z6fDLNAiHcm-sQ2qCXduE-FU&authuser=0&confirm=t
27
+ - https://drive.usercontent.google.com/download?id=1OQAZtLj8U2Cl4L0ErGFsz6vGIVTTWasD&authuser=0&confirm=t
28
+ # IC13_1015
29
+ - https://drive.usercontent.google.com/download?id=1mbsfuvWB282HYfn9tbqcj1nUDkLXcSNB&authuser=0&confirm=t
30
+ - https://drive.usercontent.google.com/download?id=1QGogU_hV-oN7iY2POutdD2LDcmK6plnV&authuser=0&confirm=t
31
+ # ArT
32
+ - https://drive.usercontent.google.com/download?id=1-53knSy-uTSngCG7wyBngVyTuTCmdnWl&authuser=0&confirm=t
33
+ - https://drive.usercontent.google.com/download?id=172EsSaf7BVaB1ORtohi-Jc_8SuUKZGGf&authuser=0&confirm=t
34
+ # SVT
35
+ - https://drive.usercontent.google.com/download?id=1p7aVUr9Yr7c4X4YUBvk2-YP28rraHjn9&authuser=0&confirm=t
36
+ - https://drive.usercontent.google.com/download?id=1ALmhvSleZ0yf-lcdbQPP3M9Zc3oqnXij&authuser=0&confirm=t
37
+ # CUTE80
38
+ - https://drive.usercontent.google.com/download?id=1Ujr4axHKnu54P2rIGUhkjdM6XlhDYrI_&authuser=0&confirm=t
39
+ - https://drive.usercontent.google.com/download?id=1DvZi9L3MqjO2zRUyCg3YvP4qMAt2bsme&authuser=0&confirm=t
40
+ filenames:
41
+ # IC13_857
42
+ - ../test/IC13_857/data.mdb
43
+ - ../test/IC13_857/lock.mdb
44
+ # IC15_2077
45
+ - ../test/IC15_2077/data.mdb
46
+ - ../test/IC15_2077/lock.mdb
47
+ # SVTP
48
+ - ../test/SVTP/data.mdb
49
+ - ../test/SVTP/lock.mdb
50
+ # IIIT5k
51
+ - ../test/IIIT5k/data.mdb
52
+ - ../test/IIIT5k/lock.mdb
53
+ # COCOv1.4
54
+ - ../test/COCOv1.4/data.mdb
55
+ - ../test/COCOv1.4/lock.mdb
56
+ # IC15_1811
57
+ - ../test/IC15_1811/data.mdb
58
+ - ../test/IC15_1811/lock.mdb
59
+ # Uber
60
+ - ../test/Uber/data.mdb
61
+ - ../test/Uber/lock.mdb
62
+ # IC13_1095
63
+ - ../test/IC13_1095/data.mdb
64
+ - ../test/IC13_1095/lock.mdb
65
+ # IC13_1015
66
+ - ../test/IC13_1015/data.mdb
67
+ - ../test/IC13_1015/lock.mdb
68
+ # ArT
69
+ - ../test/ArT/data.mdb
70
+ - ../test/ArT/lock.mdb
71
+ # SVT
72
+ - ../test/SVT/data.mdb
73
+ - ../test/SVT/lock.mdb
74
+ # CUTE80
75
+ - ../test/CUTE80/data.mdb
76
+ - ../test/CUTE80/lock.mdb
77
+ check_validity: true
configs/dataset/rec/textocr.yaml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ root: ../TextOCR
2
+ task: str
3
+ download_links:
4
+ # train
5
+ - https://drive.usercontent.google.com/download?id=1jVjJFno4pnsU0Cp_kn4MIXQrChmELy92&authuser=0&confirm=
6
+ # val
7
+ - https://drive.usercontent.google.com/download?id=1ubIRu01MXIek6OvInu-XjaIbw6277-vw&authuser=0&confirm=t
8
+ filenames:
9
+ # train
10
+ - ../TextOCR/train.zip
11
+ # val
12
+ - ../TextOCR/val.zip
13
+ check_validity: true
configs/dataset/rec/textocr_horizontal.yaml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ root: ../TextOCR_horizontal
2
+ task: str
3
+ download_links:
4
+ # train
5
+ - https://drive.usercontent.google.com/download?id=1sWH6J11xbjQb8SH7fdG_8mIKVI81ZQy5&authuser=0&confirm=
6
+ # val
7
+ - https://drive.usercontent.google.com/download?id=1gIE-AU2o-5hvg288-bjphO6UkI5AEQ2d&authuser=0&confirm=t
8
+ filenames:
9
+ # train
10
+ - ../TextOCR_horizontal/train.zip
11
+ # val
12
+ - ../TextOCR_horizontal/val.zip
13
+ check_validity: true
configs/dataset/rec/union14m_b.yaml ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ root: ../u14m
2
+ task: str
3
+ download_links:
4
+ # artistic
5
+ - https://drive.usercontent.google.com/download?id=1Je2DTuFHnkXDI99yDnm9Anl5naWaCQwd&authuser=0&confirm=t
6
+ - https://drive.usercontent.google.com/download?id=1xtT_Q0juBJUIvAG55qBxoVNNTECd2usZ&authuser=0&confirm=t
7
+ # contextless
8
+ - https://drive.usercontent.google.com/download?id=1_0OzyzWhZOmGrHkayFTVrzhrQrNRDRPR&authuser=0&confirm=t
9
+ - https://drive.usercontent.google.com/download?id=1PPgC42y3xoM9bR0HQFbDYbcT3PzMdD_y&authuser=0&confirm=t
10
+ # salient
11
+ - https://drive.usercontent.google.com/download?id=1tHLMYBmTqRnxvFOTT3dfLfQiundqFWfd&authuser=0&confirm=t
12
+ - https://drive.usercontent.google.com/download?id=13NQgpAtCK0kh9M5E2pAUmKKEp6Qu5Xwj&authuser=0&confirm=t
13
+ # multi_words
14
+ - https://drive.usercontent.google.com/download?id=1IlnDKX3V_Vp9gsDGFB0xoqsVLH1vtxUI&authuser=0&confirm=t
15
+ - https://drive.usercontent.google.com/download?id=1mFFjC7C0CwevvkwFU9YeVbZBdps_3Qpb&authuser=0&confirm=t
16
+ # curve
17
+ - https://drive.usercontent.google.com/download?id=1MxhMd85cmhUtI2lmtXhZQuFk7lav0_fw&authuser=0&confirm=t
18
+ - https://drive.usercontent.google.com/download?id=1N03g-4e-kJG2mRvlM0c5TrwWAkd-iG-Q&authuser=0&confirm=t
19
+ # general
20
+ - https://drive.usercontent.google.com/download?id=1Oqt7OaycP466NWoDmoJ3FqS8YP3YRgvu&authuser=0&confirm=t
21
+ - https://drive.usercontent.google.com/download?id=1K0MrX5eYNt8IIGFHXCwg0_oI5OF5PPFO&authuser=0&confirm=t
22
+ # multi_oriented
23
+ - https://drive.usercontent.google.com/download?id=1TKZFcZPVk0ThqfF-AGhJk_OCLg0ykKbv&authuser=0&confirm=t
24
+ - https://drive.usercontent.google.com/download?id=1PAoLMUWuR7O2-7XRoKkNzQcSiznErQzD&authuser=0&confirm=t
25
+ filenames:
26
+ # artistic
27
+ - ../u14m/artistic/data.mdb
28
+ - ../u14m/artistic/lock.mdb
29
+ # contextless
30
+ - ../u14m/contextless/data.mdb
31
+ - ../u14m/contextless/lock.mdb
32
+ # salient
33
+ - ../u14m/salient/data.mdb
34
+ - ../u14m/salient/lock.mdb
35
+ # multi_words
36
+ - ../u14m/multi_words/data.mdb
37
+ - ../u14m/multi_words/lock.mdb
38
+ # curve
39
+ - ../u14m/curve/data.mdb
40
+ - ../u14m/curve/lock.mdb
41
+ # general
42
+ - ../u14m/general/data.mdb
43
+ - ../u14m/general/lock.mdb
44
+ # multi_oriented
45
+ - ../u14m/multi_oriented/data.mdb
46
+ - ../u14m/multi_oriented/lock.mdb
47
+ check_validity: true
configs/dataset/rec/union14m_l_filtered.yaml ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ root: ../Union14M-L-LMDB-Filtered
2
+ task: str
3
+ download_links:
4
+ # train_challenging
5
+ - https://drive.usercontent.google.com/download?id=1etwzBgGHjsFsb0sygsaRnKbanW2PMe07&authuser=0&confirm=t
6
+ - https://drive.usercontent.google.com/download?id=1ly6FJfPjItwGlVQ-ifTrzzM3rVu3Ezhr&authuser=0&confirm=t
7
+ # train_easy
8
+ - https://drive.usercontent.google.com/download?id=1_zeNluTnywIaa5h3PN-Ah9tKyByypot7&authuser=0&confirm=t
9
+ - https://drive.usercontent.google.com/download?id=1caYLeQHDidXgVBDi9IWXbO1gg__DYq9a&authuser=0&confirm=t
10
+ # train_hard
11
+ - https://drive.usercontent.google.com/download?id=1eP6s2xyYPZX9gykvWA4VSOc3Fqul_UB_&authuser=0&confirm=t
12
+ - https://drive.usercontent.google.com/download?id=1-ZlCvocX8P5uVRclUXp_5DNGLDzd16EO&authuser=0&confirm=t
13
+ # train_medium
14
+ - https://drive.usercontent.google.com/download?id=1s_CoaLNJEr-UxHYiqZ5jOcliMCFiRUUy&authuser=0&confirm=t
15
+ - https://drive.usercontent.google.com/download?id=1Wpj6WVpZ5Ily77kVwfQ18CiZBzkgmEnF&authuser=0&confirm=t
16
+ # train_normal
17
+ - https://drive.usercontent.google.com/download?id=1jPt44arlAswl9cXZjzmVcdpptdTPpJ3I&authuser=0&confirm=t
18
+ - https://drive.usercontent.google.com/download?id=1Rfc5kE03AzOUv7B_eYcBhUV8KMQ2MZ1m&authuser=0&confirm=t
19
+ filenames:
20
+ # train_challenging
21
+ - ../Union14M-L-LMDB-Filtered/train_challenging/data.mdb
22
+ - ../Union14M-L-LMDB-Filtered/train_challenging/lock.mdb
23
+ # train_easy
24
+ - ../Union14M-L-LMDB-Filtered/train_easy/data.mdb
25
+ - ../Union14M-L-LMDB-Filtered/train_easy/lock.mdb
26
+ # train_hard
27
+ - ../Union14M-L-LMDB-Filtered/train_hard/data.mdb
28
+ - ../Union14M-L-LMDB-Filtered/train_hard/lock.mdb
29
+ # train_medium
30
+ - ../Union14M-L-LMDB-Filtered/train_medium/data.mdb
31
+ - ../Union14M-L-LMDB-Filtered/train_medium/lock.mdb
32
+ # train_normal
33
+ - ../Union14M-L-LMDB-Filtered/train_normal/data.mdb
34
+ - ../Union14M-L-LMDB-Filtered/train_normal/lock.mdb
35
+ check_validity: true
configs/det/dbnet/repvit_db.yml ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ device: gpu
3
+ epoch_num: &epoch_num 500
4
+ log_smooth_window: 20
5
+ print_batch_step: 100
6
+ output_dir: ./output/det_repsvtr_db
7
+ save_epoch_step: [400, 25]
8
+ eval_batch_step:
9
+ - 0
10
+ - 1000
11
+ cal_metric_during_train: false
12
+ checkpoints:
13
+ pretrained_model: openocr_det_repvit_ch.pth
14
+ save_inference_dir: null
15
+ use_tensorboard: false
16
+ infer_img:
17
+ save_res_path: ./checkpoints/det_db/predicts_db.txt
18
+ distributed: true
19
+ model_type: det
20
+
21
+ Architecture:
22
+ algorithm: DB_mobile
23
+ Backbone:
24
+ name: RepSVTR_det
25
+ Neck:
26
+ name: RSEFPN
27
+ out_channels: 96
28
+ shortcut: True
29
+ Head:
30
+ name: DBHead
31
+ k: 50
32
+
33
+ Loss:
34
+ name: DBLoss
35
+ balance_loss: true
36
+ main_loss_type: DiceLoss
37
+ alpha: 5
38
+ beta: 10
39
+ ohem_ratio: 3
40
+
41
+ Optimizer:
42
+ name: Adam
43
+ lr: 0.001
44
+ weight_decay: 5.0e-05
45
+ filter_bias_and_bn: False
46
+
47
+ LRScheduler:
48
+ name: CosineAnnealingLR
49
+ warmup_epoch: 2
50
+
51
+ PostProcess:
52
+ name: DBPostProcess
53
+ thresh: 0.3
54
+ box_thresh: 0.6
55
+ max_candidates: 1000
56
+ unclip_ratio: 1.5
57
+ score_mode: 'slow'
58
+
59
+ Metric:
60
+ name: DetMetric
61
+ main_indicator: hmean
62
+
63
+ Train:
64
+ dataset:
65
+ name: SimpleDataSet
66
+ data_dir: ../icdar2015/text_localization/
67
+ label_file_list:
68
+ - ../icdar2015/text_localization/train_icdar2015_label.txt
69
+ ratio_list: [1.0]
70
+ transforms:
71
+ - DecodeImage:
72
+ img_mode: BGR
73
+ channel_first: false
74
+ - DetLabelEncode: null
75
+ - CopyPaste: null
76
+ - IaaAugment:
77
+ augmenter_args:
78
+ - type: Fliplr
79
+ args:
80
+ p: 0.5
81
+ - type: Affine
82
+ args:
83
+ rotate:
84
+ - -10
85
+ - 10
86
+ - type: Resize
87
+ args:
88
+ size:
89
+ - 0.5
90
+ - 3
91
+ - EastRandomCropData:
92
+ size:
93
+ - 640
94
+ - 640
95
+ max_tries: 50
96
+ keep_ratio: true
97
+ - MakeBorderMap:
98
+ shrink_ratio: 0.4
99
+ thresh_min: 0.3
100
+ thresh_max: 0.7
101
+ total_epoch: *epoch_num
102
+ - MakeShrinkMap:
103
+ shrink_ratio: 0.4
104
+ min_text_size: 8
105
+ total_epoch: *epoch_num
106
+ - NormalizeImage:
107
+ scale: 1./255.
108
+ mean:
109
+ - 0.485
110
+ - 0.456
111
+ - 0.406
112
+ std:
113
+ - 0.229
114
+ - 0.224
115
+ - 0.225
116
+ order: hwc
117
+ - ToCHWImage: null
118
+ - KeepKeys:
119
+ keep_keys:
120
+ - image
121
+ - threshold_map
122
+ - threshold_mask
123
+ - shrink_map
124
+ - shrink_mask
125
+ loader:
126
+ shuffle: true
127
+ drop_last: false
128
+ batch_size_per_card: 8
129
+ num_workers: 8
130
+
131
+ Eval:
132
+ dataset:
133
+ name: SimpleDataSet
134
+ data_dir: ../icdar2015/text_localization/
135
+ label_file_list:
136
+ - ../icdar2015/text_localization/test_icdar2015_label.txt
137
+ transforms:
138
+ - DecodeImage:
139
+ img_mode: BGR
140
+ channel_first: false
141
+ - DetLabelEncode: null
142
+ - DetResizeForTest:
143
+ # image_shape: [1280, 1280]
144
+ # keep_ratio: True
145
+ # padding: True
146
+ limit_side_len: 960
147
+ limit_type: max
148
+ - NormalizeImage:
149
+ scale: 1./255.
150
+ mean:
151
+ - 0.485
152
+ - 0.456
153
+ - 0.406
154
+ std:
155
+ - 0.229
156
+ - 0.224
157
+ - 0.225
158
+ order: hwc
159
+ - ToCHWImage: null
160
+ - KeepKeys:
161
+ keep_keys:
162
+ - image
163
+ - shape
164
+ - polys
165
+ - ignore_tags
166
+ loader:
167
+ shuffle: false
168
+ drop_last: false
169
+ batch_size_per_card: 1
170
+ num_workers: 2
171
+ profiler_options: null
configs/rec/abinet/resnet45_trans_abinet_lang.yml ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ device: gpu
3
+ epoch_num: 20
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/rec/u14m_filter/resnet45_trans_abinet_lang/
7
+ eval_epoch_step: [0, 1]
8
+ eval_batch_step: [0, 500]
9
+ cal_metric_during_train: True
10
+ pretrained_model:
11
+ # ./openocr_nolang_abinet_lang.pth
12
+ checkpoints:
13
+ use_tensorboard: false
14
+ infer_img:
15
+ # for data or label process
16
+ character_dict_path: ./tools/utils/EN_symbol_dict.txt
17
+ max_text_length: 25
18
+ use_space_char: False
19
+ save_res_path: ./output/rec/u14m_filter/predicts_resnet45_trans_abinet_lang.txt
20
+ grad_clip_val: 20
21
+ use_amp: True
22
+
23
+ Optimizer:
24
+ name: Adam
25
+ lr: 0.000267
26
+ weight_decay: 0.0
27
+ filter_bias_and_bn: False
28
+
29
+ LRScheduler:
30
+ name: MultiStepLR
31
+ milestones: [12]
32
+ gamma: 0.1
33
+
34
+ Architecture:
35
+ model_type: rec
36
+ algorithm: ABINet
37
+ Transform:
38
+ Encoder:
39
+ name: ResNet45
40
+ in_channels: 3
41
+ strides: [2, 1, 2, 1, 1]
42
+ Decoder:
43
+ name: ABINetDecoder
44
+ iter_size: 3
45
+
46
+ Loss:
47
+ name: ABINetLoss
48
+
49
+ PostProcess:
50
+ name: ABINetLabelDecode
51
+
52
+ Metric:
53
+ name: RecMetric
54
+ main_indicator: acc
55
+ is_filter: True
56
+
57
+ Train:
58
+ dataset:
59
+ name: LMDBDataSet
60
+ data_dir: ../Union14M-L-LMDB-Filtered
61
+ transforms:
62
+ - DecodeImagePIL: # load image
63
+ img_mode: RGB
64
+ - PARSeqAugPIL:
65
+ - ABINetLabelEncode:
66
+ - RecTVResize:
67
+ image_shape: [32, 128]
68
+ padding: False
69
+ - KeepKeys:
70
+ keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
71
+ loader:
72
+ shuffle: True
73
+ batch_size_per_card: 256
74
+ drop_last: True
75
+ num_workers: 4
76
+
77
+ Eval:
78
+ dataset:
79
+ name: LMDBDataSet
80
+ data_dir: ../evaluation
81
+ transforms:
82
+ - DecodeImagePIL: # load image
83
+ img_mode: RGB
84
+ - ABINetLabelEncode:
85
+ - RecTVResize:
86
+ image_shape: [32, 128]
87
+ padding: False
88
+ - KeepKeys:
89
+ keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
90
+ loader:
91
+ shuffle: False
92
+ drop_last: False
93
+ batch_size_per_card: 256
94
+ num_workers: 2
configs/rec/abinet/resnet45_trans_abinet_wo_lang.yml ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ device: gpu
3
+ epoch_num: 20
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/rec/u14m_filter/resnet45_trans_abinet_wo_lang/
7
+ eval_epoch_step: [0, 1]
8
+ eval_batch_step: [0, 500]
9
+ cal_metric_during_train: True
10
+ pretrained_model:
11
+ checkpoints:
12
+ use_tensorboard: false
13
+ infer_img:
14
+ # for data or label process
15
+ character_dict_path: ./tools/utils/EN_symbol_dict.txt
16
+ max_text_length: 25
17
+ use_space_char: False
18
+ save_res_path: ./output/rec/u14m_filter/predicts_resnet45_trans_abinet_wo_lang.txt
19
+ grad_clip_val: 20
20
+ use_amp: True
21
+
22
+ Optimizer:
23
+ name: Adam
24
+ lr: 0.000267
25
+ weight_decay: 0.0
26
+ filter_bias_and_bn: False
27
+
28
+ LRScheduler:
29
+ name: MultiStepLR
30
+ milestones: [12]
31
+ gamma: 0.1
32
+
33
+ Architecture:
34
+ model_type: rec
35
+ algorithm: ABINet
36
+ Transform:
37
+ Encoder:
38
+ name: ResNet45
39
+ in_channels: 3
40
+ strides: [2, 1, 2, 1, 1]
41
+ Decoder:
42
+ name: ABINetDecoder
43
+ iter_size: 0
44
+
45
+ Loss:
46
+ name: ABINetLoss
47
+
48
+ PostProcess:
49
+ name: ABINetLabelDecode
50
+
51
+ Metric:
52
+ name: RecMetric
53
+ main_indicator: acc
54
+ is_filter: True
55
+
56
+ Train:
57
+ dataset:
58
+ name: LMDBDataSet
59
+ data_dir: ../Union14M-L-LMDB-Filtered
60
+ transforms:
61
+ - DecodeImagePIL: # load image
62
+ img_mode: RGB
63
+ - PARSeqAugPIL:
64
+ - ABINetLabelEncode:
65
+ - RecTVResize:
66
+ image_shape: [32, 128]
67
+ padding: False
68
+ - KeepKeys:
69
+ keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
70
+ loader:
71
+ shuffle: True
72
+ batch_size_per_card: 256
73
+ drop_last: True
74
+ num_workers: 4
75
+
76
+ Eval:
77
+ dataset:
78
+ name: LMDBDataSet
79
+ data_dir: ../evaluation
80
+ transforms:
81
+ - DecodeImagePIL: # load image
82
+ img_mode: RGB
83
+ - ABINetLabelEncode:
84
+ - RecTVResize:
85
+ image_shape: [32, 128]
86
+ padding: False
87
+ - KeepKeys:
88
+ keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
89
+ loader:
90
+ shuffle: False
91
+ drop_last: False
92
+ batch_size_per_card: 256
93
+ num_workers: 2
configs/rec/abinet/svtrv2_abinet_lang.yml ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ device: gpu
3
+ epoch_num: 20
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/rec/u14m_filter/svtrv2_abinet_lang/
7
+ eval_epoch_step: [0, 1]
8
+ eval_batch_step: [0, 500]
9
+ cal_metric_during_train: True
10
+ pretrained_model:
11
+ # ./openocr_svtrv2_nolang_abinet_lang.pth
12
+ checkpoints:
13
+ use_tensorboard: false
14
+ infer_img:
15
+ # for data or label process
16
+ character_dict_path: ./tools/utils/EN_symbol_dict.txt
17
+ max_text_length: 25
18
+ use_space_char: False
19
+ save_res_path: ./output/rec/u14m_filter/predicts_svtrv2_abinet_lang.txt
20
+ use_amp: True
21
+ grad_clip_val: 20
22
+
23
+ Optimizer:
24
+ name: AdamW
25
+ lr: 0.00065 # for 4gpus bs256/gpu
26
+ weight_decay: 0.05
27
+ filter_bias_and_bn: True
28
+
29
+ LRScheduler:
30
+ name: OneCycleLR
31
+ warmup_epoch: 1.5 # pct_start 0.075*20 = 1.5ep
32
+ cycle_momentum: False
33
+
34
+ Architecture:
35
+ model_type: rec
36
+ algorithm: ABINet
37
+ Transform:
38
+ Encoder:
39
+ name: SVTRv2LNConvTwo33
40
+ use_pos_embed: False
41
+ dims: [128, 256, 384]
42
+ depths: [6, 6, 6]
43
+ num_heads: [4, 8, 12]
44
+ mixer: [['Conv','Conv','Conv','Conv','Conv','Conv'],['Conv','Conv','FGlobal','Global','Global','Global'],['Global','Global','Global','Global','Global','Global']]
45
+ local_k: [[5, 5], [5, 5], [-1, -1]]
46
+ sub_k: [[1, 1], [2, 1], [-1, -1]]
47
+ last_stage: false
48
+ feat2d: True
49
+ Decoder:
50
+ name: ABINetDecoder
51
+ iter_size: 3
52
+ num_layers: 0
53
+
54
+ Loss:
55
+ name: ABINetLoss
56
+
57
+ PostProcess:
58
+ name: ABINetLabelDecode
59
+
60
+ Metric:
61
+ name: RecMetric
62
+ main_indicator: acc
63
+ is_filter: True
64
+
65
+ Train:
66
+ dataset:
67
+ name: RatioDataSetTVResize
68
+ ds_width: True
69
+ padding: false
70
+ data_dir_list: ['../Union14M-L-LMDB-Filtered/filter_train_challenging',
71
+ '../Union14M-L-LMDB-Filtered/filter_train_hard',
72
+ '../Union14M-L-LMDB-Filtered/filter_train_medium',
73
+ '../Union14M-L-LMDB-Filtered/filter_train_normal',
74
+ '../Union14M-L-LMDB-Filtered/filter_train_easy',
75
+ ]
76
+ transforms:
77
+ - DecodeImagePIL: # load image
78
+ img_mode: RGB
79
+ - PARSeqAugPIL:
80
+ - ABINetLabelEncode:
81
+ - KeepKeys:
82
+ keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
83
+ sampler:
84
+ name: RatioSampler
85
+ scales: [[128, 32]] # w, h
86
+ # divide_factor: to ensure the width and height dimensions can be devided by downsampling multiple
87
+ first_bs: &bs 256
88
+ fix_bs: false
89
+ divided_factor: [4, 16] # w, h
90
+ is_training: True
91
+ loader:
92
+ shuffle: True
93
+ batch_size_per_card: *bs
94
+ drop_last: True
95
+ max_ratio: &max_ratio 4
96
+ num_workers: 4
97
+
98
+ Eval:
99
+ dataset:
100
+ name: RatioDataSetTVResize
101
+ ds_width: True
102
+ padding: False
103
+ data_dir_list: [
104
+ '../evaluation/CUTE80',
105
+ '../evaluation/IC13_857',
106
+ '../evaluation/IC15_1811',
107
+ '../evaluation/IIIT5k',
108
+ '../evaluation/SVT',
109
+ '../evaluation/SVTP',
110
+ ]
111
+ transforms:
112
+ - DecodeImagePIL: # load image
113
+ img_mode: RGB
114
+ - ABINetLabelEncode:
115
+ - KeepKeys:
116
+ keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
117
+ sampler:
118
+ name: RatioSampler
119
+ scales: [[128, 32]] # w, h
120
+ # divide_factor: to ensure the width and height dimensions can be devided by downsampling multiple
121
+ first_bs: *bs
122
+ fix_bs: false
123
+ divided_factor: [4, 16] # w, h
124
+ is_training: False
125
+ loader:
126
+ shuffle: False
127
+ drop_last: False
128
+ batch_size_per_card: *bs
129
+ max_ratio: *max_ratio
130
+ num_workers: 4
configs/rec/abinet/svtrv2_abinet_wo_lang.yml ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ device: gpu
3
+ epoch_num: 20
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/rec/u14m_filter/svtrv2_abinet_wo_lang/
7
+ eval_epoch_step: [0, 1]
8
+ eval_batch_step: [0, 500]
9
+ cal_metric_during_train: True
10
+ pretrained_model:
11
+ checkpoints:
12
+ use_tensorboard: false
13
+ infer_img:
14
+ # for data or label process
15
+ character_dict_path: ./tools/utils/EN_symbol_dict.txt
16
+ max_text_length: 25
17
+ use_space_char: False
18
+ save_res_path: ./output/rec/u14m_filter/predicts_svtrv2_abinet_wo_lang.txt
19
+ use_amp: True
20
+ grad_clip_val: 20
21
+
22
+ Optimizer:
23
+ name: AdamW
24
+ lr: 0.00065 # for 4gpus bs256/gpu
25
+ weight_decay: 0.05
26
+ filter_bias_and_bn: True
27
+
28
+ LRScheduler:
29
+ name: OneCycleLR
30
+ warmup_epoch: 1.5 # pct_start 0.075*20 = 1.5ep
31
+ cycle_momentum: False
32
+
33
+ Architecture:
34
+ model_type: rec
35
+ algorithm: ABINet
36
+ Transform:
37
+ Encoder:
38
+ name: SVTRv2LNConvTwo33
39
+ use_pos_embed: False
40
+ dims: [128, 256, 384]
41
+ depths: [6, 6, 6]
42
+ num_heads: [4, 8, 12]
43
+ mixer: [['Conv','Conv','Conv','Conv','Conv','Conv'],['Conv','Conv','FGlobal','Global','Global','Global'],['Global','Global','Global','Global','Global','Global']]
44
+ local_k: [[5, 5], [5, 5], [-1, -1]]
45
+ sub_k: [[1, 1], [2, 1], [-1, -1]]
46
+ last_stage: false
47
+ feat2d: True
48
+ Decoder:
49
+ name: ABINetDecoder
50
+ iter_size: 0
51
+ num_layers: 0
52
+ Loss:
53
+ name: ABINetLoss
54
+
55
+ PostProcess:
56
+ name: ABINetLabelDecode
57
+
58
+ Metric:
59
+ name: RecMetric
60
+ main_indicator: acc
61
+ is_filter: True
62
+
63
+ Train:
64
+ dataset:
65
+ name: RatioDataSetTVResize
66
+ ds_width: True
67
+ padding: false
68
+ data_dir_list: ['../Union14M-L-LMDB-Filtered/filter_train_challenging',
69
+ '../Union14M-L-LMDB-Filtered/filter_train_hard',
70
+ '../Union14M-L-LMDB-Filtered/filter_train_medium',
71
+ '../Union14M-L-LMDB-Filtered/filter_train_normal',
72
+ '../Union14M-L-LMDB-Filtered/filter_train_easy',
73
+ ]
74
+ transforms:
75
+ - DecodeImagePIL: # load image
76
+ img_mode: RGB
77
+ - PARSeqAugPIL:
78
+ - ABINetLabelEncode:
79
+ - KeepKeys:
80
+ keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
81
+ sampler:
82
+ name: RatioSampler
83
+ scales: [[128, 32]] # w, h
84
+ # divide_factor: to ensure the width and height dimensions can be devided by downsampling multiple
85
+ first_bs: &bs 256
86
+ fix_bs: false
87
+ divided_factor: [4, 16] # w, h
88
+ is_training: True
89
+ loader:
90
+ shuffle: True
91
+ batch_size_per_card: *bs
92
+ drop_last: True
93
+ max_ratio: &max_ratio 4
94
+ num_workers: 4
95
+
96
+ Eval:
97
+ dataset:
98
+ name: RatioDataSetTVResize
99
+ ds_width: True
100
+ padding: False
101
+ data_dir_list: [
102
+ '../evaluation/CUTE80',
103
+ '../evaluation/IC13_857',
104
+ '../evaluation/IC15_1811',
105
+ '../evaluation/IIIT5k',
106
+ '../evaluation/SVT',
107
+ '../evaluation/SVTP',
108
+ ]
109
+ transforms:
110
+ - DecodeImagePIL: # load image
111
+ img_mode: RGB
112
+ - ABINetLabelEncode:
113
+ - KeepKeys:
114
+ keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
115
+ sampler:
116
+ name: RatioSampler
117
+ scales: [[128, 32]] # w, h
118
+ # divide_factor: to ensure the width and height dimensions can be devided by downsampling multiple
119
+ first_bs: *bs
120
+ fix_bs: false
121
+ divided_factor: [4, 16] # w, h
122
+ is_training: False
123
+ loader:
124
+ shuffle: False
125
+ drop_last: False
126
+ batch_size_per_card: *bs
127
+ max_ratio: *max_ratio
128
+ num_workers: 4
configs/rec/aster/resnet31_lstm_aster_tps_on.yml ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ device: gpu
3
+ epoch_num: 20
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/rec/u14m_filter/resnet31_lstm_aster_tps_on
7
+ eval_epoch_step: [0, 1]
8
+ eval_batch_step: [0, 500]
9
+ cal_metric_during_train: True
10
+ pretrained_model:
11
+ checkpoints:
12
+ use_tensorboard: false
13
+ infer_img:
14
+ # for data or label process
15
+ character_dict_path: ./tools/utils/EN_symbol_dict.txt
16
+ max_text_length: 25
17
+ use_space_char: False
18
+ save_res_path: ./output/rec/predicts_aster_tps.txt
19
+ use_amp: True
20
+ grad_clip_val: 1.0
21
+
22
+ Optimizer:
23
+ name: Adam
24
+ lr: 0.002 # for 1gpus bs1024/gpu
25
+ weight_decay: 0.0
26
+ filter_bias_and_bn: False
27
+
28
+ LRScheduler:
29
+ name: OneCycleLR
30
+ warmup_epoch: 1.5 # pct_start 0.075*20 = 1.5ep
31
+ cycle_momentum: False
32
+
33
+ Architecture:
34
+ model_type: rec
35
+ algorithm: aster
36
+ Transform:
37
+ name: Aster_TPS
38
+ tps_inputsize: [32, 64]
39
+ tps_outputsize: [32, 128]
40
+ Encoder:
41
+ name: ResNet_ASTER
42
+ Decoder:
43
+ name: ASTERDecoder
44
+
45
+ Loss:
46
+ name: ARLoss
47
+
48
+ Metric:
49
+ name: RecMetric
50
+ main_indicator: acc
51
+ is_filter: True
52
+
53
+ PostProcess:
54
+ name: ARLabelDecode
55
+
56
+ Train:
57
+ dataset:
58
+ name: LMDBDataSet
59
+ data_dir: ../Union14M-L-LMDB-Filtered
60
+ transforms:
61
+ - DecodeImagePIL: # load image
62
+ img_mode: RGB
63
+ - PARSeqAugPIL:
64
+ - ARLabelEncode: # Class handling label
65
+ - RecTVResize:
66
+ image_shape: [64, 256]
67
+ padding: False
68
+ - KeepKeys:
69
+ keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
70
+ loader:
71
+ shuffle: True
72
+ batch_size_per_card: 1024
73
+ drop_last: True
74
+ num_workers: 4
75
+
76
+ Eval:
77
+ dataset:
78
+ name: LMDBDataSet
79
+ data_dir: ../evaluation
80
+ transforms:
81
+ - DecodeImagePIL: # load image
82
+ img_mode: RGB
83
+ - ARLabelEncode: # Class handling label
84
+ - RecTVResize:
85
+ image_shape: [64, 256]
86
+ padding: False
87
+ - KeepKeys:
88
+ keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
89
+ loader:
90
+ shuffle: False
91
+ drop_last: False
92
+ batch_size_per_card: 256
93
+ num_workers: 2
configs/rec/aster/svtrv2_aster.yml ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ device: gpu
3
+ epoch_num: 20
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/rec/u14m_filter/svtrv2_aster
7
+ eval_epoch_step: [0, 1]
8
+ eval_batch_step: [0, 500]
9
+ cal_metric_during_train: True
10
+ pretrained_model:
11
+ checkpoints:
12
+ use_tensorboard: false
13
+ infer_img:
14
+ # for data or label process
15
+ character_dict_path: ./tools/utils/EN_symbol_dict.txt
16
+ max_text_length: 25
17
+ use_space_char: False
18
+ save_res_path: ./output/rec/u14m_filter/predicts_svtrv2_aster.txt
19
+ use_amp: True
20
+
21
+ Optimizer:
22
+ name: AdamW
23
+ lr: 0.00065 # for 4gpus bs256/gpu
24
+ weight_decay: 0.05
25
+ filter_bias_and_bn: True
26
+
27
+ LRScheduler:
28
+ name: OneCycleLR
29
+ warmup_epoch: 1.5 # pct_start 0.075*20 = 1.5ep
30
+ cycle_momentum: False
31
+
32
+ Architecture:
33
+ model_type: rec
34
+ algorithm: aster
35
+ Transform:
36
+ Encoder:
37
+ name: SVTRv2LNConvTwo33
38
+ use_pos_embed: False
39
+ out_channels: 256
40
+ dims: [128, 256, 384]
41
+ depths: [6, 6, 6]
42
+ num_heads: [4, 8, 12]
43
+ mixer: [['Conv','Conv','Conv','Conv','Conv','Conv'],['Conv','Conv','FGlobal','Global','Global','Global'],['Global','Global','Global','Global','Global','Global']]
44
+ local_k: [[5, 5], [5, 5], [-1, -1]]
45
+ sub_k: [[1, 1], [2, 1], [-1, -1]]
46
+ last_stage: false
47
+ feat2d: False
48
+ Decoder:
49
+ name: ASTERDecoder
50
+
51
+ Loss:
52
+ name: ARLoss
53
+
54
+ Metric:
55
+ name: RecMetric
56
+ main_indicator: acc
57
+ is_filter: True
58
+
59
+ PostProcess:
60
+ name: ARLabelDecode
61
+
62
+ Train:
63
+ dataset:
64
+ name: RatioDataSetTVResize
65
+ ds_width: True
66
+ padding: false
67
+ data_dir_list: ['../Union14M-L-LMDB-Filtered/filter_train_challenging',
68
+ '../Union14M-L-LMDB-Filtered/filter_train_hard',
69
+ '../Union14M-L-LMDB-Filtered/filter_train_medium',
70
+ '../Union14M-L-LMDB-Filtered/filter_train_normal',
71
+ '../Union14M-L-LMDB-Filtered/filter_train_easy',
72
+ ]
73
+ transforms:
74
+ - DecodeImagePIL: # load image
75
+ img_mode: RGB
76
+ - PARSeqAugPIL:
77
+ - ARLabelEncode: # Class handling label
78
+ - KeepKeys:
79
+ keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
80
+ sampler:
81
+ name: RatioSampler
82
+ scales: [[128, 32]] # w, h
83
+ # divide_factor: to ensure the width and height dimensions can be devided by downsampling multiple
84
+ first_bs: &bs 256
85
+ fix_bs: false
86
+ divided_factor: [4, 16] # w, h
87
+ is_training: True
88
+ loader:
89
+ shuffle: True
90
+ batch_size_per_card: *bs
91
+ drop_last: True
92
+ max_ratio: &max_ratio 4
93
+ num_workers: 4
94
+
95
+ Eval:
96
+ dataset:
97
+ name: RatioDataSetTVResize
98
+ ds_width: True
99
+ padding: False
100
+ data_dir_list: [
101
+ '../evaluation/CUTE80',
102
+ '../evaluation/IC13_857',
103
+ '../evaluation/IC15_1811',
104
+ '../evaluation/IIIT5k',
105
+ '../evaluation/SVT',
106
+ '../evaluation/SVTP',
107
+ ]
108
+ transforms:
109
+ - DecodeImagePIL: # load image
110
+ img_mode: RGB
111
+ - ARLabelEncode: # Class handling label
112
+ - KeepKeys:
113
+ keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
114
+ sampler:
115
+ name: RatioSampler
116
+ scales: [[128, 32]] # w, h
117
+ # divide_factor: to ensure the width and height dimensions can be devided by downsampling multiple
118
+ first_bs: *bs
119
+ fix_bs: false
120
+ divided_factor: [4, 16] # w, h
121
+ is_training: False
122
+ loader:
123
+ shuffle: False
124
+ drop_last: False
125
+ batch_size_per_card: *bs
126
+ max_ratio: *max_ratio
127
+ num_workers: 4
configs/rec/aster/svtrv2_aster_tps_on.yml ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ device: gpu
3
+ epoch_num: 20
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/rec/u14m_filter/svtrv2_aster_tps_on
7
+ eval_epoch_step: [0, 1]
8
+ eval_batch_step: [0, 500]
9
+ cal_metric_during_train: True
10
+ pretrained_model:
11
+ checkpoints:
12
+ use_tensorboard: false
13
+ infer_img:
14
+ # for data or label process
15
+ character_dict_path: ./tools/utils/EN_symbol_dict.txt
16
+ max_text_length: 25
17
+ use_space_char: False
18
+ save_res_path: ./output/rec/u14m_filter/predicts_svtrv2_aster_tps_on.txt
19
+ use_amp: True
20
+
21
+ Optimizer:
22
+ name: AdamW
23
+ lr: 0.00065 # for 4gpus bs256/gpu
24
+ weight_decay: 0.05
25
+ filter_bias_and_bn: True
26
+
27
+ LRScheduler:
28
+ name: OneCycleLR
29
+ warmup_epoch: 1.5 # pct_start 0.075*20 = 1.5ep
30
+ cycle_momentum: False
31
+
32
+ Architecture:
33
+ model_type: rec
34
+ algorithm: aster
35
+ Transform:
36
+ name: Aster_TPS
37
+ tps_inputsize: [32, 64]
38
+ tps_outputsize: [32, 128]
39
+ Encoder:
40
+ name: SVTRv2LNConvTwo33
41
+ use_pos_embed: False
42
+ out_channels: 256
43
+ dims: [128, 256, 384]
44
+ depths: [6, 6, 6]
45
+ num_heads: [4, 8, 12]
46
+ mixer: [['Conv','Conv','Conv','Conv','Conv','Conv'],['Conv','Conv','FGlobal','Global','Global','Global'],['Global','Global','Global','Global','Global','Global']]
47
+ local_k: [[5, 5], [5, 5], [-1, -1]]
48
+ sub_k: [[1, 1], [2, 1], [-1, -1]]
49
+ last_stage: false
50
+ feat2d: False
51
+ Decoder:
52
+ name: ASTERDecoder
53
+
54
+ Loss:
55
+ name: ARLoss
56
+
57
+ Metric:
58
+ name: RecMetric
59
+ main_indicator: acc
60
+ is_filter: True
61
+
62
+ PostProcess:
63
+ name: ARLabelDecode
64
+
65
+ Train:
66
+ dataset:
67
+ name: LMDBDataSet
68
+ data_dir: ../Union14M-L-LMDB-Filtered
69
+ transforms:
70
+ - DecodeImagePIL: # load image
71
+ img_mode: RGB
72
+ - PARSeqAugPIL:
73
+ - ARLabelEncode: # Class handling label
74
+ - RecTVResize:
75
+ image_shape: [64, 256]
76
+ padding: False
77
+ - KeepKeys:
78
+ keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
79
+ loader:
80
+ shuffle: True
81
+ batch_size_per_card: 256
82
+ drop_last: True
83
+ num_workers: 4
84
+
85
+ Eval:
86
+ dataset:
87
+ name: LMDBDataSet
88
+ data_dir: ../evaluation
89
+ transforms:
90
+ - DecodeImagePIL: # load image
91
+ img_mode: RGB
92
+ - ARLabelEncode: # Class handling label
93
+ - RecTVResize:
94
+ image_shape: [64, 256]
95
+ padding: False
96
+ - KeepKeys:
97
+ keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
98
+ loader:
99
+ shuffle: False
100
+ drop_last: False
101
+ batch_size_per_card: 256
102
+ num_workers: 2
configs/rec/autostr/autostr_lstm_aster_tps_on.yml ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ device: gpu
3
+ epoch_num: 20
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/rec/u14m_filter/autostr_lstm_aster_tps_on
7
+ eval_epoch_step: [0, 1]
8
+ eval_batch_step: [0, 500]
9
+ cal_metric_during_train: True
10
+ pretrained_model:
11
+ checkpoints:
12
+ use_tensorboard: false
13
+ infer_img:
14
+ # for data or label process
15
+ character_dict_path: ./tools/utils/EN_symbol_dict.txt
16
+ max_text_length: 25
17
+ use_space_char: False
18
+ save_res_path: ./output/rec/u14m_filter/predicts_autostr_lstm_aster_tps_on.txt
19
+ use_amp: True
20
+ grad_clip_val: 1.0
21
+
22
+ Optimizer:
23
+ name: Adam
24
+ lr: 0.002 # for 4gpus bs256/gpu
25
+ weight_decay: 0.0
26
+ filter_bias_and_bn: False
27
+
28
+ LRScheduler:
29
+ name: OneCycleLR
30
+ warmup_epoch: 1.5 # pct_start 0.075*20 = 1.5ep
31
+ cycle_momentum: False
32
+
33
+ Architecture:
34
+ model_type: rec
35
+ algorithm: autostr
36
+ Transform:
37
+ name: Aster_TPS
38
+ tps_inputsize: [32, 64]
39
+ tps_outputsize: [32, 128]
40
+ Encoder:
41
+ name: AutoSTREncoder
42
+ stride_stages: '[(2, 2), (2, 1), (2, 2), (2, 1), (2, 1)]'
43
+ conv_op_ids: [2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 4, 1, 1, 6, 6]
44
+ Decoder:
45
+ name: ASTERDecoder
46
+
47
+ Loss:
48
+ name: ARLoss
49
+
50
+ Metric:
51
+ name: RecMetric
52
+ main_indicator: acc
53
+ is_filter: True
54
+
55
+ PostProcess:
56
+ name: ARLabelDecode
57
+
58
+ Train:
59
+ dataset:
60
+ name: LMDBDataSet
61
+ data_dir: ../Union14M-L-LMDB-Filtered
62
+ transforms:
63
+ - DecodeImagePIL: # load image
64
+ img_mode: RGB
65
+ - PARSeqAugPIL:
66
+ - ARLabelEncode: # Class handling label
67
+ - RecTVResize:
68
+ image_shape: [64, 256]
69
+ padding: False
70
+ - KeepKeys:
71
+ keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
72
+ loader:
73
+ shuffle: True
74
+ batch_size_per_card: 256
75
+ drop_last: True
76
+ num_workers: 4
77
+
78
+ Eval:
79
+ dataset:
80
+ name: LMDBDataSet
81
+ data_dir: ../evaluation
82
+ transforms:
83
+ - DecodeImagePIL: # load image
84
+ img_mode: RGB
85
+ - ARLabelEncode: # Class handling label
86
+ - RecTVResize:
87
+ image_shape: [64, 256]
88
+ padding: False
89
+ - KeepKeys:
90
+ keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
91
+ loader:
92
+ shuffle: False
93
+ drop_last: False
94
+ batch_size_per_card: 256
95
+ num_workers: 2
configs/rec/busnet/svtrv2_busnet.yml ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ device: gpu
3
+ epoch_num: 10
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/rec/u14m_filter/svtrv2_busnet/
7
+ eval_epoch_step: [0, 1]
8
+ eval_batch_step: [0, 500]
9
+ cal_metric_during_train: True
10
+ pretrained_model:
11
+ # ./output/rec/u14m_filter/svtrv2_busnet_pretraining/best.pth
12
+ checkpoints:
13
+ use_tensorboard: false
14
+ infer_img:
15
+ # for data or label process
16
+ character_dict_path: ./tools/utils/EN_symbol_dict.txt
17
+ max_text_length: 25
18
+ use_space_char: False
19
+ save_res_path: ./output/rec/u14m_filter/predicts_svtrv2_busnet.txt
20
+ use_amp: True
21
+
22
+ Optimizer:
23
+ name: AdamW
24
+ lr: 0.00065 # 4gpus bs256/gpu
25
+ weight_decay: 0.05
26
+ filter_bias_and_bn: True
27
+
28
+ LRScheduler:
29
+ name: OneCycleLR
30
+ warmup_epoch: 1 # pct_start 0.075*20 = 1.5ep
31
+ cycle_momentum: False
32
+
33
+ Architecture:
34
+ model_type: rec
35
+ algorithm: BUSBet
36
+ Transform:
37
+ Encoder:
38
+ name: SVTRv2LNConvTwo33
39
+ use_pos_embed: False
40
+ dims: [128, 256, 384]
41
+ depths: [6, 6, 6]
42
+ num_heads: [4, 8, 12]
43
+ mixer: [['Conv','Conv','Conv','Conv','Conv','Conv'],['Conv','Conv','FGlobal','Global','Global','Global'],['Global','Global','Global','Global','Global','Global']]
44
+ local_k: [[5, 5], [5, 5], [-1, -1]]
45
+ sub_k: [[1, 1], [2, 1], [-1, -1]]
46
+ last_stage: false
47
+ feat2d: False
48
+ Decoder:
49
+ name: BUSDecoder
50
+ nhead: 6
51
+ num_layers: 6
52
+ dim_feedforward: 1536
53
+ ignore_index: &ignore_index 100
54
+ pretraining: False
55
+ # return_id: 2
56
+ Loss:
57
+ name: ABINetLoss
58
+ ignore_index: *ignore_index
59
+
60
+ PostProcess:
61
+ name: ABINetLabelDecode
62
+
63
+ Metric:
64
+ name: RecMetric
65
+ main_indicator: acc
66
+ is_filter: True
67
+
68
+ Train:
69
+ dataset:
70
+ name: RatioDataSetTVResize
71
+ ds_width: True
72
+ padding: false
73
+ data_dir_list: ['../Union14M-L-LMDB-Filtered/filter_train_challenging',
74
+ '../Union14M-L-LMDB-Filtered/filter_train_hard',
75
+ '../Union14M-L-LMDB-Filtered/filter_train_medium',
76
+ '../Union14M-L-LMDB-Filtered/filter_train_normal',
77
+ '../Union14M-L-LMDB-Filtered/filter_train_easy',
78
+ ]
79
+ transforms:
80
+ - DecodeImagePIL: # load image
81
+ img_mode: RGB
82
+ - PARSeqAugPIL:
83
+ - ABINetLabelEncode:
84
+ ignore_index: *ignore_index
85
+ - KeepKeys:
86
+ keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
87
+ sampler:
88
+ name: RatioSampler
89
+ scales: [[128, 32]] # w, h
90
+ # divide_factor: to ensure the width and height dimensions can be devided by downsampling multiple
91
+ first_bs: &bs 256
92
+ fix_bs: false
93
+ divided_factor: [4, 16] # w, h
94
+ is_training: True
95
+ loader:
96
+ shuffle: True
97
+ batch_size_per_card: *bs
98
+ drop_last: True
99
+ max_ratio: &max_ratio 4
100
+ num_workers: 4
101
+
102
+ Eval:
103
+ dataset:
104
+ name: RatioDataSetTVResize
105
+ ds_width: True
106
+ padding: False
107
+ data_dir_list: [
108
+ '../evaluation/CUTE80',
109
+ '../evaluation/IC13_857',
110
+ '../evaluation/IC15_1811',
111
+ '../evaluation/IIIT5k',
112
+ '../evaluation/SVT',
113
+ '../evaluation/SVTP',
114
+ ]
115
+ transforms:
116
+ - DecodeImagePIL: # load image
117
+ img_mode: RGB
118
+ - ABINetLabelEncode:
119
+ ignore_index: *ignore_index
120
+ - KeepKeys:
121
+ keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
122
+ sampler:
123
+ name: RatioSampler
124
+ scales: [[128, 32]] # w, h
125
+ # divide_factor: to ensure the width and height dimensions can be devided by downsampling multiple
126
+ first_bs: *bs
127
+ fix_bs: false
128
+ divided_factor: [4, 16] # w, h
129
+ is_training: False
130
+ loader:
131
+ shuffle: False
132
+ drop_last: False
133
+ batch_size_per_card: *bs
134
+ max_ratio: *max_ratio
135
+ num_workers: 4
configs/rec/busnet/svtrv2_busnet_pretraining.yml ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ device: gpu
3
+ epoch_num: 10
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/rec/u14m_filter/svtrv2_busnet_pretraining/
7
+ eval_epoch_step: [0, 1]
8
+ eval_batch_step: [0, 500]
9
+ cal_metric_during_train: True
10
+ pretrained_model:
11
+ checkpoints:
12
+ use_tensorboard: false
13
+ infer_img:
14
+ # for data or label process
15
+ character_dict_path: ./tools/utils/EN_symbol_dict.txt
16
+ max_text_length: 25
17
+ use_space_char: False
18
+ save_res_path: ./output/rec/u14m_filter/predicts_svtrv2_busnet_pretraining.txt
19
+ use_amp: True
20
+
21
+ Optimizer:
22
+ name: AdamW
23
+ lr: 0.00065 # 4gpus bs256/gpu
24
+ weight_decay: 0.05
25
+ filter_bias_and_bn: True
26
+
27
+ LRScheduler:
28
+ name: OneCycleLR
29
+ warmup_epoch: 1 # pct_start 0.075*20 = 1.5ep
30
+ cycle_momentum: False
31
+
32
+ Architecture:
33
+ model_type: rec
34
+ algorithm: BUSBet
35
+ Transform:
36
+ Encoder:
37
+ name: SVTRv2LNConvTwo33
38
+ use_pos_embed: False
39
+ dims: [128, 256, 384]
40
+ depths: [6, 6, 6]
41
+ num_heads: [4, 8, 12]
42
+ mixer: [['Conv','Conv','Conv','Conv','Conv','Conv'],['Conv','Conv','FGlobal','Global','Global','Global'],['Global','Global','Global','Global','Global','Global']]
43
+ local_k: [[5, 5], [5, 5], [-1, -1]]
44
+ sub_k: [[1, 1], [2, 1], [-1, -1]]
45
+ last_stage: false
46
+ feat2d: False
47
+ Decoder:
48
+ name: BUSDecoder
49
+ nhead: 6
50
+ num_layers: 6
51
+ dim_feedforward: 1536
52
+ ignore_index: &ignore_index 100
53
+ pretraining: True
54
+ # return_id: 0
55
+ Loss:
56
+ name: ABINetLoss
57
+ ignore_index: *ignore_index
58
+
59
+ PostProcess:
60
+ name: ABINetLabelDecode
61
+
62
+ Metric:
63
+ name: RecMetric
64
+ main_indicator: acc
65
+ is_filter: True
66
+
67
+ Train:
68
+ dataset:
69
+ name: RatioDataSetTVResize
70
+ ds_width: True
71
+ padding: false
72
+ data_dir_list: ['../Union14M-L-LMDB-Filtered/filter_train_challenging',
73
+ '../Union14M-L-LMDB-Filtered/filter_train_hard',
74
+ '../Union14M-L-LMDB-Filtered/filter_train_medium',
75
+ '../Union14M-L-LMDB-Filtered/filter_train_normal',
76
+ '../Union14M-L-LMDB-Filtered/filter_train_easy',
77
+ ]
78
+ transforms:
79
+ - DecodeImagePIL: # load image
80
+ img_mode: RGB
81
+ - PARSeqAugPIL:
82
+ - ABINetLabelEncode:
83
+ ignore_index: *ignore_index
84
+ - KeepKeys:
85
+ keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
86
+ sampler:
87
+ name: RatioSampler
88
+ scales: [[128, 32]] # w, h
89
+ # divide_factor: to ensure the width and height dimensions can be devided by downsampling multiple
90
+ first_bs: &bs 256
91
+ fix_bs: false
92
+ divided_factor: [4, 16] # w, h
93
+ is_training: True
94
+ loader:
95
+ shuffle: True
96
+ batch_size_per_card: *bs
97
+ drop_last: True
98
+ max_ratio: &max_ratio 4
99
+ num_workers: 4
100
+
101
+ Eval:
102
+ dataset:
103
+ name: RatioDataSetTVResize
104
+ ds_width: True
105
+ padding: False
106
+ data_dir_list: [
107
+ '../evaluation/CUTE80',
108
+ '../evaluation/IC13_857',
109
+ '../evaluation/IC15_1811',
110
+ '../evaluation/IIIT5k',
111
+ '../evaluation/SVT',
112
+ '../evaluation/SVTP',
113
+ ]
114
+ transforms:
115
+ - DecodeImagePIL: # load image
116
+ img_mode: RGB
117
+ - ABINetLabelEncode:
118
+ ignore_index: *ignore_index
119
+ - KeepKeys:
120
+ keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
121
+ sampler:
122
+ name: RatioSampler
123
+ scales: [[128, 32]] # w, h
124
+ # divide_factor: to ensure the width and height dimensions can be devided by downsampling multiple
125
+ first_bs: *bs
126
+ fix_bs: false
127
+ divided_factor: [4, 16] # w, h
128
+ is_training: False
129
+ loader:
130
+ shuffle: False
131
+ drop_last: False
132
+ batch_size_per_card: *bs
133
+ max_ratio: *max_ratio
134
+ num_workers: 4
configs/rec/busnet/vit_busnet.yml ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ device: gpu
3
+ epoch_num: 10
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/rec/u14m_filter/vit_busnet/
7
+ eval_epoch_step: [0, 1]
8
+ eval_batch_step: [0, 500]
9
+ cal_metric_during_train: True
10
+ pretrained_model:
11
+ checkpoints:
12
+ use_tensorboard: false
13
+ infer_img:
14
+ # for data or label process
15
+ character_dict_path: ./tools/utils/EN_symbol_dict.txt
16
+ max_text_length: 25
17
+ use_space_char: False
18
+ save_res_path: ./output/rec/u14m_filter/predicts_vit_busnet.txt
19
+ grad_clip_val: 20
20
+ use_amp: True
21
+
22
+ Optimizer:
23
+ name: Adam
24
+ lr: 0.00053 # 4gpus bs256/gpu
25
+ weight_decay: 0.0
26
+ filter_bias_and_bn: False
27
+
28
+ LRScheduler:
29
+ name: MultiStepLR
30
+ milestones: [6]
31
+ gamma: 0.1
32
+
33
+ Architecture:
34
+ model_type: rec
35
+ algorithm: BUSBet
36
+ Transform:
37
+ Encoder:
38
+ name: ViT
39
+ img_size: [32,128]
40
+ patch_size: [4, 8]
41
+ embed_dim: 384
42
+ depth: 12
43
+ num_heads: 6
44
+ mlp_ratio: 4
45
+ qkv_bias: True
46
+ Decoder:
47
+ name: BUSDecoder
48
+ nhead: 6
49
+ num_layers: 6
50
+ dim_feedforward: 1536
51
+ ignore_index: &ignore_index 100
52
+ pretraining: False
53
+ Loss:
54
+ name: ABINetLoss
55
+ ignore_index: *ignore_index
56
+
57
+ PostProcess:
58
+ name: ABINetLabelDecode
59
+
60
+ Metric:
61
+ name: RecMetric
62
+ main_indicator: acc
63
+ is_filter: True
64
+
65
+ Train:
66
+ dataset:
67
+ name: LMDBDataSet
68
+ data_dir: ../Union14M-L-LMDB-Filtered
69
+ transforms:
70
+ - DecodeImagePIL: # load image
71
+ img_mode: RGB
72
+ - PARSeqAugPIL:
73
+ - ABINetLabelEncode:
74
+ ignore_index: *ignore_index
75
+ - RecTVResize:
76
+ image_shape: [32, 128]
77
+ padding: False
78
+ - KeepKeys:
79
+ keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
80
+ loader:
81
+ shuffle: True
82
+ batch_size_per_card: 256
83
+ drop_last: True
84
+ num_workers: 4
85
+
86
+ Eval:
87
+ dataset:
88
+ name: LMDBDataSet
89
+ data_dir: ../evaluation
90
+ transforms:
91
+ - DecodeImagePIL: # load image
92
+ img_mode: RGB
93
+ - ABINetLabelEncode:
94
+ ignore_index: *ignore_index
95
+ - RecTVResize:
96
+ image_shape: [32, 128]
97
+ padding: False
98
+ - KeepKeys:
99
+ keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
100
+ loader:
101
+ shuffle: False
102
+ drop_last: False
103
+ batch_size_per_card: 256
104
+ num_workers: 2
configs/rec/busnet/vit_busnet_pretraining.yml ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ device: gpu
3
+ epoch_num: 10
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/rec/u14m_filter/vit_busnet_pretraining/
7
+ eval_epoch_step: [0, 1]
8
+ eval_batch_step: [0, 500]
9
+ cal_metric_during_train: True
10
+ pretrained_model:
11
+ checkpoints:
12
+ use_tensorboard: false
13
+ infer_img:
14
+ # for data or label process
15
+ character_dict_path: ./tools/utils/EN_symbol_dict.txt
16
+ max_text_length: 25
17
+ use_space_char: False
18
+ save_res_path: ./output/rec/u14m_filter/predicts_vit_busnet_pretraining.txt
19
+ grad_clip_val: 20
20
+ use_amp: True
21
+
22
+ Optimizer:
23
+ name: Adam
24
+ lr: 0.00053 # 4gpus bs256/gpu
25
+ weight_decay: 0.0
26
+ filter_bias_and_bn: False
27
+
28
+ LRScheduler:
29
+ name: MultiStepLR
30
+ milestones: [6]
31
+ gamma: 0.1
32
+
33
+ Architecture:
34
+ model_type: rec
35
+ algorithm: BUSBet
36
+ Transform:
37
+ Encoder:
38
+ name: ViT
39
+ img_size: [32,128]
40
+ patch_size: [4, 8]
41
+ embed_dim: 384
42
+ depth: 12
43
+ num_heads: 6
44
+ mlp_ratio: 4
45
+ qkv_bias: True
46
+ Decoder:
47
+ name: BUSDecoder
48
+ nhead: 6
49
+ num_layers: 6
50
+ dim_feedforward: 1536
51
+ ignore_index: &ignore_index 100
52
+ pretraining: True
53
+ Loss:
54
+ name: ABINetLoss
55
+ ignore_index: *ignore_index
56
+
57
+ PostProcess:
58
+ name: ABINetLabelDecode
59
+
60
+ Metric:
61
+ name: RecMetric
62
+ main_indicator: acc
63
+ is_filter: True
64
+
65
+ Train:
66
+ dataset:
67
+ name: LMDBDataSet
68
+ data_dir: ../Union14M-L-LMDB-Filtered
69
+ transforms:
70
+ - DecodeImagePIL: # load image
71
+ img_mode: RGB
72
+ - PARSeqAugPIL:
73
+ - ABINetLabelEncode:
74
+ ignore_index: *ignore_index
75
+ - RecTVResize:
76
+ image_shape: [32, 128]
77
+ padding: False
78
+ - KeepKeys:
79
+ keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
80
+ loader:
81
+ shuffle: True
82
+ batch_size_per_card: 256
83
+ drop_last: True
84
+ num_workers: 4
85
+
86
+ Eval:
87
+ dataset:
88
+ name: LMDBDataSet
89
+ data_dir: ../evaluation
90
+ transforms:
91
+ - DecodeImagePIL: # load image
92
+ img_mode: RGB
93
+ - ABINetLabelEncode:
94
+ ignore_index: *ignore_index
95
+ - RecTVResize:
96
+ image_shape: [32, 128]
97
+ padding: False
98
+ - KeepKeys:
99
+ keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
100
+ loader:
101
+ shuffle: False
102
+ drop_last: False
103
+ batch_size_per_card: 256
104
+ num_workers: 2
configs/rec/cam/convnextv2_cam_tps_on.yml ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ device: gpu
3
+ epoch_num: 20
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/rec/u14m_filter/convnextv2_cam_tps_on
7
+ eval_epoch_step: [0, 1]
8
+ eval_batch_step: [0, 500]
9
+ cal_metric_during_train: False
10
+ pretrained_model:
11
+ checkpoints:
12
+ use_tensorboard: false
13
+ infer_img:
14
+ # for data or label process
15
+ character_dict_path: ./tools/utils/EN_symbol_dict.txt
16
+ max_text_length: &max_text_length 25
17
+ use_space_char: False
18
+ save_res_path: ./output/rec/u14m_filter/predicts_convnextv2_cam_tps_on.txt
19
+ use_amp: True
20
+
21
+ Optimizer:
22
+ name: AdamW
23
+ lr: 0.0008 # for 4gpus bs256/gpu
24
+ weight_decay: 0.05
25
+ filter_bias_and_bn: True
26
+ eps: 1.e-8
27
+
28
+ LRScheduler:
29
+ name: OneCycleLR
30
+ warmup_epoch: 1.5 # pct_start 0.075*20 : 1.5ep
31
+ cycle_momentum: False
32
+
33
+ Architecture:
34
+ model_type: rec
35
+ algorithm: CAM
36
+ Transform:
37
+ name: Aster_TPS
38
+ tps_inputsize: [32, 64]
39
+ tps_outputsize: &img_shape [32, 128]
40
+ Encoder:
41
+ name: CAMEncoder
42
+ encoder_config:
43
+ name: ConvNeXtV2
44
+ depths: [2, 2, 8, 2]
45
+ dims: [80, 160, 320, 640]
46
+ strides: [[4,4], [2,1], [2,1], [1,1]]
47
+ drop_path_rate: 0.2
48
+ feat2d: True
49
+ nb_classes: 97
50
+ strides: [[4,4], [2,1], [2,1], [1,1]]
51
+ deform_stride: 2
52
+ stage_idx: 2
53
+ use_depthwise_unet: True
54
+ use_more_unet: False
55
+ binary_loss_type: BanlanceMultiClassCrossEntropyLoss
56
+ mid_size: True
57
+ d_embedding: 384
58
+ Decoder:
59
+ name: CAMDecoder
60
+ num_encoder_layers: -1
61
+ beam_size: 0
62
+ num_decoder_layers: 2
63
+ nhead: 8
64
+ max_len: *max_text_length
65
+
66
+ Loss:
67
+ name: CAMLoss
68
+ loss_weight_binary: 1.5
69
+ label_smoothing: 0.
70
+
71
+ Metric:
72
+ name: RecMetric
73
+ main_indicator: acc
74
+ is_filter: True
75
+
76
+ PostProcess:
77
+ name: ARLabelDecode
78
+
79
+ Train:
80
+ dataset:
81
+ name: LMDBDataSet
82
+ data_dir: ../Union14M-L-LMDB-Filtered
83
+ transforms:
84
+ - DecodeImagePIL: # load image
85
+ img_mode: RGB
86
+ - PARSeqAugPIL:
87
+ - CAMLabelEncode: # Class handling label
88
+ font_path: ./arial.ttf
89
+ image_shape: *img_shape
90
+ - RecTVResize:
91
+ image_shape: [64, 256]
92
+ padding: False
93
+ - KeepKeys:
94
+ keep_keys: ['image', 'label', 'length', 'binary_mask'] # dataloader will return list in this order
95
+ loader:
96
+ shuffle: True
97
+ batch_size_per_card: 256
98
+ drop_last: True
99
+ num_workers: 4
100
+
101
+ Eval:
102
+ dataset:
103
+ name: LMDBDataSet
104
+ data_dir: ../evaluation
105
+ transforms:
106
+ - DecodeImagePIL: # load image
107
+ img_mode: RGB
108
+ - ARLabelEncode: # Class handling label
109
+ - RecTVResize:
110
+ image_shape: [64, 256]
111
+ padding: False
112
+ - KeepKeys:
113
+ keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
114
+ loader:
115
+ shuffle: False
116
+ drop_last: False
117
+ batch_size_per_card: 256
118
+ num_workers: 2
configs/rec/cam/convnextv2_tiny_cam_tps_on.yml ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ device: gpu
3
+ epoch_num: 20
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/rec/u14m_filter/convnextv2_tiny_cam_tps_on
7
+ eval_epoch_step: [0, 1]
8
+ eval_batch_step: [0, 500]
9
+ cal_metric_during_train: False
10
+ pretrained_model:
11
+ checkpoints:
12
+ use_tensorboard: false
13
+ infer_img:
14
+ # for data or label process
15
+ character_dict_path: ./tools/utils/EN_symbol_dict.txt
16
+ max_text_length: &max_text_length 25
17
+ use_space_char: False
18
+ save_res_path: ./output/rec/u14m_filter/predicts_convnextv2_cam_tps_on.txt
19
+ use_amp: True
20
+
21
+ Optimizer:
22
+ name: AdamW
23
+ lr: 0.0008 # for 4gpus bs256/gpu
24
+ weight_decay: 0.05
25
+ filter_bias_and_bn: True
26
+ eps: 1.e-8
27
+
28
+ LRScheduler:
29
+ name: OneCycleLR
30
+ warmup_epoch: 1.5 # pct_start 0.075*20 : 1.5ep
31
+ cycle_momentum: False
32
+
33
+ Architecture:
34
+ model_type: rec
35
+ algorithm: CAM
36
+ Transform:
37
+ name: Aster_TPS
38
+ tps_inputsize: [32, 64]
39
+ tps_outputsize: &img_shape [32, 128]
40
+ Encoder:
41
+ name: CAMEncoder
42
+ encoder_config:
43
+ name: ConvNeXtV2
44
+ depths: [3, 3, 9, 3]
45
+ dims: [96, 192, 384, 768]
46
+ strides: [[4,4], [2,1], [2,1], [1,1]]
47
+ drop_path_rate: 0.2
48
+ feat2d: True
49
+ nb_classes: 97
50
+ strides: [[4,4], [2,1], [2,1], [1,1]]
51
+ deform_stride: 2
52
+ stage_idx: 2
53
+ use_depthwise_unet: True
54
+ use_more_unet: False
55
+ binary_loss_type: BanlanceMultiClassCrossEntropyLoss
56
+ mid_size: False
57
+ d_embedding: 512
58
+ Decoder:
59
+ name: CAMDecoder
60
+ num_encoder_layers: -1
61
+ beam_size: 0
62
+ num_decoder_layers: 2
63
+ nhead: 8
64
+ max_len: *max_text_length
65
+
66
+ Loss:
67
+ name: CAMLoss
68
+ loss_weight_binary: 1.5
69
+ label_smoothing: 0.
70
+
71
+ Metric:
72
+ name: RecMetric
73
+ main_indicator: acc
74
+ is_filter: True
75
+
76
+ PostProcess:
77
+ name: ARLabelDecode
78
+
79
+ Train:
80
+ dataset:
81
+ name: LMDBDataSet
82
+ data_dir: ../Union14M-L-LMDB-Filtered
83
+ transforms:
84
+ - DecodeImagePIL: # load image
85
+ img_mode: RGB
86
+ - PARSeqAugPIL:
87
+ - CAMLabelEncode: # Class handling label
88
+ font_path: ./arial.ttf
89
+ image_shape: *img_shape
90
+ - RecTVResize:
91
+ image_shape: [64, 256]
92
+ padding: False
93
+ - KeepKeys:
94
+ keep_keys: ['image', 'label', 'length', 'binary_mask'] # dataloader will return list in this order
95
+ loader:
96
+ shuffle: True
97
+ batch_size_per_card: 256
98
+ drop_last: True
99
+ num_workers: 4
100
+
101
+ Eval:
102
+ dataset:
103
+ name: LMDBDataSet
104
+ data_dir: ../evaluation
105
+ transforms:
106
+ - DecodeImagePIL: # load image
107
+ img_mode: RGB
108
+ - ARLabelEncode: # Class handling label
109
+ - RecTVResize:
110
+ image_shape: [64, 256]
111
+ padding: False
112
+ - KeepKeys:
113
+ keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
114
+ loader:
115
+ shuffle: False
116
+ drop_last: False
117
+ batch_size_per_card: 256
118
+ num_workers: 2
configs/rec/cam/svtrv2_cam_tps_on.yml ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ device: gpu
3
+ epoch_num: 20
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/rec/u14m_filter/svtrv2_cam_tps_on
7
+ eval_epoch_step: [0, 1]
8
+ eval_batch_step: [0, 500]
9
+ cal_metric_during_train: False
10
+ pretrained_model:
11
+ checkpoints:
12
+ use_tensorboard: false
13
+ infer_img:
14
+ # for data or label process
15
+ character_dict_path: ./tools/utils/EN_symbol_dict.txt
16
+ max_text_length: &max_text_length 25
17
+ use_space_char: False
18
+ save_res_path: ./output/rec/u14m_filter/predicts_svtrv2_cam_tps_on.txt
19
+ use_amp: True
20
+
21
+ Optimizer:
22
+ name: AdamW
23
+ lr: 0.00065 # for 4gpus bs256/gpu
24
+ weight_decay: 0.05
25
+ filter_bias_and_bn: True
26
+
27
+ LRScheduler:
28
+ name: OneCycleLR
29
+ warmup_epoch: 1.5 # pct_start 0.075*20 : 1.5ep
30
+ cycle_momentum: False
31
+
32
+ Architecture:
33
+ model_type: rec
34
+ algorithm: CAM
35
+ Transform:
36
+ name: Aster_TPS
37
+ tps_inputsize: [32, 64]
38
+ tps_outputsize: &img_shape [32, 128]
39
+ Encoder:
40
+ name: CAMEncoder
41
+ encoder_config:
42
+ name: SVTRv2LNConvTwo33
43
+ use_pos_embed: False
44
+ dims: [128, 256, 384]
45
+ depths: [6, 6, 6]
46
+ num_heads: [4, 8, 12]
47
+ mixer: [['Conv','Conv','Conv','Conv','Conv','Conv'],['Conv','Conv','FGlobal','Global','Global','Global'],['Global','Global','Global','Global','Global','Global']]
48
+ local_k: [[5, 5], [5, 5], [-1, -1]]
49
+ sub_k: [[1, 1], [2, 1], [-1, -1]]
50
+ last_stage: false
51
+ feat2d: True
52
+ nb_classes: 97
53
+ strides: [[4, 4], [1, 1], [2, 1], [1, 1]]
54
+ k_size: [[2, 2], [1, 1], [2, 1], [1, 1]]
55
+ q_size: [4, 32]
56
+ deform_stride: 2
57
+ stage_idx: 2
58
+ use_depthwise_unet: True
59
+ use_more_unet: False
60
+ binary_loss_type: BanlanceMultiClassCrossEntropyLoss
61
+ mid_size: True
62
+ d_embedding: 384
63
+ Decoder:
64
+ name: CAMDecoder
65
+ num_encoder_layers: -1
66
+ beam_size: 0
67
+ num_decoder_layers: 2
68
+ nhead: 8
69
+ max_len: *max_text_length
70
+
71
+ Loss:
72
+ name: CAMLoss
73
+ loss_weight_binary: 1.5
74
+ label_smoothing: 0.
75
+
76
+ Metric:
77
+ name: RecMetric
78
+ main_indicator: acc
79
+ is_filter: True
80
+
81
+ PostProcess:
82
+ name: ARLabelDecode
83
+
84
+ Train:
85
+ dataset:
86
+ name: LMDBDataSet
87
+ data_dir: ../Union14M-L-LMDB-Filtered
88
+ transforms:
89
+ - DecodeImagePIL: # load image
90
+ img_mode: RGB
91
+ - PARSeqAugPIL:
92
+ - CAMLabelEncode: # Class handling label
93
+ font_path: ./arial.ttf
94
+ image_shape: *img_shape
95
+ - RecTVResize:
96
+ image_shape: [64, 256]
97
+ padding: False
98
+ - KeepKeys:
99
+ keep_keys: ['image', 'label', 'length', 'binary_mask'] # dataloader will return list in this order
100
+ loader:
101
+ shuffle: True
102
+ batch_size_per_card: 256
103
+ drop_last: True
104
+ num_workers: 4
105
+
106
+ Eval:
107
+ dataset:
108
+ name: LMDBDataSet
109
+ data_dir: ../evaluation
110
+ transforms:
111
+ - DecodeImagePIL: # load image
112
+ img_mode: RGB
113
+ - ARLabelEncode: # Class handling label
114
+ - RecTVResize:
115
+ image_shape: [64, 256]
116
+ padding: False
117
+ - KeepKeys:
118
+ keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
119
+ loader:
120
+ shuffle: False
121
+ drop_last: False
122
+ batch_size_per_card: 256
123
+ num_workers: 2
configs/rec/cdistnet/resnet45_trans_cdistnet.yml ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ device: gpu
3
+ epoch_num: 20
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/rec/u14m_filter/resnet45_trans_cdistnet
7
+ eval_epoch_step: [0, 1]
8
+ eval_batch_step: [0, 500]
9
+ cal_metric_during_train: True
10
+ pretrained_model:
11
+ checkpoints:
12
+ use_tensorboard: false
13
+ infer_img:
14
+ # for data or label process
15
+ character_dict_path: ./tools/utils/EN_symbol_dict.txt
16
+ max_text_length: 25
17
+ use_space_char: False
18
+ save_res_path: ./output/rec/u14m_filter/predicts_resnet45_trans_cdistnet.txt
19
+ use_amp: True
20
+ grad_clip_val: 5
21
+
22
+ Optimizer:
23
+ name: Adam
24
+ lr: 0.002 # for 4gpus bs256/gpu
25
+ weight_decay: 0.0
26
+ filter_bias_and_bn: False
27
+
28
+ LRScheduler:
29
+ name: OneCycleLR
30
+ warmup_epoch: 1.5 # pct_start 0.075*20 = 1.5ep
31
+ cycle_momentum: False
32
+
33
+ Architecture:
34
+ model_type: rec
35
+ algorithm: CDistNet
36
+ Transform:
37
+ Encoder:
38
+ name: ResNet45
39
+ in_channels: 3
40
+ strides: [2, 1, 2, 1, 1]
41
+ Decoder:
42
+ name: CDistNetDecoder
43
+ add_conv: True
44
+
45
+ Loss:
46
+ name: ARLoss
47
+
48
+ PostProcess:
49
+ name: ARLabelDecode
50
+
51
+ Metric:
52
+ name: RecMetric
53
+ main_indicator: acc
54
+ is_filter: True
55
+
56
+ Train:
57
+ dataset:
58
+ name: LMDBDataSet
59
+ data_dir: ../Union14M-L-LMDB-Filtered
60
+ transforms:
61
+ - DecodeImagePIL: # load image
62
+ img_mode: RGB
63
+ - PARSeqAugPIL:
64
+ - ARLabelEncode: # Class handling label
65
+ - RecTVResize:
66
+ image_shape: [32, 128]
67
+ padding: False
68
+ - KeepKeys:
69
+ keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
70
+ loader:
71
+ shuffle: True
72
+ batch_size_per_card: 256
73
+ drop_last: True
74
+ num_workers: 4
75
+
76
+ Eval:
77
+ dataset:
78
+ name: LMDBDataSet
79
+ data_dir: ../evaluation
80
+ transforms:
81
+ - DecodeImagePIL: # load image
82
+ img_mode: RGB
83
+ - ARLabelEncode: # Class handling label
84
+ - RecTVResize:
85
+ image_shape: [32, 128]
86
+ padding: False
87
+ - KeepKeys:
88
+ keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
89
+ loader:
90
+ shuffle: False
91
+ drop_last: False
92
+ batch_size_per_card: 256
93
+ num_workers: 2
configs/rec/cdistnet/svtrv2_cdistnet.yml ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ device: gpu
3
+ epoch_num: 20
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/rec/u14m_filter/svtrv2_cdistnet/
7
+ eval_epoch_step: [0, 1]
8
+ eval_batch_step: [0, 500]
9
+ cal_metric_during_train: True
10
+ pretrained_model:
11
+ checkpoints:
12
+ use_tensorboard: false
13
+ infer_img:
14
+ # for data or label process
15
+ character_dict_path: &character_dict_path ./tools/utils/EN_symbol_dict.txt # 96en
16
+ # ./tools/utils/ppocr_keys_v1.txt # ch
17
+ max_text_length: &max_text_length 25
18
+ use_space_char: &use_space_char False
19
+ save_res_path: ./output/rec/u14m_filter/predicts_svtrv2_cdistnet.txt
20
+ use_amp: True
21
+
22
+ Optimizer:
23
+ name: AdamW
24
+ lr: 0.00065 #4gpus bs256/gpu
25
+ weight_decay: 0.05
26
+ filter_bias_and_bn: True
27
+
28
+ LRScheduler:
29
+ name: OneCycleLR
30
+ warmup_epoch: 1.5 # pct_start 0.075*20 = 1.5ep
31
+ cycle_momentum: False
32
+
33
+ Architecture:
34
+ model_type: rec
35
+ algorithm: CDistNet
36
+ in_channels: 3
37
+ Transform:
38
+ Encoder:
39
+ name: SVTRv2LNConvTwo33
40
+ use_pos_embed: False
41
+ out_channels: 256
42
+ dims: [128, 256, 384]
43
+ depths: [6, 6, 6]
44
+ num_heads: [4, 8, 12]
45
+ mixer: [['Conv','Conv','Conv','Conv','Conv','Conv'],['Conv','Conv','FGlobal','Global','Global','Global'],['Global','Global','Global','Global','Global','Global']]
46
+ local_k: [[5, 5], [5, 5], [-1, -1]]
47
+ sub_k: [[1, 1], [2, 1], [-1, -1]]
48
+ last_stage: false
49
+ feat2d: True
50
+ Decoder:
51
+ name: CDistNetDecoder
52
+ add_conv: False
53
+ num_encoder_blocks: 0
54
+
55
+ Loss:
56
+ name: ARLoss
57
+
58
+ PostProcess:
59
+ name: ARLabelDecode
60
+ character_dict_path: *character_dict_path
61
+ use_space_char: *use_space_char
62
+
63
+ Metric:
64
+ name: RecMetric
65
+ main_indicator: acc
66
+ is_filter: True
67
+
68
+ Train:
69
+ dataset:
70
+ name: RatioDataSetTVResize
71
+ ds_width: True
72
+ padding: false
73
+ data_dir_list: ['../Union14M-L-LMDB-Filtered/filter_train_challenging',
74
+ '../Union14M-L-LMDB-Filtered/filter_train_hard',
75
+ '../Union14M-L-LMDB-Filtered/filter_train_medium',
76
+ '../Union14M-L-LMDB-Filtered/filter_train_normal',
77
+ '../Union14M-L-LMDB-Filtered/filter_train_easy',
78
+ ]
79
+ transforms:
80
+ - DecodeImagePIL: # load image
81
+ img_mode: RGB
82
+ - PARSeqAugPIL:
83
+ - ARLabelEncode: # Class handling label
84
+ character_dict_path: *character_dict_path
85
+ use_space_char: *use_space_char
86
+ max_text_length: *max_text_length
87
+ - KeepKeys:
88
+ keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
89
+ sampler:
90
+ name: RatioSampler
91
+ scales: [[128, 32]] # w, h
92
+ # divide_factor: to ensure the width and height dimensions can be devided by downsampling multiple
93
+ first_bs: &bs 256
94
+ fix_bs: false
95
+ divided_factor: [4, 16] # w, h
96
+ is_training: True
97
+ loader:
98
+ shuffle: True
99
+ batch_size_per_card: *bs
100
+ drop_last: True
101
+ max_ratio: &max_ratio 4
102
+ num_workers: 4
103
+
104
+ Eval:
105
+ dataset:
106
+ name: RatioDataSetTVResize
107
+ ds_width: True
108
+ padding: False
109
+ data_dir_list: [
110
+ '../evaluation/CUTE80',
111
+ '../evaluation/IC13_857',
112
+ '../evaluation/IC15_1811',
113
+ '../evaluation/IIIT5k',
114
+ '../evaluation/SVT',
115
+ '../evaluation/SVTP',
116
+ ]
117
+ transforms:
118
+ - DecodeImagePIL: # load image
119
+ img_mode: RGB
120
+ - ARLabelEncode: # Class handling label
121
+ character_dict_path: *character_dict_path
122
+ use_space_char: *use_space_char
123
+ max_text_length: *max_text_length
124
+ - KeepKeys:
125
+ keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
126
+ sampler:
127
+ name: RatioSampler
128
+ scales: [[128, 32]] # w, h
129
+ # divide_factor: to ensure the width and height dimensions can be devided by downsampling multiple
130
+ first_bs: *bs
131
+ fix_bs: false
132
+ divided_factor: [4, 16] # w, h
133
+ is_training: False
134
+ loader:
135
+ shuffle: False
136
+ drop_last: False
137
+ batch_size_per_card: *bs
138
+ max_ratio: *max_ratio
139
+ num_workers: 4
configs/rec/cppd/svtr_base_cppd.yml ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ device: gpu
3
+ epoch_num: 20
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/rec/u14m_filter/svtr_base_cppd/
7
+ save_epoch_step: [15, 1]
8
+ # evaluation is run every 2000 iterations
9
+ eval_batch_step: [0, 500]
10
+ eval_epoch_step: [0, 1]
11
+ cal_metric_during_train: True
12
+ pretrained_model:
13
+ checkpoints:
14
+ use_tensorboard: false
15
+ infer_img:
16
+ # for data or label process
17
+ character_dict_path: &character_dict_path
18
+ # ./tools/utils/EN_symbol_dict.txt # 96en
19
+ # ./tools/utils/ppocr_keys_v1.txt # ch
20
+ max_text_length: &max_text_length 25
21
+ use_space_char: &use_space_char False
22
+ save_res_path: ./output/rec/u14m_filter/predicts_svtr_base_cppd.txt
23
+ use_amp: True
24
+
25
+ Optimizer:
26
+ name: AdamW
27
+ lr: 0.00065 # for 4gpus bs256/gpu
28
+ weight_decay: 0.05
29
+ filter_bias_and_bn: True
30
+
31
+ LRScheduler:
32
+ name: OneCycleLR
33
+ warmup_epoch: 1.5 # pct_start 0.075*20 = 1.5ep
34
+ cycle_momentum: False
35
+
36
+ Architecture:
37
+ model_type: rec
38
+ algorithm: CPPD
39
+ in_channels: 3
40
+ Transform:
41
+ Encoder:
42
+ name: SVTRNet
43
+ img_size: [32, 128]
44
+ out_char_num: 25
45
+ out_channels: 256
46
+ patch_merging: 'Conv'
47
+ embed_dim: [128, 256, 384]
48
+ depth: [6, 6, 6]
49
+ num_heads: [4, 8, 12]
50
+ mixer: ['Conv','Conv','Conv','Conv','Conv','Conv', 'Conv','Conv', 'Global','Global','Global','Global','Global','Global','Global','Global','Global','Global']
51
+ local_mixer: [[5, 5], [5, 5], [5, 5]]
52
+ last_stage: False
53
+ prenorm: True
54
+ Decoder:
55
+ name: CPPDDecoder
56
+ vis_seq: 64
57
+ num_layer: 2
58
+ pos_len: False
59
+ rec_layer: 1
60
+
61
+
62
+ Loss:
63
+ name: CPPDLoss
64
+ ignore_index: 100
65
+ smoothing: True
66
+ pos_len: False
67
+ sideloss_weight: 1.0
68
+
69
+ PostProcess:
70
+ name: CPPDLabelDecode
71
+ character_dict_path: *character_dict_path
72
+ use_space_char: *use_space_char
73
+
74
+ Metric:
75
+ name: RecMetric
76
+ main_indicator: acc
77
+
78
+ Train:
79
+ dataset:
80
+ name: LMDBDataSet
81
+ data_dir: ../Union14M-L-LMDB-Filtered
82
+ transforms:
83
+ - DecodeImagePIL: # load image
84
+ img_mode: RGB
85
+ - PARSeqAugPIL:
86
+ - CPPDLabelEncode: # Class handling label
87
+ pos_len: False
88
+ character_dict_path: *character_dict_path
89
+ use_space_char: *use_space_char
90
+ max_text_length: *max_text_length
91
+ - RecTVResize:
92
+ image_shape: [32, 128]
93
+ padding: False
94
+ - KeepKeys:
95
+ keep_keys: ['image', 'label', 'label_node', 'length'] # dataloader will return list in this order
96
+ loader:
97
+ shuffle: True
98
+ batch_size_per_card: 256
99
+ drop_last: True
100
+ num_workers: 4
101
+
102
+ Eval:
103
+ dataset:
104
+ name: LMDBDataSet
105
+ data_dir: ../evaluation/
106
+ transforms:
107
+ - DecodeImagePIL: # load image
108
+ img_mode: RGB
109
+ - CPPDLabelEncode: # Class handling label
110
+ pos_len: False
111
+ character_dict_path: *character_dict_path
112
+ use_space_char: *use_space_char
113
+ max_text_length: *max_text_length
114
+ - RecTVResize:
115
+ image_shape: [32, 128]
116
+ padding: False
117
+ - KeepKeys:
118
+ keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
119
+ loader:
120
+ shuffle: False
121
+ drop_last: False
122
+ batch_size_per_card: 128
123
+ num_workers: 4
configs/rec/cppd/svtr_base_cppd_ch.yml ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ device: gpu
3
+ epoch_num: 100
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/rec/ch/svtr_base_cppd/
7
+ save_epoch_step: [15, 1]
8
+ # evaluation is run every 2000 iterations
9
+ eval_batch_step: [0, 2000]
10
+ eval_epoch_step: [0, 1]
11
+ cal_metric_during_train: False
12
+ pretrained_model:
13
+ checkpoints:
14
+ use_tensorboard: false
15
+ infer_img:
16
+ # for data or label process
17
+ character_dict_path: &character_dict_path ./tools/utils/ppocr_keys_v1.txt
18
+ # ./tools/utils/EN_symbol_dict.txt # 96en
19
+ # ./tools/utils/ppocr_keys_v1.txt # ch
20
+ max_text_length: &max_text_length 25
21
+ use_space_char: &use_space_char False
22
+ save_res_path: ./output/rec/ch/predicts_svtr_base_cppd.txt
23
+ use_amp: True
24
+
25
+ Optimizer:
26
+ name: AdamW
27
+ lr: 0.0005 # for 4gpus bs128/gpu
28
+ weight_decay: 0.05
29
+ filter_bias_and_bn: True
30
+
31
+ LRScheduler:
32
+ name: CosineAnnealingLR
33
+ warmup_epoch: 5
34
+
35
+ Architecture:
36
+ model_type: rec
37
+ algorithm: CPPD
38
+ in_channels: 3
39
+ Transform:
40
+ Encoder:
41
+ name: SVTRNet
42
+ img_size: [32, 256]
43
+ patch_merging: 'Conv'
44
+ embed_dim: [128, 256, 384]
45
+ depth: [6, 6, 4]
46
+ num_heads: [4, 8, 12]
47
+ mixer: ['Conv','Conv','Conv','Conv','Conv','Conv', 'Conv','Conv', 'Global','Global','Global','Global','Global','Global','Global','Global','Global','Global']
48
+ local_mixer: [[5, 5], [5, 5], [5, 5]]
49
+ last_stage: False
50
+ prenorm: True
51
+ Decoder:
52
+ name: CPPDDecoder
53
+ vis_seq: 128
54
+ num_layer: 3
55
+ pos_len: False
56
+ rec_layer: 1
57
+ ch: True
58
+
59
+
60
+ Loss:
61
+ name: CPPDLoss
62
+ ignore_index: 7000
63
+ smoothing: True
64
+ pos_len: False
65
+ sideloss_weight: 1.0
66
+
67
+ PostProcess:
68
+ name: CPPDLabelDecode
69
+ character_dict_path: *character_dict_path
70
+ use_space_char: *use_space_char
71
+
72
+ Metric:
73
+ name: RecMetric
74
+ main_indicator: acc
75
+
76
+ Train:
77
+ dataset:
78
+ name: LMDBDataSet
79
+ data_dir: ../benchmark_bctr/benchmark_bctr_train
80
+ transforms:
81
+ - DecodeImage: # load image
82
+ img_mode: BGR
83
+ channel_first: False
84
+ - CPPDLabelEncode: # Class handling label
85
+ pos_len: False
86
+ ch: True
87
+ ignore_index: 7000
88
+ character_dict_path: *character_dict_path
89
+ use_space_char: *use_space_char
90
+ max_text_length: *max_text_length
91
+ - SVTRResize:
92
+ image_shape: [3, 32, 256]
93
+ padding: True
94
+ - KeepKeys:
95
+ keep_keys: ['image', 'label', 'label_node', 'label_index', 'length'] # dataloader will return list in this order
96
+ loader:
97
+ shuffle: True
98
+ batch_size_per_card: 128
99
+ drop_last: True
100
+ num_workers: 8
101
+
102
+ Eval:
103
+ dataset:
104
+ name: LMDBDataSet
105
+ data_dir: ../benchmark_bctr/benchmark_bctr_test/scene_test
106
+ transforms:
107
+ - DecodeImage: # load image
108
+ img_mode: BGR
109
+ channel_first: False
110
+ - CPPDLabelEncode: # Class handling label
111
+ pos_len: False
112
+ ch: True
113
+ ignore_index: 7000
114
+ character_dict_path: *character_dict_path
115
+ use_space_char: *use_space_char
116
+ max_text_length: *max_text_length
117
+ - SVTRResize:
118
+ image_shape: [3, 32, 256]
119
+ padding: True
120
+ - KeepKeys:
121
+ keep_keys: ['image', 'label', 'label_node', 'length'] # dataloader will return list in this order
122
+ loader:
123
+ shuffle: False
124
+ drop_last: False
125
+ batch_size_per_card: 256
126
+ num_workers: 4
configs/rec/cppd/svtr_base_cppd_h8.yml ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ device: gpu
3
+ epoch_num: 20
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/rec/u14m_filter/svtr_base_h8_cppd/
7
+ save_epoch_step: [15, 1]
8
+ # evaluation is run every 2000 iterations
9
+ eval_batch_step: [0, 500]
10
+ eval_epoch_step: [0, 1]
11
+ cal_metric_during_train: True
12
+ pretrained_model:
13
+ checkpoints:
14
+ use_tensorboard: false
15
+ infer_img:
16
+ # for data or label process
17
+ character_dict_path: &character_dict_path ./tools/utils/EN_symbol_dict.txt # 96en
18
+ # ./tools/utils/ppocr_keys_v1.txt # ch
19
+ max_text_length: &max_text_length 25
20
+ use_space_char: &use_space_char False
21
+ save_res_path: ./output/rec/u14m_filter/predicts_svtr_base_cppd.txt
22
+ use_amp: True
23
+
24
+ Optimizer:
25
+ name: AdamW
26
+ lr: 0.00065 # for 4gpus bs256/gpu
27
+ weight_decay: 0.05
28
+ filter_bias_and_bn: True
29
+
30
+ LRScheduler:
31
+ name: OneCycleLR
32
+ warmup_epoch: 1.5 # pct_start 0.075*20 = 1.5ep
33
+ cycle_momentum: False
34
+
35
+ Architecture:
36
+ model_type: rec
37
+ algorithm: CPPD
38
+ in_channels: 3
39
+ Transform:
40
+ Encoder:
41
+ name: SVTRNet
42
+ img_size: [32, 128]
43
+ out_char_num: 25
44
+ out_channels: 256
45
+ patch_merging: 'Conv'
46
+ embed_dim: [128, 256, 384]
47
+ depth: [6, 6, 6]
48
+ num_heads: [4, 8, 12]
49
+ sub_k: [[1, 1], [2, 1]]
50
+ mixer: ['Conv','Conv','Conv','Conv','Conv','Conv', 'Conv','Conv', 'Global','Global','Global','Global','Global','Global','Global','Global','Global','Global']
51
+ local_mixer: [[5, 5], [5, 5], [5, 5]]
52
+ last_stage: False
53
+ prenorm: True
54
+ Decoder:
55
+ name: CPPDDecoder
56
+ vis_seq: 128
57
+ num_layer: 2
58
+ pos_len: False
59
+ rec_layer: 1
60
+
61
+ Loss:
62
+ name: CPPDLoss
63
+ ignore_index: 100
64
+ smoothing: True
65
+ pos_len: False
66
+ sideloss_weight: 1.0
67
+
68
+ PostProcess:
69
+ name: CPPDLabelDecode
70
+ character_dict_path: *character_dict_path
71
+ use_space_char: *use_space_char
72
+
73
+ Metric:
74
+ name: RecMetric
75
+ main_indicator: acc
76
+ is_filter: True
77
+
78
+ Train:
79
+ dataset:
80
+ name: LMDBDataSet
81
+ data_dir: ../Union14M-L-LMDB-Filtered
82
+ transforms:
83
+ - DecodeImagePIL: # load image
84
+ img_mode: RGB
85
+ - PARSeqAugPIL:
86
+ - CPPDLabelEncode: # Class handling label
87
+ pos_len: False
88
+ character_dict_path: *character_dict_path
89
+ use_space_char: *use_space_char
90
+ max_text_length: *max_text_length
91
+ - RecTVResize:
92
+ image_shape: [32, 128]
93
+ padding: False
94
+ - KeepKeys:
95
+ keep_keys: ['image', 'label', 'label_node', 'length'] # dataloader will return list in this order
96
+ loader:
97
+ shuffle: True
98
+ batch_size_per_card: 256
99
+ drop_last: True
100
+ num_workers: 4
101
+
102
+ Eval:
103
+ dataset:
104
+ name: LMDBDataSet
105
+ data_dir: ../evaluation/
106
+ transforms:
107
+ - DecodeImagePIL: # load image
108
+ img_mode: RGB
109
+ - CPPDLabelEncode: # Class handling label
110
+ pos_len: False
111
+ character_dict_path: *character_dict_path
112
+ use_space_char: *use_space_char
113
+ max_text_length: *max_text_length
114
+ - RecTVResize:
115
+ image_shape: [32, 128]
116
+ padding: False
117
+ - KeepKeys:
118
+ keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
119
+ loader:
120
+ shuffle: False
121
+ drop_last: False
122
+ batch_size_per_card: 128
123
+ num_workers: 4
configs/rec/cppd/svtr_base_cppd_syn.yml ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ device: gpu
3
+ epoch_num: 60
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/rec/syn/svtr_base_cppd/
7
+ save_epoch_step: [15, 1]
8
+ # evaluation is run every 2000 iterations
9
+ eval_batch_step: [0, 500]
10
+ eval_epoch_step: [0, 1]
11
+ cal_metric_during_train: True
12
+ pretrained_model:
13
+ checkpoints:
14
+ use_tensorboard: false
15
+ infer_img:
16
+ # for data or label process
17
+ character_dict_path: &character_dict_path
18
+ # ./tools/utils/EN_symbol_dict.txt # 96en
19
+ # ./tools/utils/ppocr_keys_v1.txt # ch
20
+ max_text_length: &max_text_length 25
21
+ use_space_char: &use_space_char False
22
+ save_res_path: ./output/rec/syn/predicts_svtr_base_cppd.txt
23
+ use_amp: True
24
+
25
+ Optimizer:
26
+ name: AdamW
27
+ lr: 0.0005 # for 4gpus bs256/gpu
28
+ weight_decay: 0.05
29
+ filter_bias_and_bn: True
30
+
31
+ LRScheduler:
32
+ name: CosineAnnealingLR
33
+ warmup_epoch: 6
34
+
35
+ Architecture:
36
+ model_type: rec
37
+ algorithm: CPPD
38
+ in_channels: 3
39
+ Transform:
40
+ Encoder:
41
+ name: SVTRNet
42
+ img_size: [32, 100]
43
+ out_char_num: 25
44
+ out_channels: 256
45
+ patch_merging: 'Conv'
46
+ embed_dim: [128, 256, 384]
47
+ depth: [6, 6, 4]
48
+ num_heads: [4, 8, 12]
49
+ mixer: ['Conv','Conv','Conv','Conv','Conv','Conv', 'Conv','Conv', 'Global','Global','Global','Global','Global','Global','Global','Global','Global','Global']
50
+ local_mixer: [[5, 5], [5, 5], [5, 5]]
51
+ last_stage: False
52
+ prenorm: True
53
+ Decoder:
54
+ name: CPPDDecoder
55
+ vis_seq: 50
56
+ num_layer: 3
57
+ pos_len: False
58
+ rec_layer: 1
59
+
60
+
61
+ Loss:
62
+ name: CPPDLoss
63
+ ignore_index: 100
64
+ smoothing: True
65
+ pos_len: False
66
+ sideloss_weight: 1.0
67
+
68
+ PostProcess:
69
+ name: CPPDLabelDecode
70
+ character_dict_path: *character_dict_path
71
+ use_space_char: *use_space_char
72
+
73
+ Metric:
74
+ name: RecMetric
75
+ main_indicator: acc
76
+
77
+ Train:
78
+ dataset:
79
+ name: STRLMDBDataSet
80
+ data_dir: ./
81
+ transforms:
82
+ - DecodeImage: # load image
83
+ img_mode: BGR
84
+ channel_first: False
85
+ # - SVTRRAug:
86
+ - CPPDLabelEncode: # Class handling label
87
+ pos_len: False
88
+ character_dict_path: *character_dict_path
89
+ use_space_char: *use_space_char
90
+ max_text_length: *max_text_length
91
+ - SVTRResize:
92
+ image_shape: [3, 32, 100]
93
+ padding: False
94
+ - KeepKeys:
95
+ keep_keys: ['image', 'label', 'label_node', 'length'] # dataloader will return list in this order
96
+ loader:
97
+ shuffle: True
98
+ batch_size_per_card: 256
99
+ drop_last: True
100
+ num_workers: 8
101
+
102
+ Eval:
103
+ dataset:
104
+ name: LMDBDataSet
105
+ data_dir: ../evaluation/
106
+ transforms:
107
+ - DecodeImage: # load image
108
+ img_mode: BGR
109
+ channel_first: False
110
+ - CPPDLabelEncode: # Class handling label
111
+ pos_len: False
112
+ character_dict_path: *character_dict_path
113
+ use_space_char: *use_space_char
114
+ max_text_length: *max_text_length
115
+ - SVTRResize:
116
+ image_shape: [3, 32, 100]
117
+ padding: False
118
+ - KeepKeys:
119
+ keep_keys: ['image', 'label', 'label_node', 'length'] # dataloader will return list in this order
120
+ loader:
121
+ shuffle: False
122
+ drop_last: False
123
+ batch_size_per_card: 256
124
+ num_workers: 4
configs/rec/cppd/svtrv2_cppd.yml ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ device: gpu
3
+ epoch_num: 20
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/rec/u14m_filter/svtrv2_cppd/
7
+ save_epoch_step: [15, 1]
8
+ # evaluation is run every 2000 iterations
9
+ eval_batch_step: [0, 500]
10
+ eval_epoch_step: [0, 1]
11
+ cal_metric_during_train: True
12
+ pretrained_model:
13
+ checkpoints:
14
+ use_tensorboard: false
15
+ infer_img:
16
+ # for data or label process
17
+ character_dict_path: &character_dict_path ./tools/utils/EN_symbol_dict.txt # 96en
18
+ # ./tools/utils/ppocr_keys_v1.txt # ch
19
+ max_text_length: &max_text_length 25
20
+ use_space_char: &use_space_char False
21
+ save_res_path: ./output/rec/u14m_filter/predicts_svtrv2_cppd.txt
22
+ use_amp: True
23
+
24
+ Optimizer:
25
+ name: AdamW
26
+ lr: 0.00065 # for 4gpus bs256/gpu
27
+ weight_decay: 0.05
28
+ filter_bias_and_bn: True
29
+
30
+ LRScheduler:
31
+ name: OneCycleLR
32
+ warmup_epoch: 1.5 # pct_start 0.075*20 = 1.5ep
33
+ cycle_momentum: False
34
+
35
+ Architecture:
36
+ model_type: rec
37
+ algorithm: CPPD
38
+ in_channels: 3
39
+ Transform:
40
+ Encoder:
41
+ name: SVTRv2LNConvTwo33
42
+ use_pos_embed: False
43
+ out_channels: 256
44
+ dims: [128, 256, 384]
45
+ depths: [6, 6, 6]
46
+ num_heads: [4, 8, 12]
47
+ mixer: [['Conv','Conv','Conv','Conv','Conv','Conv'],['Conv','Conv','FGlobal','Global','Global','Global'],['Global','Global','Global','Global','Global','Global']]
48
+ local_k: [[5, 5], [5, 5], [-1, -1]]
49
+ sub_k: [[1, 1], [2, 1], [-1, -1]]
50
+ last_stage: false
51
+ feat2d: False
52
+ Decoder:
53
+ name: CPPDDecoder
54
+ ds: True
55
+ num_layer: 2
56
+ pos_len: False
57
+ rec_layer: 1
58
+
59
+
60
+ Loss:
61
+ name: CPPDLoss
62
+ ignore_index: 100
63
+ smoothing: True
64
+ pos_len: False
65
+ sideloss_weight: 1.0
66
+
67
+ PostProcess:
68
+ name: CPPDLabelDecode
69
+ character_dict_path: *character_dict_path
70
+ use_space_char: *use_space_char
71
+
72
+ Metric:
73
+ name: RecMetric
74
+ main_indicator: acc
75
+ is_filter: True
76
+
77
+ Train:
78
+ dataset:
79
+ name: RatioDataSetTVResize
80
+ ds_width: True
81
+ padding: false
82
+ data_dir_list: ['../Union14M-L-LMDB-Filtered/filter_train_challenging',
83
+ '../Union14M-L-LMDB-Filtered/filter_train_hard',
84
+ '../Union14M-L-LMDB-Filtered/filter_train_medium',
85
+ '../Union14M-L-LMDB-Filtered/filter_train_normal',
86
+ '../Union14M-L-LMDB-Filtered/filter_train_easy',
87
+ ]
88
+ transforms:
89
+ - DecodeImagePIL: # load image
90
+ img_mode: RGB
91
+ - PARSeqAugPIL:
92
+ - CPPDLabelEncode: # Class handling label
93
+ pos_len: False
94
+ character_dict_path: *character_dict_path
95
+ use_space_char: *use_space_char
96
+ max_text_length: *max_text_length
97
+ - KeepKeys:
98
+ keep_keys: ['image', 'label', 'label_node', 'length'] # dataloader will return list in this order
99
+ sampler:
100
+ name: RatioSampler
101
+ scales: [[128, 32]] # w, h
102
+ # divide_factor: to ensure the width and height dimensions can be devided by downsampling multiple
103
+ first_bs: &bs 256
104
+ fix_bs: false
105
+ divided_factor: [4, 16] # w, h
106
+ is_training: True
107
+ loader:
108
+ shuffle: True
109
+ batch_size_per_card: *bs
110
+ drop_last: True
111
+ max_ratio: &max_ratio 4
112
+ num_workers: 4
113
+
114
+ Eval:
115
+ dataset:
116
+ name: RatioDataSetTVResize
117
+ ds_width: True
118
+ padding: False
119
+ data_dir_list: [
120
+ '../evaluation/CUTE80',
121
+ '../evaluation/IC13_857',
122
+ '../evaluation/IC15_1811',
123
+ '../evaluation/IIIT5k',
124
+ '../evaluation/SVT',
125
+ '../evaluation/SVTP',
126
+ ]
127
+ transforms:
128
+ - DecodeImagePIL: # load image
129
+ img_mode: RGB
130
+ - CPPDLabelEncode: # Class handling label
131
+ pos_len: False
132
+ character_dict_path: *character_dict_path
133
+ use_space_char: *use_space_char
134
+ max_text_length: *max_text_length
135
+ - KeepKeys:
136
+ keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
137
+ sampler:
138
+ name: RatioSampler
139
+ scales: [[128, 32]] # w, h
140
+ # divide_factor: to ensure the width and height dimensions can be devided by downsampling multiple
141
+ first_bs: *bs
142
+ fix_bs: false
143
+ divided_factor: [4, 16] # w, h
144
+ is_training: False
145
+ loader:
146
+ shuffle: False
147
+ drop_last: False
148
+ batch_size_per_card: *bs
149
+ max_ratio: *max_ratio
150
+ num_workers: 4
configs/rec/dan/resnet45_fpn_dan.yml ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ device: gpu
3
+ epoch_num: 20
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/rec/u14m_filter/resnet45_fpn_dan/
7
+ eval_epoch_step: [0, 1]
8
+ eval_batch_step: [0, 500]
9
+ cal_metric_during_train: True
10
+ pretrained_model:
11
+ checkpoints:
12
+ use_tensorboard: false
13
+ infer_img:
14
+ # for data or label process
15
+ character_dict_path: ./tools/utils/EN_symbol_dict.txt
16
+ max_text_length: 25
17
+ use_space_char: False
18
+ save_res_path: ./output/rec/u14m_filter/predicts_resnet45_fpn_dan.txt
19
+ use_amp: True
20
+ grad_clip_val: 20
21
+
22
+ Optimizer:
23
+ name: Adam
24
+ lr: 0.00065 # for 4gpus bs256/gpu
25
+ weight_decay: 0.0
26
+ filter_bias_and_bn: False
27
+
28
+ LRScheduler:
29
+ name: OneCycleLR
30
+ warmup_epoch: 1.5 # pct_start 0.075*20 = 1.5ep
31
+ cycle_momentum: False
32
+
33
+ Architecture:
34
+ model_type: rec
35
+ algorithm: DAN
36
+ Transform:
37
+ Encoder:
38
+ name: ResNet45
39
+ in_channels: 3
40
+ strides: [2, 1, 2, 1, 1]
41
+ return_list: True
42
+ Decoder:
43
+ name: DANDecoder
44
+ max_len: 25
45
+ channels_list: [64, 128, 256, 512]
46
+ strides_list: [[2, 2], [1, 1], [1, 1]]
47
+ in_shape: [8, 32]
48
+ depth: 4
49
+
50
+ Loss:
51
+ name: ARLoss
52
+
53
+ PostProcess:
54
+ name: ARLabelDecode
55
+
56
+ Metric:
57
+ name: RecMetric
58
+ main_indicator: acc
59
+ is_filter: True
60
+
61
+ Train:
62
+ dataset:
63
+ name: LMDBDataSet
64
+ data_dir: ../Union14M-L-LMDB-Filtered
65
+ transforms:
66
+ - DecodeImagePIL: # load image
67
+ img_mode: RGB
68
+ - PARSeqAugPIL:
69
+ - ARLabelEncode:
70
+ - RecTVResize:
71
+ image_shape: [32, 128]
72
+ padding: False
73
+ - KeepKeys:
74
+ keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
75
+ loader:
76
+ shuffle: True
77
+ batch_size_per_card: 256
78
+ drop_last: True
79
+ num_workers: 4
80
+
81
+ Eval:
82
+ dataset:
83
+ name: LMDBDataSet
84
+ data_dir: ../evaluation
85
+ transforms:
86
+ - DecodeImagePIL: # load image
87
+ img_mode: RGB
88
+ - ARLabelEncode:
89
+ - RecTVResize:
90
+ image_shape: [32, 128]
91
+ padding: False
92
+ - KeepKeys:
93
+ keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
94
+ loader:
95
+ shuffle: False
96
+ drop_last: False
97
+ batch_size_per_card: 256
98
+ num_workers: 2
configs/rec/dan/svtrv2_dan.yml ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ device: gpu
3
+ epoch_num: 20
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/rec/u14m_filter/svtrv2_dan
7
+ eval_epoch_step: [0, 1]
8
+ eval_batch_step: [0, 500]
9
+ cal_metric_during_train: True
10
+ pretrained_model:
11
+ checkpoints:
12
+ use_tensorboard: false
13
+ infer_img:
14
+ # for data or label process
15
+ character_dict_path: ./tools/utils/EN_symbol_dict.txt
16
+ max_text_length: 25
17
+ use_space_char: False
18
+ save_res_path: ./output/rec/u14m_filter/predicts_svtrv2_dan.txt
19
+ use_amp: True
20
+ grad_clip_val: 20
21
+
22
+ Optimizer:
23
+ name: AdamW
24
+ lr: 0.00065 # 4gpus 256bs/gpu
25
+ weight_decay: 0.05
26
+ filter_bias_and_bn: True
27
+
28
+ LRScheduler:
29
+ name: OneCycleLR
30
+ warmup_epoch: 1.5 # pct_start 0.075*20 = 1.5ep
31
+ cycle_momentum: False
32
+
33
+ Architecture:
34
+ model_type: rec
35
+ algorithm: DAN
36
+ Transform:
37
+ Encoder:
38
+ name: SVTRv2LNConvTwo33
39
+ use_pos_embed: False
40
+ out_channels: 256
41
+ dims: [128, 256, 384]
42
+ depths: [6, 6, 6]
43
+ num_heads: [4, 8, 12]
44
+ mixer: [['Conv','Conv','Conv','Conv','Conv','Conv'],['Conv','Conv','FGlobal','Global','Global','Global'],['Global','Global','Global','Global','Global','Global']]
45
+ local_k: [[5, 5], [5, 5], [-1, -1]]
46
+ sub_k: [[1, 1], [2, 1], [-1, -1]]
47
+ last_stage: false
48
+ feat2d: True
49
+ Decoder:
50
+ name: DANDecoder
51
+ use_cam: False
52
+ max_len: 25
53
+
54
+ Loss:
55
+ name: ARLoss
56
+
57
+ PostProcess:
58
+ name: ARLabelDecode
59
+
60
+ Metric:
61
+ name: RecMetric
62
+ main_indicator: acc
63
+ is_filter: True
64
+
65
+ Train:
66
+ dataset:
67
+ name: RatioDataSetTVResize
68
+ ds_width: True
69
+ padding: false
70
+ data_dir_list: ['../Union14M-L-LMDB-Filtered/filter_filter_train_challenging',
71
+ '../Union14M-L-LMDB-Filtered/filter_filter_train_hard',
72
+ '../Union14M-L-LMDB-Filtered/filter_filter_train_medium',
73
+ '../Union14M-L-LMDB-Filtered/filter_filter_train_normal',
74
+ '../Union14M-L-LMDB-Filtered/filter_filter_train_easy',
75
+ ]
76
+ transforms:
77
+ - DecodeImagePIL: # load image
78
+ img_mode: RGB
79
+ - PARSeqAugPIL:
80
+ - ARLabelEncode:
81
+ - KeepKeys:
82
+ keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
83
+ sampler:
84
+ name: RatioSampler
85
+ scales: [[128, 32]] # w, h
86
+ # divide_factor: to ensure the width and height dimensions can be devided by downsampling multiple
87
+ first_bs: &bs 256
88
+ fix_bs: false
89
+ divided_factor: [4, 16] # w, h
90
+ is_training: True
91
+ loader:
92
+ shuffle: True
93
+ batch_size_per_card: *bs
94
+ drop_last: True
95
+ max_ratio: &max_ratio 4
96
+ num_workers: 4
97
+
98
+ Eval:
99
+ dataset:
100
+ name: RatioDataSetTVResize
101
+ ds_width: True
102
+ padding: False
103
+ data_dir_list: [
104
+ '../evaluation/CUTE80',
105
+ '../evaluation/IC13_857',
106
+ '../evaluation/IC15_1811',
107
+ '../evaluation/IIIT5k',
108
+ '../evaluation/SVT',
109
+ '../evaluation/SVTP',
110
+ ]
111
+ transforms:
112
+ - DecodeImagePIL: # load image
113
+ img_mode: RGB
114
+ - ARLabelEncode:
115
+ - KeepKeys:
116
+ keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
117
+ sampler:
118
+ name: RatioSampler
119
+ scales: [[128, 32]] # w, h
120
+ # divide_factor: to ensure the width and height dimensions can be devided by downsampling multiple
121
+ first_bs: *bs
122
+ fix_bs: false
123
+ divided_factor: [4, 16] # w, h
124
+ is_training: False
125
+ loader:
126
+ shuffle: False
127
+ drop_last: False
128
+ batch_size_per_card: *bs
129
+ max_ratio: *max_ratio
130
+ num_workers: 4
configs/rec/dptr/dptr_parseq_pretrain.yml ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ device: gpu
3
+ epoch_num: 20
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: /share/ckpt/zhaoshuai/openocr/dptr_parseq/
7
+ eval_epoch_step: [0, 1]
8
+ eval_batch_step: [0, 500]
9
+ cal_metric_during_train: True
10
+ pretrained_model:
11
+ checkpoints:
12
+ use_tensorboard: false
13
+ infer_img:
14
+ # for data or label process
15
+ character_dict_path: &character_dict_path ./tools/utils/EN_symbol_dict.txt
16
+ max_text_length: &max_text_length 25
17
+ use_space_char: &use_space_char False
18
+ use_amp: True
19
+ save_res_path: /share/ckpt/zhaoshuai/openocr/dptr_parseq/predicts_dptr_parseq.txt
20
+ grad_clip_val: 20
21
+
22
+ Optimizer:
23
+ name: AdamW
24
+ lr: 0.001485 # 2gpus 384bs/gpu
25
+ weight_decay: 0.
26
+ filter_bias_and_bn: False
27
+
28
+ LRScheduler:
29
+ name: OneCycleLR
30
+ warmup_epoch: 1.5 # pct_start 0.075*20 = 1.5ep
31
+ cycle_momentum: False
32
+
33
+ Architecture:
34
+ model_type: rec
35
+ algorithm: DPTR
36
+ Decoder:
37
+ name: DptrParseq
38
+ decode_ar: True
39
+ refine_iters: 1
40
+ is_pretrain: True
41
+ ORP_path: /share/ckpt/zhaoshuai/parseq/clip_background.pth
42
+
43
+ Loss:
44
+ name: PARSeqLoss
45
+
46
+ PostProcess:
47
+ name: ARLabelDecode
48
+ character_dict_path: *character_dict_path
49
+ use_space_char: *use_space_char
50
+
51
+ Metric:
52
+ name: RecMetric
53
+ main_indicator: acc
54
+ is_filter: True
55
+
56
+ Train:
57
+ dataset:
58
+ name: TextLMDBDataSet
59
+ data_dir: /share/test/zhaoshuai/parseq-data/data/train/real/ArT
60
+ transforms:
61
+ - DPTRLabelEncode: # Class handling label
62
+ character_dict_path: *character_dict_path
63
+ use_space_char: *use_space_char
64
+ max_text_length: *max_text_length
65
+ - KeepKeys:
66
+ keep_keys: ['clip_label', 'label'] # dataloader will return list in this order
67
+ loader:
68
+ shuffle: True
69
+ batch_size_per_card: 256
70
+ drop_last: True
71
+ num_workers: 4
72
+
73
+ Eval:
74
+ dataset:
75
+ name: TextLMDBDataSet
76
+ data_dir: /share/test/zhaoshuai/parseq-data/data/val
77
+ transforms:
78
+ - DPTRLabelEncode: # Class handling label
79
+ character_dict_path: *character_dict_path
80
+ use_space_char: *use_space_char
81
+ max_text_length: *max_text_length
82
+ - KeepKeys:
83
+ keep_keys: ['clip_label', 'label'] # dataloader will return list in this order
84
+ loader:
85
+ shuffle: False
86
+ drop_last: False
87
+ batch_size_per_card: 256
88
+ num_workers: 2
configs/rec/focalsvtr/focalsvtr_ctc.yml ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ device: gpu
3
+ epoch_num: 20
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/rec/u14m_filter/focalsvtr_ctc/
7
+ eval_epoch_step: [0, 1]
8
+ eval_batch_step: [0, 500]
9
+ cal_metric_during_train: True
10
+ pretrained_model:
11
+ checkpoints:
12
+ use_tensorboard: false
13
+ infer_img:
14
+ # for data or label process
15
+ character_dict_path: &character_dict_path
16
+ # ./tools/utils/EN_symbol_dict.txt
17
+ max_text_length: &max_text_length 25
18
+ use_space_char: &use_space_char False
19
+ save_res_path: ./output/rec/u14m_filter/predicts_focalsvtr_ctc.txt
20
+
21
+
22
+ Optimizer:
23
+ name: AdamW
24
+ lr: 0.00065 # for 4gpus bs256/gpu
25
+ weight_decay: 0.05
26
+ filter_bias_and_bn: True
27
+
28
+ LRScheduler:
29
+ name: OneCycleLR
30
+
31
+ warmup_epoch: 1.5 # pct_start 0.075*20 = 1.5ep
32
+ cycle_momentum: False
33
+
34
+ Architecture:
35
+ model_type: rec
36
+ algorithm: SVTR
37
+ Transform:
38
+ Encoder:
39
+ name: FocalSVTR
40
+ img_size: [32, 128]
41
+ depths: [6, 6, 6]
42
+ embed_dim: 96
43
+ sub_k: [[1, 1], [2, 1], [1, 1]]
44
+ focal_levels: [3, 3, 3]
45
+ out_channels: 256
46
+ last_stage: True
47
+ Decoder:
48
+ name: CTCDecoder
49
+
50
+ Loss:
51
+ name: CTCLoss
52
+ zero_infinity: True
53
+
54
+ PostProcess:
55
+ name: CTCLabelDecode
56
+ character_dict_path: *character_dict_path
57
+ use_space_char: *use_space_char
58
+
59
+ Metric:
60
+ name: RecMetric
61
+ main_indicator: acc
62
+ is_filter: True
63
+
64
+
65
+ Train:
66
+ dataset:
67
+ name: RatioDataSet
68
+ ds_width: True
69
+ padding: &padding False
70
+ data_dir_list: ['../Union14M-L-LMDB-Filtered/filter_train_challenging',
71
+ '../Union14M-L-LMDB-Filtered/filter_train_hard',
72
+ '../Union14M-L-LMDB-Filtered/filter_train_medium',
73
+ '../Union14M-L-LMDB-Filtered/filter_train_normal',
74
+ '../Union14M-L-LMDB-Filtered/filter_train_easy',
75
+ ]
76
+ transforms:
77
+ - DecodeImage: # load image
78
+ img_mode: BGR
79
+ channel_first: False
80
+ - PARSeqAug:
81
+ - CTCLabelEncode: # Class handling label
82
+ character_dict_path: *character_dict_path
83
+ use_space_char: *use_space_char
84
+ max_text_length: *max_text_length
85
+ - KeepKeys:
86
+ keep_keys: ['image', 'label', 'length']
87
+ sampler:
88
+ name: RatioSampler
89
+ scales: [[128, 32]] # w, h
90
+ # divide_factor: to ensure the width and height dimensions can be devided by downsampling multiple
91
+ first_bs: &bs 256
92
+ fix_bs: false
93
+ divided_factor: [4, 16] # w, h
94
+ is_training: True
95
+ loader:
96
+ shuffle: True
97
+ batch_size_per_card: *bs
98
+ drop_last: True
99
+ max_ratio: 12
100
+ num_workers: 4
101
+
102
+ Eval:
103
+ dataset:
104
+ name: RatioDataSet
105
+ ds_width: True
106
+ padding: True
107
+ data_dir_list: ['../evaluation/CUTE80',
108
+ '../evaluation/IC13_857',
109
+ '../evaluation/IC15_1811',
110
+ '../evaluation/IIIT5k',
111
+ '../evaluation/SVT',
112
+ '../evaluation/SVTP',
113
+ ]
114
+ transforms:
115
+ - DecodeImage: # load image
116
+ img_mode: BGR
117
+ channel_first: False
118
+ - CTCLabelEncode: # Class handling label
119
+ character_dict_path: *character_dict_path
120
+ use_space_char: *use_space_char
121
+ max_text_length: *max_text_length
122
+ - KeepKeys:
123
+ keep_keys: ['image', 'label', 'length']
124
+ sampler:
125
+ name: RatioSampler
126
+ scales: [[128, 32]] # w, h
127
+ # divide_factor: to ensure the width and height dimensions can be devided by downsampling multiple
128
+ first_bs: 128
129
+ fix_bs: false
130
+ divided_factor: [4, 16] # w, h
131
+ is_training: False
132
+ loader:
133
+ shuffle: False
134
+ drop_last: False
135
+ batch_size_per_card: 128
136
+ max_ratio: 12
137
+ num_workers: 4
configs/rec/gtc/svtrv2_lnconv_nrtr_gtc.yml ADDED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ device: gpu
3
+ epoch_num: 20
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/rec/svtrv2_lnconv_nrtr_gtc
7
+ save_epoch_step: [15, 1]
8
+ # evaluation is run every 2000 iterations
9
+ eval_batch_step: [0, 500]
10
+ eval_epoch_step: [0, 1]
11
+ cal_metric_during_train: True
12
+ pretrained_model:
13
+ checkpoints:
14
+ use_tensorboard: false
15
+ infer_img: ../ltb/img
16
+ # for data or label process
17
+ character_dict_path: &character_dict_path ./tools/utils/EN_symbol_dict.txt # 96en
18
+ # ./tools/utils/ppocr_keys_v1.txt # ch
19
+ max_text_length: &max_text_length 25
20
+ use_space_char: &use_space_char False
21
+ save_res_path: ./output/rec/predicts_smtr.txt
22
+ use_amp: True
23
+ distributed: true
24
+
25
+ Optimizer:
26
+ name: AdamW
27
+ lr: 0.00065
28
+ weight_decay: 0.05
29
+ filter_bias_and_bn: True
30
+
31
+ LRScheduler:
32
+ name: OneCycleLR
33
+ warmup_epoch: 1.5 # pct_start 0.075*20 = 1.5ep
34
+ cycle_momentum: False
35
+
36
+ Architecture:
37
+ model_type: rec
38
+ algorithm: BGPD
39
+ in_channels: 3
40
+ Transform:
41
+ Encoder:
42
+ name: SVTRv2LNConvTwo33
43
+ use_pos_embed: False
44
+ out_channels: 256
45
+ dims: [128, 256, 384]
46
+ depths: [6, 6, 6]
47
+ num_heads: [4, 8, 12]
48
+ mixer: [['Conv','Conv','Conv','Conv','Conv','Conv'],['Conv','Conv','FGlobal','Global','Global','Global'],['Global','Global','Global','Global','Global','Global']]
49
+ local_k: [[5, 5], [5, 5], [-1, -1]]
50
+ sub_k: [[1, 1], [2, 1], [-1, -1]]
51
+ last_stage: false
52
+ feat2d: True
53
+ Decoder:
54
+ name: GTCDecoder
55
+ infer_gtc: True
56
+ detach: False
57
+ gtc_decoder:
58
+ name: NRTRDecoder
59
+ num_encoder_layers: -1
60
+ beam_size: 0
61
+ num_decoder_layers: 2
62
+ nhead: 12
63
+ max_len: *max_text_length
64
+ ctc_decoder:
65
+ name: RCTCDecoder
66
+
67
+ Loss:
68
+ name: GTCLoss
69
+ gtc_loss:
70
+ name: ARLoss
71
+
72
+ PostProcess:
73
+ name: GTCLabelDecode
74
+ gtc_label_decode:
75
+ name: ARLabelDecode
76
+ character_dict_path: *character_dict_path
77
+ use_space_char: *use_space_char
78
+
79
+ Metric:
80
+ name: RecGTCMetric
81
+ main_indicator: acc
82
+ is_filter: True
83
+
84
+ Train:
85
+ dataset:
86
+ name: RatioDataSet
87
+ ds_width: True
88
+ # max_ratio: &max_ratio 4
89
+ # min_ratio: 1
90
+ # base_shape: &base_shape [[64, 64], [96, 48], [112, 40], [128, 32]]
91
+ # base_h: &base_h 32
92
+ # padding: &padding False
93
+ padding: false
94
+ # padding_rand: true
95
+ # padding_doub: true
96
+ data_dir_list: ['../Union14M-L-LMDB-Filtered/filter_train_challenging',
97
+ '../Union14M-L-LMDB-Filtered/filter_train_hard',
98
+ '../Union14M-L-LMDB-Filtered/filter_train_medium',
99
+ '../Union14M-L-LMDB-Filtered/filter_train_normal',
100
+ '../Union14M-L-LMDB-Filtered/filter_train_easy',
101
+ ]
102
+ transforms:
103
+ - DecodeImage: # load image
104
+ img_mode: BGR
105
+ channel_first: False
106
+ - PARSeqAug:
107
+ - GTCLabelEncode: # Class handling label
108
+ gtc_label_encode:
109
+ name: ARLabelEncode
110
+ character_dict_path: *character_dict_path
111
+ use_space_char: *use_space_char
112
+ max_text_length: *max_text_length
113
+ - KeepKeys:
114
+ keep_keys: ['image', 'label', 'length', 'ctc_label', 'ctc_length'] # dataloader will return list in this order
115
+ sampler:
116
+ name: RatioSampler
117
+ scales: [[128, 32]] # w, h
118
+ # divide_factor: to ensure the width and height dimensions can be devided by downsampling multiple
119
+ first_bs: &bs 256
120
+ fix_bs: false
121
+ divided_factor: [4, 16] # w, h
122
+ is_training: True
123
+ loader:
124
+ shuffle: True
125
+ batch_size_per_card: *bs
126
+ drop_last: True
127
+ max_ratio: &max_ratio 4
128
+ num_workers: 4
129
+
130
+ Eval:
131
+ dataset:
132
+ name: RatioDataSet
133
+ ds_width: True
134
+ padding: False
135
+ data_dir_list: [
136
+ '../evaluation/CUTE80',
137
+ '../evaluation/IC13_857',
138
+ '../evaluation/IC15_1811',
139
+ '../evaluation/IIIT5k',
140
+ '../evaluation/SVT',
141
+ '../evaluation/SVTP',
142
+ ]
143
+ transforms:
144
+ - DecodeImage: # load image
145
+ img_mode: BGR
146
+ channel_first: False
147
+ - GTCLabelEncode: # Class handling label
148
+ gtc_label_encode:
149
+ name: ARLabelEncode
150
+ character_dict_path: *character_dict_path
151
+ use_space_char: *use_space_char
152
+ max_text_length: *max_text_length
153
+ - KeepKeys:
154
+ keep_keys: ['image', 'label', 'length', 'ctc_label', 'ctc_length'] # dataloader will return list in this order
155
+ sampler:
156
+ name: RatioSampler
157
+ scales: [[128, 32]] # w, h
158
+ # divide_factor: to ensure the width and height dimensions can be devided by downsampling multiple
159
+ first_bs: *bs
160
+ fix_bs: false
161
+ divided_factor: [4, 16] # w, h
162
+ is_training: False
163
+ loader:
164
+ shuffle: False
165
+ drop_last: False
166
+ batch_size_per_card: *bs
167
+ max_ratio: *max_ratio
168
+ num_workers: 4
configs/rec/gtc/svtrv2_lnconv_smtr_gtc_long_infer.yml ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ device: gpu
3
+ epoch_num: 20
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/rec/svtrv2_lnconv_smtr_gtc_long_infer
7
+ save_epoch_step: [15, 1]
8
+ # evaluation is run every 2000 iterations
9
+ eval_batch_step: [0, 1000]
10
+ eval_epoch_step: [0, 1]
11
+ cal_metric_during_train: True
12
+ pretrained_model:
13
+ checkpoints:
14
+ use_tensorboard: false
15
+ infer_img: ../ltb/img
16
+ # for data or label process
17
+ character_dict_path: &character_dict_path ./tools/utils/EN_symbol_dict.txt # 96en
18
+ # ./tools/utils/ppocr_keys_v1.txt # ch
19
+ max_text_length: &max_text_length 25
20
+ use_space_char: &use_space_char False
21
+ save_res_path: ./output/rec/predicts_smtr.txt
22
+ use_amp: True
23
+ distributed: true
24
+
25
+ Optimizer:
26
+ name: AdamW
27
+ lr: 0.000325
28
+ weight_decay: 0.05
29
+ filter_bias_and_bn: True
30
+
31
+ LRScheduler:
32
+ name: OneCycleLR
33
+ warmup_epoch: 1.5 # pct_start 0.075*20 = 1.5ep
34
+ cycle_momentum: False
35
+
36
+ Architecture:
37
+ model_type: rec
38
+ algorithm: BGPD
39
+ in_channels: 3
40
+ Transform:
41
+ Encoder:
42
+ name: SVTRv2LNConvTwo33
43
+ use_pos_embed: False
44
+ out_channels: 256
45
+ dims: [128, 256, 384]
46
+ depths: [6, 6, 6]
47
+ num_heads: [4, 8, 12]
48
+ mixer: [['Conv','Conv','Conv','Conv','Conv','Conv'],['Conv','Conv','FGlobal','Global','Global','Global'],['Global','Global','Global','Global','Global','Global']]
49
+ local_k: [[5, 5], [5, 5], [-1, -1]]
50
+ sub_k: [[1, 1], [2, 1], [-1, -1]]
51
+ last_stage: false
52
+ feat2d: True
53
+ Decoder:
54
+ name: GTCDecoder
55
+ infer_gtc: False
56
+ detach: False
57
+ gtc_decoder:
58
+ name: SMTRDecoder
59
+ num_layer: 1
60
+ ds: True
61
+ max_len: *max_text_length
62
+ next_mode: &next True
63
+ sub_str_len: &subsl 5
64
+ ctc_decoder:
65
+ name: RCTCDecoder
66
+
67
+ Loss:
68
+ name: CTCLoss
69
+
70
+ PostProcess:
71
+ name: CTCLabelDecode
72
+ character_dict_path: *character_dict_path
73
+ use_space_char: *use_space_char
74
+
75
+ Metric:
76
+ name: RecMetric
77
+ main_indicator: acc
78
+ is_filter: True
79
+
80
+ Train:
81
+ dataset:
82
+ name: RatioDataSetTVResize
83
+ ds_width: True
84
+ padding: false
85
+ data_dir_list: ['../Union14M-L-LMDB-Filtered/filter_train_challenging',
86
+ '../Union14M-L-LMDB-Filtered/filter_train_hard',
87
+ '../Union14M-L-LMDB-Filtered/filter_train_medium',
88
+ '../Union14M-L-LMDB-Filtered/filter_train_normal',
89
+ '../Union14M-L-LMDB-Filtered/filter_train_easy',
90
+ ]
91
+ transforms:
92
+ - DecodeImagePIL: # load image
93
+ img_mode: RGB
94
+ - PARSeqAugPIL:
95
+ - CTCLabelEncode: # Class handling label
96
+ character_dict_path: *character_dict_path
97
+ use_space_char: *use_space_char
98
+ max_text_length: *max_text_length
99
+ - KeepKeys:
100
+ keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
101
+ sampler:
102
+ name: RatioSampler
103
+ scales: [[128, 32]] # w, h
104
+ # divide_factor: to ensure the width and height dimensions can be devided by downsampling multiple
105
+ first_bs: &bs 128
106
+ fix_bs: false
107
+ divided_factor: [4, 16] # w, h
108
+ is_training: True
109
+ loader:
110
+ shuffle: True
111
+ batch_size_per_card: *bs
112
+ drop_last: True
113
+ max_ratio: &max_ratio 12
114
+ num_workers: 4
115
+
116
+ Eval:
117
+ dataset:
118
+ name: RatioDataSetTVResize
119
+ ds_width: True
120
+ padding: False
121
+ data_dir_list: [
122
+ '../evaluation/CUTE80',
123
+ '../evaluation/IC13_857',
124
+ '../evaluation/IC15_1811',
125
+ '../evaluation/IIIT5k',
126
+ '../evaluation/SVT',
127
+ '../evaluation/SVTP',
128
+ ]
129
+ transforms:
130
+ - DecodeImagePIL: # load image
131
+ img_mode: RGB
132
+ - CTCLabelEncode: # Class handling label
133
+ character_dict_path: *character_dict_path
134
+ use_space_char: *use_space_char
135
+ max_text_length: *max_text_length
136
+ - KeepKeys:
137
+ keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order
138
+ sampler:
139
+ name: RatioSampler
140
+ scales: [[128, 32]] # w, h
141
+ # divide_factor: to ensure the width and height dimensions can be devided by downsampling multiple
142
+ first_bs: *bs
143
+ fix_bs: false
144
+ divided_factor: [4, 16] # w, h
145
+ is_training: False
146
+ loader:
147
+ shuffle: False
148
+ drop_last: False
149
+ batch_size_per_card: *bs
150
+ max_ratio: *max_ratio
151
+ num_workers: 4
configs/rec/gtc/svtrv2_lnconv_smtr_gtc_smtr_long.yml ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ device: gpu
3
+ epoch_num: 20
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/rec/svtrv2_lnconv_smtr_gtc_nodetach_smtr_long_infer
7
+ save_epoch_step: [15, 1]
8
+ # evaluation is run every 2000 iterations
9
+ eval_batch_step: [0, 1000]
10
+ eval_epoch_step: [0, 1]
11
+ cal_metric_during_train: True
12
+ pretrained_model:
13
+ checkpoints:
14
+ use_tensorboard: false
15
+ infer_img:
16
+ # for data or label process
17
+ character_dict_path: &character_dict_path ./tools/utils/EN_symbol_dict.txt # 96en
18
+ # ./tools/utils/ppocr_keys_v1.txt # ch
19
+ max_text_length: &max_text_length 25
20
+ use_space_char: &use_space_char False
21
+ save_res_path: ./output/rec/predicts_smtr.txt
22
+ use_amp: True
23
+ distributed: true
24
+
25
+ Optimizer:
26
+ name: AdamW
27
+ lr: 0.000325
28
+ weight_decay: 0.05
29
+ filter_bias_and_bn: True
30
+
31
+ LRScheduler:
32
+ name: OneCycleLR
33
+ warmup_epoch: 1.5 # pct_start 0.075*20 = 1.5ep
34
+ cycle_momentum: False
35
+ Architecture:
36
+ model_type: rec
37
+ algorithm: BGPD
38
+ in_channels: 3
39
+ Transform:
40
+ Encoder:
41
+ name: SVTRv2LNConvTwo33
42
+ use_pos_embed: False
43
+ out_channels: 256
44
+ dims: [128, 256, 384]
45
+ depths: [6, 6, 6]
46
+ num_heads: [4, 8, 12]
47
+ mixer: [['Conv','Conv','Conv','Conv','Conv','Conv'],['Conv','Conv','FGlobal','Global','Global','Global'],['Global','Global','Global','Global','Global','Global']]
48
+ local_k: [[5, 5], [5, 5], [-1, -1]]
49
+ sub_k: [[1, 1], [2, 1], [-1, -1]]
50
+ last_stage: false
51
+ feat2d: True
52
+ Decoder:
53
+ name: GTCDecoder
54
+ infer_gtc: True
55
+ detach: False
56
+ gtc_decoder:
57
+ name: SMTRDecoder
58
+ num_layer: 1
59
+ ds: True
60
+ max_len: *max_text_length
61
+ next_mode: &next True
62
+ sub_str_len: &subsl 5
63
+ infer_aug: True
64
+ ctc_decoder:
65
+ name: RCTCDecoder
66
+
67
+ Loss:
68
+ name: GTCLoss
69
+ ctc_weight: 0.1
70
+ gtc_loss:
71
+ name: SMTRLoss
72
+
73
+ PostProcess:
74
+ name: GTCLabelDecode
75
+ gtc_label_decode:
76
+ name: SMTRLabelDecode
77
+ next_mode: *next
78
+ character_dict_path: *character_dict_path
79
+ use_space_char: *use_space_char
80
+ only_gtc: True
81
+
82
+ Metric:
83
+ name: RecGTCMetric
84
+ main_indicator: acc
85
+ is_filter: True
86
+
87
+ Train:
88
+ dataset:
89
+ name: RatioDataSetTVResize
90
+ ds_width: True
91
+ padding: false
92
+ data_dir_list: ['../Union14M-L-LMDB-Filtered/filter_train_challenging',
93
+ '../Union14M-L-LMDB-Filtered/filter_train_hard',
94
+ '../Union14M-L-LMDB-Filtered/filter_train_medium',
95
+ '../Union14M-L-LMDB-Filtered/filter_train_normal',
96
+ '../Union14M-L-LMDB-Filtered/filter_train_easy',
97
+ ]
98
+ transforms:
99
+ - DecodeImagePIL: # load image
100
+ img_mode: RGB
101
+ - PARSeqAugPIL:
102
+ - SMTRLabelEncode: # Class handling label
103
+ sub_str_len: *subsl
104
+ character_dict_path: *character_dict_path
105
+ use_space_char: *use_space_char
106
+ max_text_length: *max_text_length
107
+ - KeepKeys:
108
+ keep_keys: ['image', 'label', 'label_subs', 'label_next', 'length_subs',
109
+ 'label_subs_pre', 'label_next_pre', 'length_subs_pre', 'length'] # dataloader will return list in this order
110
+ sampler:
111
+ name: RatioSampler
112
+ scales: [[128, 32]] # w, h
113
+ # divide_factor: to ensure the width and height dimensions can be devided by downsampling multiple
114
+ first_bs: &bs 256
115
+ fix_bs: false
116
+ divided_factor: [4, 16] # w, h
117
+ is_training: True
118
+ loader:
119
+ shuffle: True
120
+ batch_size_per_card: *bs
121
+ drop_last: True
122
+ max_ratio: &max_ratio 12
123
+ num_workers: 4
124
+
125
+ Eval:
126
+ dataset:
127
+ name: SimpleDataSet
128
+ data_dir: ../ltb/
129
+ label_file_list: ['../ltb/ultra_long_70_list.txt']
130
+ transforms:
131
+ - DecodeImage: # load image
132
+ img_mode: BGR
133
+ channel_first: False
134
+ - GTCLabelEncode: # Class handling label
135
+ gtc_label_encode:
136
+ name: ARLabelEncode
137
+ character_dict_path: *character_dict_path
138
+ use_space_char: *use_space_char
139
+ max_text_length: 200
140
+ - SliceResize:
141
+ image_shape: [3, 32, 128]
142
+ padding: False
143
+ max_ratio: 12
144
+ - KeepKeys:
145
+ keep_keys: ['image', 'label', 'length', 'ctc_label', 'ctc_length'] # dataloader will return list in this order
146
+ loader:
147
+ shuffle: False
148
+ drop_last: False
149
+ batch_size_per_card: 1
150
+ num_workers: 2
configs/rec/gtc/svtrv2_lnconv_smtr_gtc_stream.yml ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Global:
2
+ device: gpu
3
+ epoch_num: 60
4
+ log_smooth_window: 20
5
+ print_batch_step: 10
6
+ output_dir: ./output/rec/svtrv2_lnconv_smtr_gtc_stream
7
+ save_epoch_step: [15, 1]
8
+ # evaluation is run every 2000 iterations
9
+ eval_batch_step: [0, 500]
10
+ eval_epoch_step: [0, 1]
11
+ cal_metric_during_train: True
12
+ pretrained_model:
13
+ checkpoints:
14
+ use_tensorboard: false
15
+ infer_img:
16
+ # for data or label process
17
+ character_dict_path: &character_dict_path ./tools/utils/EN_symbol_dict.txt # 96en
18
+ # ./tools/utils/ppocr_keys_v1.txt # ch
19
+ max_text_length: &max_text_length 25
20
+ use_space_char: &use_space_char False
21
+ save_res_path: ./output/rec/predicts_smtr.txt
22
+ use_amp: True
23
+ distributed: true
24
+ grad_clip_val: 20
25
+
26
+ Optimizer:
27
+ name: AdamW
28
+ lr: 0.00065
29
+ weight_decay: 0.05
30
+ filter_bias_and_bn: True
31
+
32
+ LRScheduler:
33
+ name: OneCycleLR
34
+ warmup_epoch: 5 # pct_start 0.075*20 = 1.5ep
35
+ cycle_momentum: False
36
+
37
+ Architecture:
38
+ model_type: rec
39
+ algorithm: BGPD
40
+ in_channels: 3
41
+ Transform:
42
+ Encoder:
43
+ name: SVTRv2LNConvTwo33
44
+ use_pos_embed: False
45
+ out_channels: 256
46
+ dims: [128, 256, 384]
47
+ depths: [6, 6, 6]
48
+ num_heads: [4, 8, 12]
49
+ mixer: [['Conv','Conv','Conv','Conv','Conv','Conv'],['Conv','Conv','FGlobal','Global','Global','Global'],['Global','Global','Global','Global','Global','Global']]
50
+ local_k: [[5, 5], [5, 5], [-1, -1]]
51
+ sub_k: [[1, 1], [2, 1], [-1, -1]]
52
+ last_stage: false
53
+ feat2d: True
54
+ Decoder:
55
+ name: GTCDecoder
56
+ infer_gtc: True
57
+ detach: False
58
+ gtc_decoder:
59
+ name: SMTRDecoder
60
+ num_layer: 1
61
+ ds: True
62
+ max_len: *max_text_length
63
+ next_mode: &next True
64
+ sub_str_len: &subsl 5
65
+ infer_aug: False
66
+ ctc_decoder:
67
+ name: RCTCDecoder
68
+
69
+ Loss:
70
+ name: GTCLoss
71
+ ctc_weight: 0.25
72
+ gtc_loss:
73
+ name: SMTRLoss
74
+
75
+ PostProcess:
76
+ name: GTCLabelDecode
77
+ gtc_label_decode:
78
+ name: SMTRLabelDecode
79
+ next_mode: *next
80
+ character_dict_path: *character_dict_path
81
+ use_space_char: *use_space_char
82
+ only_gtc: True
83
+
84
+ Metric:
85
+ name: RecMetric
86
+ main_indicator: acc
87
+ is_filter: True
88
+ stream: True
89
+
90
+ Train:
91
+ dataset:
92
+ name: RatioDataSetTVResize
93
+ ds_width: True
94
+ padding: false
95
+ data_dir_list: ['../Union14M-L-LMDB-Filtered/filter_train_challenging',
96
+ '../Union14M-L-LMDB-Filtered/filter_train_hard',
97
+ '../Union14M-L-LMDB-Filtered/filter_train_medium',
98
+ '../Union14M-L-LMDB-Filtered/filter_train_normal',
99
+ '../Union14M-L-LMDB-Filtered/filter_train_easy',
100
+ ]
101
+ transforms:
102
+ - DecodeImagePIL: # load image
103
+ img_mode: RGB
104
+ - PARSeqAugPIL:
105
+ - SMTRLabelEncode: # Class handling label
106
+ sub_str_len: *subsl
107
+ character_dict_path: *character_dict_path
108
+ use_space_char: *use_space_char
109
+ max_text_length: *max_text_length
110
+ - KeepKeys:
111
+ keep_keys: ['image', 'label', 'label_subs', 'label_next', 'length_subs',
112
+ 'label_subs_pre', 'label_next_pre', 'length_subs_pre', 'length'] # dataloader will return list in this order
113
+ sampler:
114
+ name: RatioSampler
115
+ scales: [[128, 32]] # w, h
116
+ # divide_factor: to ensure the width and height dimensions can be devided by downsampling multiple
117
+ first_bs: &bs 256
118
+ fix_bs: false
119
+ divided_factor: [4, 16] # w, h
120
+ is_training: True
121
+ loader:
122
+ shuffle: True
123
+ batch_size_per_card: *bs
124
+ drop_last: True
125
+ max_ratio: &max_ratio 12
126
+ num_workers: 4
127
+
128
+ Eval:
129
+ dataset:
130
+ name: SimpleDataSet
131
+ data_dir: ../ltb/
132
+ label_file_list: ['../ltb/ultra_long_70_list.txt']
133
+ transforms:
134
+ - DecodeImagePIL: # load image
135
+ img_mode: RGB
136
+ - GTCLabelEncode: # Class handling label
137
+ gtc_label_encode:
138
+ name: ARLabelEncode
139
+ character_dict_path: *character_dict_path
140
+ use_space_char: *use_space_char
141
+ max_text_length: *max_text_length
142
+ - SliceTVResize:
143
+ image_shape: [32, 128]
144
+ padding: False
145
+ max_ratio: 4
146
+ - KeepKeys:
147
+ keep_keys: ['image', 'label', 'length', 'ctc_label', 'ctc_length'] # dataloader will return list in this order
148
+ loader:
149
+ shuffle: False
150
+ drop_last: False
151
+ batch_size_per_card: 1
152
+ num_workers: 2
configs/rec/igtr/readme.md ADDED
@@ -0,0 +1,192 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # IGTR
2
+
3
+ - [IGTR](#igtr)
4
+ - [1. Introduction](#1-introduction)
5
+ - [2. Environment](#2-environment)
6
+ - [Dataset Preparation](#dataset-preparation)
7
+ - [3. Model Training / Evaluation](#3-model-training--evaluation)
8
+ - [Citation](#citation)
9
+
10
+ <a name="1"></a>
11
+
12
+ ## 1. Introduction
13
+
14
+ Paper:
15
+
16
+ > [Instruction-Guided Scene Text Recognition](https://arxiv.org/abs/2401.17851),
17
+ > Yongkun Du, Zhineng Chen, Yuchen Su, Caiyan Jia, Yu-Gang Jiang,
18
+ > TPAMI
19
+
20
+ <a name="model"></a>
21
+ Multi-modal models have shown appealing performance in visual recognition tasks, as free-form text-guided training evokes the ability to understand fine-grained visual content. However, current models cannot be trivially applied to scene text recognition (STR) due to the compositional difference between natural and text images. We propose a novel instruction-guided scene text recognition (IGTR) paradigm that formulates STR as an instruction learning problem and understands text images by predicting character attributes, e.g., character frequency, position, etc. IGTR first devises $\\left \\langle condition,question,answer\\right \\rangle$ instruction triplets, providing rich and diverse descriptions of character attributes. To effectively learn these attributes through question-answering, IGTR develops a lightweight instruction encoder, a cross-modal feature fusion module and a multi-task answer head, which guides nuanced text image understanding. Furthermore, IGTR realizes different recognition pipelines simply by using different instructions, enabling a character-understanding-based text reasoning paradigm that differs from current methods considerably. Experiments on English and Chinese benchmarks show that IGTR outperforms existing models by significant margins, while maintaining a small model size and fast inference speed. Moreover, by adjusting the sampling of instructions, IGTR offers an elegant way to tackle the recognition of rarely appearing and morphologically similar characters, which were previous challenges.
22
+
23
+ <a name="model"></a>
24
+ The accuracy (%) and model files of IGTR on the public dataset of scene text recognition are as follows:
25
+
26
+ - Trained on Synth dataset(MJ+ST), test on Common Benchmarks, training and test datasets both from [PARSeq](https://github.com/baudm/parseq).
27
+
28
+ | Model | IC13<br/>857 | SVT | IIIT5k<br/>3000 | IC15<br/>1811 | SVTP | CUTE80 | Avg | Config&Model&Log |
29
+ | :-----: | :----------: | :--: | :-------------: | :-----------: | :--: | :----: | :---: | :---------------------------------------------------------------------------------------------: |
30
+ | IGTR-PD | 97.6 | 95.2 | 97.6 | 88.4 | 91.6 | 95.5 | 94.30 | [link](https://drive.google.com/drive/folders/1Pv0CW2hiWC_dIyaB74W1fsXqiX3z5yXA?usp=drive_link) |
31
+ | IGTR-AR | 98.6 | 95.7 | 98.2 | 88.4 | 92.4 | 95.5 | 94.78 | as above |
32
+
33
+ - Test on Union14M-L benchmark, from [Union14M](https://github.com/Mountchicken/Union14M/).
34
+
35
+ | Model | Curve | Multi-<br/>Oriented | Artistic | Contextless | Salient | Multi-<br/>word | General | Avg | Config&Model&Log |
36
+ | :-----: | :---: | :-----------------: | :------: | :---------: | :-----: | :-------------: | :-----: | :---: | :---------------------: |
37
+ | IGTR-PD | 76.9 | 30.6 | 59.1 | 63.3 | 77.8 | 62.5 | 66.7 | 62.40 | Same as the above table |
38
+ | IGTR-AR | 78.4 | 31.9 | 61.3 | 66.5 | 80.2 | 69.3 | 67.9 | 65.07 | as above |
39
+
40
+ - Trained on Union14M-L training dataset.
41
+
42
+ | Model | IC13<br/>857 | SVT | IIIT5k<br/>3000 | IC15<br/>1811 | SVTP | CUTE80 | Avg | Config&Model&Log |
43
+ | :----------: | :----------: | :--: | :-------------: | :-----------: | :--: | :----: | :---: | :---------------------------------------------------------------------------------------------: |
44
+ | IGTR-PD | 97.7 | 97.7 | 98.3 | 89.8 | 93.7 | 97.9 | 95.86 | [link](https://drive.google.com/drive/folders/1ZGlzDqEzjrBg8qG2wBkbOm3bLRzFbTzo?usp=drive_link) |
45
+ | IGTR-AR | 98.1 | 98.4 | 98.7 | 90.5 | 94.9 | 98.3 | 96.48 | as above |
46
+ | IGTR-PD-60ep | 97.9 | 98.3 | 99.2 | 90.8 | 93.7 | 97.6 | 96.24 | [link](https://drive.google.com/drive/folders/1ik4hxZDRsjU1RbCA19nwE45Kg1bCnMoa?usp=drive_link) |
47
+ | IGTR-AR-60ep | 98.4 | 98.1 | 99.3 | 91.5 | 94.3 | 97.6 | 96.54 | as above |
48
+ | IGTR-PD-PT | 98.6 | 98.0 | 99.1 | 91.7 | 96.8 | 99.0 | 97.20 | [link](https://drive.google.com/drive/folders/1QM0EWV66IfYI1G0Xm066V2zJA62hH6-1?usp=drive_link) |
49
+ | IGTR-AR-PT | 98.8 | 98.3 | 99.2 | 92.0 | 96.8 | 99.0 | 97.34 | as above |
50
+
51
+ | Model | Curve | Multi-<br/>Oriented | Artistic | Contextless | Salient | Multi-<br/>word | General | Avg | Config&Model&Log |
52
+ | :----------: | :---: | :-----------------: | :------: | :---------: | :-----: | :-------------: | :-----: | :---: | :---------------------: |
53
+ | IGTR-PD | 88.1 | 89.9 | 74.2 | 80.3 | 82.8 | 79.2 | 83.0 | 82.51 | Same as the above table |
54
+ | IGTR-AR | 90.4 | 91.2 | 77.0 | 82.4 | 84.7 | 84.0 | 84.4 | 84.86 | as above |
55
+ | IGTR-PD-60ep | 90.0 | 92.1 | 77.5 | 82.8 | 86.0 | 83.0 | 84.8 | 85.18 | Same as the above table |
56
+ | IGTR-AR-60ep | 91.0 | 93.0 | 78.7 | 84.6 | 87.3 | 84.8 | 85.6 | 86.43 | as above |
57
+ | IGTR-PD-PT | 92.4 | 92.1 | 80.7 | 83.6 | 87.7 | 86.9 | 85.0 | 86.92 | Same as the above table |
58
+ | IGTR-AR-PT | 93.0 | 92.9 | 81.3 | 83.4 | 88.6 | 88.7 | 85.6 | 87.65 | as above |
59
+
60
+ - Trained and test on Chinese dataset, from [Chinese Benckmark](https://github.com/FudanVI/benchmarking-chinese-text-recognition).
61
+
62
+ | Model | Scene | Web | Document | Handwriting | Avg | Config&Model&Log |
63
+ | :---------: | :---: | :--: | :------: | :---------: | :---: | :---------------------------------------------------------------------------------------------: |
64
+ | IGTR-PD | 73.1 | 74.8 | 98.6 | 52.5 | 74.75 | |
65
+ | IGTR-AR | 75.1 | 76.4 | 98.7 | 55.3 | 76.37 | |
66
+ | IGTR-PD-TS | 73.5 | 75.9 | 98.7 | 54.5 | 75.65 | [link](https://drive.google.com/drive/folders/1H3VRdGHjhawd6fkSC-qlBzVzvYYTpHRg?usp=drive_link) |
67
+ | IGTR-AR-TS | 75.6 | 77.0 | 98.8 | 57.3 | 77.17 | as above |
68
+ | IGTR-PD-Aug | 79.5 | 80.0 | 99.4 | 58.9 | 79.45 | [link](https://drive.google.com/drive/folders/1XFQkCILwcFwA7iYyQY9crnrouaI5sqcZ?usp=drive_link) |
69
+ | IGTR-AR-Aug | 82.0 | 81.7 | 99.5 | 63.8 | 81.74 | as above |
70
+
71
+ Download all Configs, Models, and Logs from [Google Drive](https://drive.google.com/drive/folders/1mSRDg9Mj5R6PspAdFGXZHDHTCQmjkd8d?usp=drive_link).
72
+
73
+ <a name="2"></a>
74
+
75
+ ## 2. Environment
76
+
77
+ - [PyTorch](http://pytorch.org/) version >= 1.13.0
78
+ - Python version >= 3.7
79
+
80
+ ```shell
81
+ git clone -b develop https://github.com/Topdu/OpenOCR.git
82
+ cd OpenOCR
83
+ # A100 Ubuntu 20.04 Cuda 11.8
84
+ conda create -n openocr python==3.8
85
+ conda activate openocr
86
+ conda install pytorch==2.2.0 torchvision==0.17.0 torchaudio==2.2.0 pytorch-cuda=11.8 -c pytorch -c nvidia
87
+ pip install -r requirements.txt
88
+ ```
89
+
90
+ #### Dataset Preparation
91
+
92
+ - [English dataset download](https://github.com/baudm/parseq)
93
+
94
+ - [Union14M-L-LMDB-Filtered download](https://drive.google.com/drive/folders/1OlDWJZgvd6s4S09S3IGeAI90jI0i7AB_?usp=sharing)
95
+
96
+ - [Chinese dataset download](https://github.com/fudanvi/benchmarking-chinese-text-recognition#download)
97
+
98
+ The expected filesystem structure is as follows:
99
+
100
+ ```
101
+ benchmark_bctr
102
+ ├── benchmark_bctr_test
103
+ │ ├── document_test
104
+ │ ├── handwriting_test
105
+ │ ├── scene_test
106
+ │ └── web_test
107
+ └── benchmark_bctr_train
108
+ ├── document_train
109
+ ├── handwriting_train
110
+ ├── scene_train
111
+ └── web_train
112
+ evaluation
113
+ ├── CUTE80
114
+ ├── IC13_857
115
+ ├── IC15_1811
116
+ ├── IIIT5k
117
+ ├── SVT
118
+ └── SVTP
119
+ OpenOCR
120
+ synth
121
+ ├── MJ
122
+ │ ├── test
123
+ │ ├── train
124
+ │ └── val
125
+ └── ST
126
+ test # from PARSeq
127
+ ├── ArT
128
+ ├── COCOv1.4
129
+ ├── CUTE80
130
+ ├── IC13_1015
131
+ ├── IC13_1095
132
+ ├── IC13_857
133
+ ├── IC15_1811
134
+ ├── IC15_2077
135
+ ├── IIIT5k
136
+ ├── SVT
137
+ ├── SVTP
138
+ └── Uber
139
+ u14m # lmdb format
140
+ ├── artistic
141
+ ├── contextless
142
+ ├── curve
143
+ ├── general
144
+ ├── multi_oriented
145
+ ├── multi_words
146
+ └── salient
147
+ Union14M-L-LMDB-Filtered # lmdb format
148
+ ├── train_challenging
149
+ ├── train_easy
150
+ ├── train_hard
151
+ ├── train_medium
152
+ └── train_normal
153
+ ```
154
+
155
+ <a name="3"></a>
156
+
157
+ ## 3. Model Training / Evaluation
158
+
159
+ Training:
160
+
161
+ ```shell
162
+ # The configuration file is available from the link provided in the table above.
163
+ # Multi GPU training
164
+ CUDA_VISIBLE_DEVICES=0,1 python -m torch.distributed.launch --nproc_per_node=2 tools/train_rec.py --c PATH/svtr_base_igtr_XXX.yml
165
+ ```
166
+
167
+ Evaluation:
168
+
169
+ ```shell
170
+ # The configuration file is available from the link provided in the table above.
171
+ # en
172
+ python tools/eval_rec_all_en.py --c PATH/svtr_base_igtr_syn.yml
173
+ # ch
174
+ python tools/eval_rec_all_ch.py --c PATH/svtr_base_igtr_ch_aug.yml
175
+ ```
176
+
177
+ ## Citation
178
+
179
+ If you find our method useful for your reserach, please cite:
180
+
181
+ ```bibtex
182
+ @article{Du2024IGTR,
183
+ title = {Instruction-Guided Scene Text Recognition},
184
+ author = {Du, Yongkun and Chen, Zhineng and Su, Yuchen and Jia, Caiyan and Jiang, Yu-Gang},
185
+ journal = {CoRR},
186
+ eprinttype = {arXiv},
187
+ primaryClass={cs.CV},
188
+ volume = {abs/2401.17851},
189
+ year = {2024},
190
+ url = {https://arxiv.org/abs/2401.17851}
191
+ }
192
+ ```