ONNX
Yiyao Wang commited on
Commit
3d05847
·
1 Parent(s): 4fcc8b2

Text Recognition: Add script to evaluate text recognition by ICDAR2003 (#71)

Browse files

* update readme

* add another script

* revise details for this pr

Files changed (3) hide show
  1. README.md +14 -0
  2. charset_94_CH.txt +94 -0
  3. crnn.py +3 -1
README.md CHANGED
@@ -2,11 +2,24 @@
2
 
3
  An End-to-End Trainable Neural Network for Image-based Sequence Recognition and Its Application to Scene Text Recognition
4
 
 
 
 
 
 
 
 
 
 
 
 
5
  Note:
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.
12
 
@@ -16,6 +29,7 @@ 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`.
20
 
21
  Run the demo detecting English:
 
2
 
3
  An End-to-End Trainable Neural Network for Image-based Sequence Recognition and Its Application to Scene Text Recognition
4
 
5
+ Results of accuracy evaluation with [tools/eval](../../tools/eval) at different text recognition datasets.
6
+
7
+ | Model name | ICDAR03(%) | IIIT5k(%) | CUTE80(%) |
8
+ |--------------|------------|-----------|-----------|
9
+ | CRNN_EN | 81.66 | 74.33 | 52.78 |
10
+ | CRNN_EN_FP16 | 82.01 | 74.93 | 52.34 |
11
+ | CRNN_CH | 71.28 | 80.90 | 67.36 |
12
+ | CRNN_CH_FP16 | 78.63 | 80.93 | 67.01 |
13
+
14
+ \*: 'FP16' stands for 'model quantized into FP16'.
15
+
16
  Note:
17
  - Model source:
18
  - `text_recognition_CRNN_EN_2021sep.onnx`: https://docs.opencv.org/4.5.2/d9/d1e/tutorial_dnn_OCR.html (CRNN_VGG_BiLSTM_CTC.onnx)
19
+ - `text_recognition_CRNN_CH_2021sep.onnx`: https://docs.opencv.org/4.x/d4/d43/tutorial_dnn_text_spotting.html (crnn_cs.onnx)
20
  - `text_recognition_CRNN_CN_2021nov.onnx`: https://docs.opencv.org/4.5.2/d4/d43/tutorial_dnn_text_spotting.html (crnn_cs_CN.onnx)
21
  - `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).
22
+ - `text_recognition_CRNN_CH_2021sep.onnx` can detect digits (0\~9), upper/lower-case letters (a\~z and A\~Z), and some special characters (view `charset_94_CH.txt` for details).
23
  - `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).
24
  - For details on training this model series, please visit https://github.com/zihaomu/deep-text-recognition-benchmark.
25
 
 
29
  - This demo uses [text_detection_db](../text_detection_db) as text detector.
30
  - Selected model must match with the charset:
31
  - Try `text_recognition_CRNN_EN_2021sep.onnx` with `charset_36_EN.txt`.
32
+ - Try `text_recognition_CRNN_CH_2021sep.onnx` with `charset_94_CH.txt`
33
  - Try `text_recognition_CRNN_CN_2021sep.onnx` with `charset_3944_CN.txt`.
34
 
35
  Run the demo detecting English:
charset_94_CH.txt ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
37
+ A
38
+ B
39
+ C
40
+ D
41
+ E
42
+ F
43
+ G
44
+ H
45
+ I
46
+ J
47
+ K
48
+ L
49
+ M
50
+ N
51
+ O
52
+ P
53
+ Q
54
+ R
55
+ S
56
+ T
57
+ U
58
+ V
59
+ W
60
+ X
61
+ Y
62
+ Z
63
+ !
64
+ "
65
+ #
66
+ $
67
+ %
68
+ &
69
+ '
70
+ (
71
+ )
72
+ *
73
+ +
74
+ ,
75
+ -
76
+ .
77
+ /
78
+ :
79
+ ;
80
+ <
81
+ =
82
+ >
83
+ ?
84
+ @
85
+ [
86
+ \
87
+ ]
88
+ ^
89
+ _
90
+ `
91
+ {
92
+ |
93
+ }
94
+ ~
crnn.py CHANGED
@@ -54,7 +54,9 @@ class CRNN:
54
  rotationMatrix = cv.getPerspectiveTransform(vertices, self._targetVertices)
55
  cropped = cv.warpPerspective(image, rotationMatrix, self._inputSize)
56
 
57
- if 'CN' in self._model_path:
 
 
58
  pass
59
  else:
60
  cropped = cv.cvtColor(cropped, cv.COLOR_BGR2GRAY)
 
54
  rotationMatrix = cv.getPerspectiveTransform(vertices, self._targetVertices)
55
  cropped = cv.warpPerspective(image, rotationMatrix, self._inputSize)
56
 
57
+ # 'CN' can detect digits (0\~9), upper/lower-case letters (a\~z and A\~Z), and some special characters
58
+ # 'CH' can detect digits (0\~9), upper/lower-case letters (a\~z and A\~Z), some Chinese characters and some special characters
59
+ if 'CN' in self._model_path or 'CH' in self._model_path:
60
  pass
61
  else:
62
  cropped = cv.cvtColor(cropped, cv.COLOR_BGR2GRAY)