litealpr 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. litealpr-0.1.0/.gitignore +42 -0
  2. litealpr-0.1.0/LICENSE +201 -0
  3. litealpr-0.1.0/MANIFEST.in +8 -0
  4. litealpr-0.1.0/PKG-INFO +261 -0
  5. litealpr-0.1.0/README.md +226 -0
  6. litealpr-0.1.0/build_package.py +170 -0
  7. litealpr-0.1.0/configs/det/yolov8/yolov8n_efficient.yml +43 -0
  8. litealpr-0.1.0/configs/rec/svtr26/svtr26_tiny.yml +122 -0
  9. litealpr-0.1.0/dataset/det/data.yaml +5 -0
  10. litealpr-0.1.0/dataset/det/test/images/carlong_0002.png +0 -0
  11. litealpr-0.1.0/dataset/det/test/images/carlong_0008.png +0 -0
  12. litealpr-0.1.0/dataset/det/test/images/carlong_0078.png +0 -0
  13. litealpr-0.1.0/dataset/det/test/images/carlong_0120.png +0 -0
  14. litealpr-0.1.0/dataset/det/test/images/carlong_0178.png +0 -0
  15. litealpr-0.1.0/dataset/det/test/labels/carlong_0002.txt +1 -0
  16. litealpr-0.1.0/dataset/det/test/labels/carlong_0008.txt +1 -0
  17. litealpr-0.1.0/dataset/det/test/labels/carlong_0078.txt +1 -0
  18. litealpr-0.1.0/dataset/det/test/labels/carlong_0120.txt +1 -0
  19. litealpr-0.1.0/dataset/det/test/labels/carlong_0178.txt +1 -0
  20. litealpr-0.1.0/dataset/det/train/images/carlong_0183.png +0 -0
  21. litealpr-0.1.0/dataset/det/train/images/carlong_0184.png +0 -0
  22. litealpr-0.1.0/dataset/det/train/images/carlong_0189.png +0 -0
  23. litealpr-0.1.0/dataset/det/train/images/carlong_0199.png +0 -0
  24. litealpr-0.1.0/dataset/det/train/images/carlong_0223.png +0 -0
  25. litealpr-0.1.0/dataset/det/train/images/carlong_0234.png +0 -0
  26. litealpr-0.1.0/dataset/det/train/images/carlong_0236.png +0 -0
  27. litealpr-0.1.0/dataset/det/train/images/carlong_0263.png +0 -0
  28. litealpr-0.1.0/dataset/det/train/images/carlong_0265.png +0 -0
  29. litealpr-0.1.0/dataset/det/train/labels/carlong_0183.txt +1 -0
  30. litealpr-0.1.0/dataset/det/train/labels/carlong_0184.txt +1 -0
  31. litealpr-0.1.0/dataset/det/train/labels/carlong_0189.txt +1 -0
  32. litealpr-0.1.0/dataset/det/train/labels/carlong_0199.txt +1 -0
  33. litealpr-0.1.0/dataset/det/train/labels/carlong_0223.txt +1 -0
  34. litealpr-0.1.0/dataset/det/train/labels/carlong_0234.txt +1 -0
  35. litealpr-0.1.0/dataset/det/train/labels/carlong_0236.txt +1 -0
  36. litealpr-0.1.0/dataset/det/train/labels/carlong_0263.txt +1 -0
  37. litealpr-0.1.0/dataset/det/train/labels/carlong_0265.txt +1 -0
  38. litealpr-0.1.0/dataset/det/val/images/carlong_0130.png +0 -0
  39. litealpr-0.1.0/dataset/det/val/images/carlong_0133.png +0 -0
  40. litealpr-0.1.0/dataset/det/val/images/carlong_0134.png +0 -0
  41. litealpr-0.1.0/dataset/det/val/images/carlong_0174.png +0 -0
  42. litealpr-0.1.0/dataset/det/val/labels/carlong_0130.txt +1 -0
  43. litealpr-0.1.0/dataset/det/val/labels/carlong_0133.txt +1 -0
  44. litealpr-0.1.0/dataset/det/val/labels/carlong_0134.txt +1 -0
  45. litealpr-0.1.0/dataset/det/val/labels/carlong_0174.txt +1 -0
  46. litealpr-0.1.0/dataset/rec/lmdb_data/.gitkeep +0 -0
  47. litealpr-0.1.0/dataset/rec/test/a10.jpg +0 -0
  48. litealpr-0.1.0/dataset/rec/test/a9_crop0.jpg +0 -0
  49. litealpr-0.1.0/dataset/rec/test/a9_crop1.jpg +0 -0
  50. litealpr-0.1.0/dataset/rec/test/a9_crop2.jpg +0 -0
  51. litealpr-0.1.0/dataset/rec/test/a9_crop3.jpg +0 -0
  52. litealpr-0.1.0/dataset/rec/test_labels.txt +5 -0
  53. litealpr-0.1.0/dataset/rec/train/a1.jpg +0 -0
  54. litealpr-0.1.0/dataset/rec/train/a2.jpg +0 -0
  55. litealpr-0.1.0/dataset/rec/train/a3.jpg +0 -0
  56. litealpr-0.1.0/dataset/rec/train/a4.jpg +0 -0
  57. litealpr-0.1.0/dataset/rec/train/a66_crop0.jpg +0 -0
  58. litealpr-0.1.0/dataset/rec/train_labels.txt +5 -0
  59. litealpr-0.1.0/dataset/rec/val/a6.jpg +0 -0
  60. litealpr-0.1.0/dataset/rec/val/a7.jpg +0 -0
  61. litealpr-0.1.0/dataset/rec/val_labels.txt +2 -0
  62. litealpr-0.1.0/dataset/wild/1.png +0 -0
  63. litealpr-0.1.0/dataset/wild/10.png +0 -0
  64. litealpr-0.1.0/dataset/wild/11.png +0 -0
  65. litealpr-0.1.0/dataset/wild/12.png +0 -0
  66. litealpr-0.1.0/dataset/wild/2.png +0 -0
  67. litealpr-0.1.0/dataset/wild/3.png +0 -0
  68. litealpr-0.1.0/dataset/wild/4.png +0 -0
  69. litealpr-0.1.0/dataset/wild/5.png +0 -0
  70. litealpr-0.1.0/dataset/wild/6.png +0 -0
  71. litealpr-0.1.0/dataset/wild/7.png +0 -0
  72. litealpr-0.1.0/dataset/wild/8.png +0 -0
  73. litealpr-0.1.0/dataset/wild/9.png +0 -0
  74. litealpr-0.1.0/docs/figures/Hung_0060.png +0 -0
  75. litealpr-0.1.0/docs/figures/Hung_0060_crop.png +0 -0
  76. litealpr-0.1.0/docs/figures/efficient_rctc_decoder.png +0 -0
  77. litealpr-0.1.0/docs/figures/generate_c2f.png +0 -0
  78. litealpr-0.1.0/docs/figures/generate_c3ghost.png +0 -0
  79. litealpr-0.1.0/docs/figures/intro1.png +0 -0
  80. litealpr-0.1.0/docs/figures/original_rctc_decoder.png +0 -0
  81. litealpr-0.1.0/examples/demo.ipynb +1262 -0
  82. litealpr-0.1.0/examples/full_pipeline.ipynb +2016 -0
  83. litealpr-0.1.0/litealpr/__init__.py +5 -0
  84. litealpr-0.1.0/litealpr/det/__init__.py +1 -0
  85. litealpr-0.1.0/litealpr/license_plate_dict.txt +37 -0
  86. litealpr-0.1.0/litealpr/pipeline.py +187 -0
  87. litealpr-0.1.0/litealpr/rec/losses/__init__.py +71 -0
  88. litealpr-0.1.0/litealpr/rec/losses/ctc_loss.py +33 -0
  89. litealpr-0.1.0/litealpr/rec/metrics/__init__.py +33 -0
  90. litealpr-0.1.0/litealpr/rec/metrics/rec_metric.py +287 -0
  91. litealpr-0.1.0/litealpr/rec/modeling/__init__.py +11 -0
  92. litealpr-0.1.0/litealpr/rec/modeling/base_recognizer.py +57 -0
  93. litealpr-0.1.0/litealpr/rec/modeling/common.py +242 -0
  94. litealpr-0.1.0/litealpr/rec/modeling/decoders/__init__.py +22 -0
  95. litealpr-0.1.0/litealpr/rec/modeling/decoders/efficient_rctc_decoder.py +56 -0
  96. litealpr-0.1.0/litealpr/rec/modeling/encoders/__init__.py +22 -0
  97. litealpr-0.1.0/litealpr/rec/modeling/encoders/svtrv2.py +495 -0
  98. litealpr-0.1.0/litealpr/rec/modeling/encoders/svtrv2_lnconv.py +524 -0
  99. litealpr-0.1.0/litealpr/rec/modeling/encoders/svtrv2_lnconv_two33.py +542 -0
  100. litealpr-0.1.0/litealpr/rec/optimizer/__init__.py +75 -0
  101. litealpr-0.1.0/litealpr/rec/optimizer/lr.py +276 -0
  102. litealpr-0.1.0/litealpr/rec/postprocess/__init__.py +26 -0
  103. litealpr-0.1.0/litealpr/rec/postprocess/ctc_postprocess.py +118 -0
  104. litealpr-0.1.0/litealpr/rec/preprocess/__init__.py +78 -0
  105. litealpr-0.1.0/litealpr/rec/preprocess/auto_augment.py +493 -0
  106. litealpr-0.1.0/litealpr/rec/preprocess/ctc_label_encode.py +123 -0
  107. litealpr-0.1.0/litealpr/rec/preprocess/parseq_aug.py +156 -0
  108. litealpr-0.1.0/litealpr/rec/preprocess/rec_aug.py +12 -0
  109. litealpr-0.1.0/litealpr.egg-info/PKG-INFO +261 -0
  110. litealpr-0.1.0/litealpr.egg-info/SOURCES.txt +144 -0
  111. litealpr-0.1.0/litealpr.egg-info/dependency_links.txt +1 -0
  112. litealpr-0.1.0/litealpr.egg-info/not-zip-safe +1 -0
  113. litealpr-0.1.0/litealpr.egg-info/requires.txt +7 -0
  114. litealpr-0.1.0/litealpr.egg-info/top_level.txt +1 -0
  115. litealpr-0.1.0/pretrained_models/det/yolov8n_efficient/.gitkeep +0 -0
  116. litealpr-0.1.0/pretrained_models/rec/svtr26_tiny/.gitkeep +0 -0
  117. litealpr-0.1.0/pyproject.toml +56 -0
  118. litealpr-0.1.0/requirements.txt +14 -0
  119. litealpr-0.1.0/setup.cfg +4 -0
  120. litealpr-0.1.0/setup.py +80 -0
  121. litealpr-0.1.0/tools/__init__.py +0 -0
  122. litealpr-0.1.0/tools/convert_fp16.py +12 -0
  123. litealpr-0.1.0/tools/create_lmdb_dataset.py +124 -0
  124. litealpr-0.1.0/tools/data/__init__.py +110 -0
  125. litealpr-0.1.0/tools/data/collate_fn.py +97 -0
  126. litealpr-0.1.0/tools/data/lmdb_dataset.py +142 -0
  127. litealpr-0.1.0/tools/data/ratio_dataset_tvresize.py +214 -0
  128. litealpr-0.1.0/tools/data/ratio_sampler.py +192 -0
  129. litealpr-0.1.0/tools/engine/config.py +157 -0
  130. litealpr-0.1.0/tools/engine/trainer.py +602 -0
  131. litealpr-0.1.0/tools/eval_det.py +47 -0
  132. litealpr-0.1.0/tools/eval_rec.py +49 -0
  133. litealpr-0.1.0/tools/export_det.py +66 -0
  134. litealpr-0.1.0/tools/export_rec.py +83 -0
  135. litealpr-0.1.0/tools/infer_det.py +134 -0
  136. litealpr-0.1.0/tools/infer_rec.py +173 -0
  137. litealpr-0.1.0/tools/train_det.py +33 -0
  138. litealpr-0.1.0/tools/train_rec.py +42 -0
  139. litealpr-0.1.0/tools/utility.py +45 -0
  140. litealpr-0.1.0/tools/utils/__init__.py +0 -0
  141. litealpr-0.1.0/tools/utils/ckpt.py +100 -0
  142. litealpr-0.1.0/tools/utils/gen_label.py +67 -0
  143. litealpr-0.1.0/tools/utils/license_plate_dict.txt +37 -0
  144. litealpr-0.1.0/tools/utils/logging.py +54 -0
  145. litealpr-0.1.0/tools/utils/stats.py +59 -0
  146. litealpr-0.1.0/tools/utils/utility.py +166 -0
