Skip to content

Commit 8a42017

Browse files
authored
Add CRNN_CN for recognizing Chinese (#23)
* add charsets and CRNN_CN * workable wrapper and demo for CRNN_CN * update README with CRNN_CN; rename models with EN/CN suffix * impl benchmarks for CRNN_EN and CRNN_CN * update benchmark result on arm * update benchmark results on x86_64 & cuda
1 parent d5b4145 commit 8a42017

File tree

10 files changed

+4066
-39
lines changed

10 files changed

+4066
-39
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ Guidelines:
1919
| [YuNet](./models/face_detection_yunet) | 160x120 | 1.45 | 6.22 | 12.18 |
2020
| [DB-IC15](./models/text_detection_db) | 640x480 | 142.91 | 2835.91 | 208.41 |
2121
| [DB-TD500](./models/text_detection_db) | 640x480 | 142.91 | 2841.71 | 210.51 |
22-
| [CRNN](./models/text_recognition_crnn) | 100x32 | 50.21 | 234.32 | 196.15 |
22+
| [CRNN-EN](./models/text_recognition_crnn) | 100x32 | 50.21 | 234.32 | 196.15 |
23+
| [CRNN-CN](./models/text_recognition_crnn) | 100x32 | 73.52 | 322.16 | 239.76 |
2324
| [SFace](./models/face_recognition_sface) | 112x112 | 8.65 | 99.20 | 24.88 |
2425
| [PP-ResNet](./models/image_classification_ppresnet) | 224x224 | 56.05 | 602.58 | 98.64 |
2526
| [PP-HumanSeg](./models/human_segmentation_pphumanseg) | 192x192 | 19.92 | 105.32 | 67.97 |
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Benchmark:
2+
name: "Text Recognition Benchmark"
3+
type: "Recognition"
4+
data:
5+
path: "benchmark/data/text"
6+
files: ["1.jpg", "2.jpg", "3.jpg"]
7+
metric: # 'sizes' is omitted since this model requires input of fixed size
8+
warmup: 30
9+
repeat: 10
10+
reduction: "median"
11+
backend: "default"
12+
target: "cpu"
13+
14+
Model:
15+
name: "CRNN"
16+
modelPath: "models/text_recognition_crnn/text_recognition_CRNN_CN_2021nov.onnx"
17+
charsetPath: "models/text_recognition_crnn/charset_3944_CN.txt"

benchmark/config/text_recognition_crnn.yaml renamed to benchmark/config/text_recognition_crnn_en.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ Benchmark:
1313

1414
Model:
1515
name: "CRNN"
16-
modelPath: "models/text_recognition_crnn/text_recognition_CRNN_VGG_BiLSTM_CTC_2021sep.onnx"
16+
modelPath: "models/text_recognition_crnn/text_recognition_CRNN_EN_2021sep.onnx"
17+
charsetPath: "models/text_recognition_crnn/charset_36_EN.txt"

models/text_recognition_crnn/README.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,37 @@
33
An End-to-End Trainable Neural Network for Image-based Sequence Recognition and Its Application to Scene Text Recognition
44

55
Note:
6-
- Model source: https://docs.opencv.org/4.5.2/d9/d1e/tutorial_dnn_OCR.html.
7-
- For details on training this model, please visit https://github.com/zihaomu/deep-text-recognition-benchmark, which can only recognize english words.
6+
- Model source:
7+
- `text_recognition_CRNN_EN_2021sep.onnx`: https://docs.opencv.org/4.5.2/d9/d1e/tutorial_dnn_OCR.html (CRNN_VGG_BiLSTM_CTC.onnx)
8+
- `text_recognition_CRNN_CN_2021nov.onnx`: https://docs.opencv.org/4.5.2/d4/d43/tutorial_dnn_text_spotting.html (crnn_cs_CN.onnx)
9+
- `text_recognition_CRNN_EN_2021sep.onnx` can detect digits (0~9) and letters (return lowercase letters a~z) (view `charset_36_EN.txt` for details).
10+
- `text_recognition_CRNN_CN_2021nov.onnx` can detect digits (0~9), upper/lower-case letters (a~z and A~Z), some Chinese characters and some special characters (view `charset_3944_CN.txt` for details).
11+
- For details on training this model series, please visit https://github.com/zihaomu/deep-text-recognition-benchmark.
812

913
## Demo
1014

11-
***NOTE***: This demo uses [text_detection_db](../text_detection_db) as text detector.
15+
***NOTE***:
16+
- This demo uses [text_detection_db](../text_detection_db) as text detector.
17+
- Selected model must match with the charset:
18+
- Try `text_recognition_CRNN_EN_2021sep.onnx` with `charset_36_EN.txt`.
19+
- Try `text_recognition_CRNN_CN_2021sep.onnx` with `charset_3944_CN.txt`.
1220

13-
Run the following command to try the demo:
21+
Run the demo detecting English:
1422
```shell
1523
# detect on camera input
1624
python demo.py
1725
# detect on an image
1826
python demo.py --input /path/to/image
1927
```
2028

29+
Run the demo detecting Chinese:
30+
```shell
31+
# detect on camera input
32+
python demo.py --model text_recognition_CRNN_CN_2021nov.onnx --charset charset_3944_CN.txt
33+
# detect on an image
34+
python demo.py --input /path/to/image --model text_recognition_CRNN_CN_2021nov.onnx --charset charset_3944_CN.txt
35+
```
36+
2137
## License
2238

2339
All files in this directory are licensed under [Apache 2.0 License](./LICENSE).
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
0
2+
1
3+
2
4+
3
5+
4
6+
5
7+
6
8+
7
9+
8
10+
9
11+
a
12+
b
13+
c
14+
d
15+
e
16+
f
17+
g
18+
h
19+
i
20+
j
21+
k
22+
l
23+
m
24+
n
25+
o
26+
p
27+
q
28+
r
29+
s
30+
t
31+
u
32+
v
33+
w
34+
x
35+
y
36+
z

0 commit comments

Comments
 (0)