@@ -0,0 +1,42 @@
1
+ # Python and Environment
2
+ __pycache__/
3
+ .ipynb_checkpoints/
4
+ *.py[cod]
5
+ *$py.class
6
+ *.so
7
+ env/
8
+ venv/
9
+ .env
10
+
11
+ # Build and Distribution
12
+ build/
13
+ dist/
14
+ *.egg-info/
15
+
16
+ # IDE and OS
17
+ .vscode/
18
+ .idea/
19
+ *.DS_Store
20
+ *.vs
21
+ *.user
22
+ *~
23
+
24
+ # Logs and Outputs
25
+ *.log
26
+ output/
27
+ inference/
28
+ inference_results/
29
+ e2e_results/
30
+ rec_results/
31
+ det_results/
32
+ test_output/
33
+ gradio_outputs/
34
+
35
+ # Data and Models
36
+ dataset/
37
+ train_data/
38
+ train_data_lmdb/
39
+ pretrained_models/
40
+ *.pt
41
+ *.pth
42
+ *.safetensors
litealpr-0.1.0/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.
@@ -0,0 +1,8 @@
1
+ include README.md
2
+ include LICENSE
3
+
4
+ # Include all Python files
5
+ recursive-include litealpr *.py
6
+
7
+ # Include dictionary files
8
+ recursive-include litealpr *.txt
@@ -0,0 +1,261 @@
1
+ Metadata-Version: 2.4
2
+ Name: litealpr
3
+ Version: 0.1.0
4
+ Summary: Accurate and Efficient General OCR System for License Plates
5
+ Home-page: https://github.com/vn-anhnth/LiteALPR
6
+ Author: vn-anhnth
7
+ Author-email: vn-anhnth <anhlone3@gmail.com>
8
+ License: Apache License 2.0
9
+ Project-URL: Homepage, https://github.com/vn-anhnth/LiteALPR
10
+ Project-URL: Documentation, https://github.com/vn-anhnth/LiteALPR/tree/main/docs
11
+ Project-URL: Bug Reports, https://github.com/vn-anhnth/LiteALPR/issues
12
+ Keywords: ocr,license plate recognition,yolov8,svtr,deep learning,computer vision
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: Apache Software License
16
+ Classifier: Programming Language :: Python :: 3.8
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Topic :: Scientific/Engineering :: Image Recognition
21
+ Requires-Python: >=3.8
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: numpy<2.0
25
+ Requires-Dist: opencv-python<=5.0.0.93
26
+ Requires-Dist: pyyaml<=6.0.3
27
+ Requires-Dist: huggingface-hub<=0.31
28
+ Requires-Dist: torch>=1.7.0
29
+ Requires-Dist: torchvision
30
+ Requires-Dist: ultralytics<=8.3.99
31
+ Dynamic: author
32
+ Dynamic: home-page
33
+ Dynamic: license-file
34
+ Dynamic: requires-python
35
+
36
+ # LiteALPR
37
+
38
+ [![PyPI version](https://badge.fury.io/py/litealpr.svg)](https://pypi.org/project/litealpr/)
39
+
40
+ <p align="center">
41
+ <img src="https://raw.githubusercontent.com/vn-anhnth/LiteALPR/main/docs/figures/intro1.png" width="350">
42
+ <br>
43
+ <em>Visual samples of challenging real-world license plates (motion blur, diverse layouts, low light) that LiteALPR is built to handle.</em>
44
+ </p>
45
+
46
+ 🚀 **LiteALPR** is an accurate, extremely fast, and flexible End-to-End License Plate Recognition library.
47
+
48
+ Unlike traditional ALPR systems that rely on heavy architectures, LiteALPR introduces structural improvements designed specifically for high-throughput applications. Our framework achieves ultra-fast inference speeds without sacrificing accuracy on blurry or degraded license plates through two major architectural optimizations.
49
+
50
+ ## 🧩 LiteALPR Pipeline
51
+ The framework is structured as a highly optimized two-stage sequential pipeline:
52
+
53
+ <p align="center">
54
+ <img src="https://raw.githubusercontent.com/vn-anhnth/LiteALPR/main/docs/figures/Hung_0060.png" height="150"> ➔ <b>YOLOv8n-Efficient</b> ➔ <img src="https://raw.githubusercontent.com/vn-anhnth/LiteALPR/main/docs/figures/Hung_0060_crop.png" height="150"> ➔ <b>SVTR26-Tiny</b> ➔ <code>59P289136</code>
55
+ </p>
56
+ <p align="center"><em>Overview of the proposed highly optimized two-stage ALPR pipeline.</em></p>
57
+
58
+ ### 1. YOLOv8n-Efficient for Fast Detection
59
+ We replaced the **original heavy C2f blocks** in the YOLOv8 neck with **lightweight C3Ghost blocks**.
60
+
61
+ | Original: Heavy C2f Block | Proposed: Lightweight C3Ghost Block |
62
+ | :---: | :---: |
63
+ | <img src="https://raw.githubusercontent.com/vn-anhnth/LiteALPR/main/docs/figures/generate_c2f.png" height="250"> | <img src="https://raw.githubusercontent.com/vn-anhnth/LiteALPR/main/docs/figures/generate_c3ghost.png" height="250"> |
64
+
65
+ Leveraging Ghost modules, this architectural enhancement significantly increases detection speed while maintaining high localization accuracy. By generating more feature maps from cheap operations, it eliminates computational redundancy, enabling ultra-fast performance on consumer-grade hardware without compromising precision.
66
+
67
+ ### 2. SVTR26-Tiny for Lightning-Fast Recognition
68
+ To make the SVTR26 OCR model viable for strict high-speed constraints, we applied a key modification:
69
+ * **Efficient RCTC Decoder:** We entirely discarded the **Original heavy attention-based RCTC Decoder**. Since license plates have a rigid, horizontally aligned structure, we replaced 2D attention with a simple **Height-wise Average Pooling** operation. This elegantly compresses the 2D features into a 1D sequence, completely bypassing expensive matrix multiplications.
70
+
71
+ | Original: Heavy RCTC Decoder | Proposed: Efficient RCTC Decoder |
72
+ | :---: | :---: |
73
+ | <img src="https://raw.githubusercontent.com/vn-anhnth/LiteALPR/main/docs/figures/original_rctc_decoder.png" width="400"> | <img src="https://raw.githubusercontent.com/vn-anhnth/LiteALPR/main/docs/figures/efficient_rctc_decoder.png" width="400"> |
74
+
75
+ By integrating these specialized components, **LiteALPR** delivers unmatched production-ready performance, processing frames at blazing speeds!
76
+
77
+ ---
78
+
79
+ ## 🛠 Installation
80
+
81
+ ```bash
82
+ pip install litealpr
83
+ ```
84
+
85
+ *(Note: To use the auto-download feature for pre-trained weights, please ensure `huggingface_hub` is installed).*
86
+
87
+ ## ⚡ Quick Start
88
+
89
+ LiteALPR automatically downloads the best pre-trained models from our HuggingFace repository the first time you run it. You don't need to manually configure any paths!
90
+
91
+ ### 1. End-to-End Recognition (Detect & Read)
92
+
93
+ ```python
94
+ from litealpr import LiteALPR
95
+
96
+ # Initialize (auto-downloads weights if not found)
97
+ model = LiteALPR()
98
+
99
+ # Read the plate
100
+ results = model.read('sample.jpg')
101
+
102
+ for res in results:
103
+ print(f"Plate Text: {res['text']} | Confidence: {res['score']:.4f}")
104
+ print(f"Bounding Box: {res['box']}")
105
+ ```
106
+
107
+ ### 2. Flexible API: Detect Only
108
+ If you only need to locate the license plates without reading the text:
109
+ ```python
110
+ # Disable the recognition model
111
+ model = LiteALPR(use_rec=False)
112
+ boxes = model.detect('sample.jpg')
113
+ print("Detected boxes:", boxes)
114
+ ```
115
+
116
+ ### 3. Flexible API: Recognize Only
117
+ If you already have a cropped image of a license plate and just want to read the characters:
118
+ ```python
119
+ # Disable the detection model
120
+ model = LiteALPR(use_det=False)
121
+
122
+ crop_img = cv2.imread('sample_crop.jpg')
123
+ text, score = model.recognize(crop_img)
124
+ print(f"Text: {text} (Score: {score})")
125
+ ```
126
+
127
+ ### 4. Using Custom Local Weights
128
+ If you have fine-tuned your own models or downloaded the weights locally, you can easily load them:
129
+ ```python
130
+ model = LiteALPR(
131
+ det_model_path="/path/to/your/yolov8n_efficient/best.pt",
132
+ rec_model_path="/path/to/your/svtr26_tiny/best.pth"
133
+ )
134
+ ```
135
+
136
+ ## 🏋️ Training & Evaluation
137
+
138
+ LiteALPR provides a complete suite of scripts in the `tools/` directory for dataset preparation, training, evaluation, and inference.
139
+
140
+ ### 0. Model Weights Preparation
141
+ Before training or evaluation, download the official pre-trained models from our [HuggingFace Repository](https://huggingface.co/anhone3/LiteALPR) and place them in the following structure:
142
+ ```
143
+ LiteALPR/
144
+ ├── pretrained_models/
145
+ │ ├── yolov8n_efficient/
146
+ │ │ └── best.pt
147
+ │ └── svtr26_tiny/
148
+ │ └── best.pth
149
+ ```
150
+ You can download them manually or use `wget`:
151
+ ```bash
152
+ wget -O pretrained_models/det/yolov8n_efficient/best.pt https://huggingface.co/anhone3/LiteALPR/resolve/main/yolov8n_efficient/best.pt
153
+ wget -O pretrained_models/rec/svtr26_tiny/best.pth https://huggingface.co/anhone3/LiteALPR/resolve/main/svtr26_tiny/best.pth
154
+ ```
155
+
156
+ ### 1. Data Preparation (Create LMDB)
157
+ Because our LMDB script uses hardcoded paths for simplicity, please open `tools/create_lmdb_dataset.py` and modify the `data_dir` variable in the `__main__` block to match your dataset path before running:
158
+ ```python
159
+ if __name__ == '__main__':
160
+ data_dir = './dataset/rec' # Set your dataset directory
161
+
162
+ label_file_list = [
163
+ os.path.join(data_dir, 'train_labels.txt'),
164
+ os.path.join(data_dir, 'val_labels.txt'),
165
+ os.path.join(data_dir, 'test_labels.txt')
166
+ ]
167
+ ```
168
+ After modifying the paths, generate the LMDB:
169
+ ```bash
170
+ python tools/create_lmdb_dataset.py
171
+ ```
172
+
173
+ ### 2. Training (Det & Rec)
174
+ Before training, you must configure your dataset paths, batch sizes, and learning parameters:
175
+
176
+ **For Detection:**
177
+ Open `tools/train_det.py` and modify the parameters inside the `model.train()` function directly:
178
+ ```python
179
+ model.train(
180
+ data='dataset/det/data.yaml', # Point this to your YOLO data.yaml
181
+ epochs=50,
182
+ batch=256,
183
+ ...
184
+ )
185
+ ```
186
+
187
+ **For Recognition (`configs/rec/svtr26/svtr26_tiny.yml`):**
188
+ ```yaml
189
+ Train:
190
+ dataset:
191
+ name: RatioDataSetTVResize
192
+ data_dir_list: ['./dataset/rec/lmdb_data/train']
193
+
194
+ Eval:
195
+ dataset:
196
+ name: RatioDataSetTVResize
197
+ data_dir_list: ['./dataset/rec/lmdb_data/val']
198
+ ```
199
+
200
+ Once configured, start training:
201
+
202
+ > [!TIP]
203
+ > **Pre-trained Models (Fine-tuning)**
204
+ > By default, the training process will load pre-trained weights to speed up convergence. You can change the path or remove it to train from scratch:
205
+ > - **For Detection:** Edit the `.load(...)` path directly inside the `tools/train_det.py` script.
206
+ > - **For Recognition:** Edit the `Global.pretrained_model` field inside your `.yml` config file (e.g., `configs/rec/svtr26/svtr26_tiny.yml`).
207
+
208
+ ```bash
209
+ # Train Detection Model (YOLOv8)
210
+ # For multi-GPU training, set device to a list of GPU IDs in train_det.py, e.g., device=[0, 1]
211
+ python tools/train_det.py -c configs/det/yolov8/yolov8n_efficient.yml
212
+
213
+ # Train Recognition Model (SVTR26)
214
+ # For multi-GPU training, set nproc_per_node to the number of GPUs being used for training
215
+ torchrun --nproc_per_node=1 tools/train_rec.py \
216
+ -c configs/rec/svtr26/svtr26_tiny.yml
217
+ ```
218
+
219
+ ### 3. Evaluation (Validation)
220
+ Evaluate your trained checkpoints on the validation set:
221
+ ```bash
222
+ # Evaluate Detection
223
+ python tools/eval_det.py -m output/det/yolov8n_efficient/train/weights/best.pt
224
+
225
+ # Evaluate Recognition
226
+ python tools/eval_rec.py -c configs/rec/svtr26/svtr26_tiny.yml -m output/rec/svtr26_tiny/train/best.pth
227
+ ```
228
+
229
+ ### 4. Batch Inference
230
+ Test your checkpoints directly on directories of images (supports `--save_log` to save predictions):
231
+ ```bash
232
+ # Infer Detection
233
+ python tools/infer_det.py -m pretrained_models/det/yolov8n_efficient/best.pt -d dataset/det/test/images --save_log
234
+
235
+ # Infer Recognition
236
+ python tools/infer_rec.py -m pretrained_models/rec/svtr26_tiny/best.pth -d dataset/rec/test --save_log
237
+ ```
238
+
239
+ ### 5. Export to ONNX
240
+ Export your trained PyTorch models to the ONNX format for deployment in production environments (C++, C#, TensorRT, etc.).
241
+
242
+ ```bash
243
+ # Export Detection
244
+ # The ONNX file will automatically be saved alongside the original `.pt` file
245
+ python tools/export_det.py -m output/det/yolov8n_efficient/train/weights/best.pt
246
+
247
+ # Export Recognition
248
+ # By default, the SVTR ONNX model expects a fixed 128x32 image. If you need it to accept dynamic width images in production, add the `--dynamic` flag
249
+ python tools/export_rec.py -m output/rec/svtr26_tiny/train/best.pth --save_path output/rec/svtr26_tiny/train/best.onnx --dynamic
250
+ ```
251
+
252
+ ## 🤝 Acknowledgements
253
+
254
+ - **OpenOCR**: LiteALPR is built upon the robust foundation of [OpenOCR](https://github.com/Topdu/OpenOCR).
255
+ - **YOLOv8 & SVTRv2**: This work heavily leverages the architectural innovations from **YOLOv8** for high-speed object detection and **SVTRv2** for accurate text recognition.
256
+ - Read the [YOLOv8 Paper](https://arxiv.org/html/2408.15857v1)
257
+ - Read the [SVTRv2 Paper](https://arxiv.org/html/2411.15858v1)
258
+ - **Datasets**: Our evaluation utilizes datasets from [Brazil (RodoSol-ALPR)](https://github.com/raysonlaroca/rodosol-alpr-dataset), [China (CBLPRD-330k)](https://github.com/SunlifeV/CBLPRD-330k), and [Vietnam](https://www.kaggle.com/datasets/duydieunguyen/licenseplates) public collections alongside self-collected traffic footage. We sincerely thank the original authors of these datasets for advancing the ALPR research community.
259
+
260
+ ## 📧 Contact
261
+ For any questions or issues, please open an issue or contact: `anhlone3@gmail.com`.