mxaln commited on
Commit
354549c
Β·
verified Β·
1 Parent(s): 6309f00

Add model card

Browse files
Files changed (1) hide show
  1. README.md +115 -0
README.md ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ library_name: onnx
4
+ tags:
5
+ - ocr
6
+ - handwriting-recognition
7
+ - paddleocr
8
+ - onnx
9
+ - multilingual
10
+ language:
11
+ - en
12
+ - zh
13
+ - ja
14
+ - hi
15
+ - th
16
+ - ar
17
+ - ko
18
+ ---
19
+
20
+ # DocScanner on-device OCR models
21
+
22
+ ONNX exports of [PaddleOCR](https://github.com/PaddlePaddle/PaddleOCR) text detection and
23
+ recognition models, used by [DocScanner](https://github.com/Bible-Translation-Tools/doc-scanner)
24
+ to transcribe handwritten pages **entirely on the device**.
25
+
26
+ DocScanner is a free, open-source tool for Bible translation field teams. Transcription has to
27
+ work without a network and without per-page cost, so no cloud model is involved: a page is cut
28
+ into text lines by the detector, and each line is read by the recognizer for that project's
29
+ writing system.
30
+
31
+ ## Layout
32
+
33
+ A device downloads the detector plus exactly one recognizer β€” 13 MB for most scripts, 78 MB for
34
+ Latin/CJK β€” never the whole set.
35
+
36
+ | path | file | size | sha256 (short) |
37
+ |------|------|------|----------------|
38
+ | `detector/` | `det_model.onnx` | 4.6 MB | `0c5eeee2` |
39
+ | `ppocrv6/` | `rec_model.onnx` | 73 MB | `4078550d` |
40
+ | `ppocrv6/` | `charset.json` | 128 KB | `46f80089` |
41
+ | `devanagari/` | `rec_model.onnx` | 7.6 MB | `a3d5b5fa` |
42
+ | `devanagari/` | `charset.json` | 3.6 KB | `621d0073` |
43
+ | `thai/` | `rec_model.onnx` | 7.5 MB | `d52231fe` |
44
+ | `thai/` | `charset.json` | 3.3 KB | `b62ede69` |
45
+ | `arabic/` | `rec_model.onnx` | 7.6 MB | `a1e69c68` |
46
+ | `arabic/` | `charset.json` | 4.5 KB | `df730929` |
47
+ | `korean/` | `rec_model.onnx` | 13 MB | `03525a1d` |
48
+ | `korean/` | `charset.json` | 81 KB | `e600744e` |
49
+
50
+ The app pins a **tag** of this repository in its download URL, so a given build can only ever
51
+ fetch the weights it was tested against.
52
+
53
+ ## Provenance
54
+
55
+ Exported with [`paddle2onnx`](https://github.com/PaddlePaddle/Paddle2ONNX) from the official
56
+ PaddleOCR inference models, unquantized (float32):
57
+
58
+ | directory | source model | opset |
59
+ |-----------|--------------|-------|
60
+ | `detector/` | `PP-OCRv5_mobile_det` | 17 |
61
+ | `ppocrv6/` | `PP-OCRv6_medium_rec` | 16 |
62
+ | `devanagari/` | `devanagari_PP-OCRv5_mobile_rec` | 16 |
63
+ | `thai/` | `th_PP-OCRv5_mobile_rec` | 16 |
64
+ | `arabic/` | `arabic_PP-OCRv5_mobile_rec` | 16 |
65
+ | `korean/` | `korean_PP-OCRv5_mobile_rec` | 16 |
66
+
67
+ `charset.json` is each model's character table from PaddleOCR, as a JSON array. The recognizer
68
+ output has `charset + 2` classes: index 0 is the CTC blank, then the table, then a space β€”
69
+ the layout PaddleOCR's `CTCLabelDecode` expects.
70
+
71
+ ## Interfaces
72
+
73
+ **Detector** (`det_model.onnx`) β€” input `[1, 3, H, W]`, BGR, long side scaled to 960 and floored
74
+ to a multiple of 32, normalized with ImageNet statistics (mean `0.485/0.456/0.406`, std
75
+ `0.229/0.224/0.225`). Output `[1, 1, H, W]`, a per-pixel probability of text.
76
+
77
+ **Recognizers** (`rec_model.onnx`) β€” input `[1, 3, 48, W]`, RGB, height 48 with width scaled by
78
+ the line's aspect ratio and padded to a multiple of 32, normalized `(x/255 - 0.5) / 0.5`.
79
+ Padding is left at zero *after* normalization (mid-grey), which is how PaddleOCR pads; padding
80
+ with black instead wrecks recognition. Output `[1, T, classes]` logits, greedy CTC decoded.
81
+
82
+ Arabic is read right-to-left: CTC scans left to right and so emits the logically last character
83
+ first. The line is reversed by grapheme cluster, keeping combining marks attached to their base
84
+ letter β€” correcting this took the error on rendered Arabic from 79% to 18%.
85
+
86
+ ## Measured accuracy
87
+
88
+ Character error rate on handwritten sample pages, per line, after detection:
89
+
90
+ | script | CER | note |
91
+ |--------|-----|------|
92
+ | English (neat) | 5-7% | |
93
+ | English (hard hand) | ~14% | |
94
+ | Spanish / French | ~4% | |
95
+ | Chinese | 2% | written in a squared-paper grid |
96
+ | Devanagari | usable | whole lines, most words legible |
97
+ | Thai | 15-25% | |
98
+ | Arabic | 25-35% | words land in the right places and reading order |
99
+ | Korean | 15-25% | several lines nearly verbatim |
100
+
101
+ These are CTC models with **no language model**, which is deliberate: an unreadable crop comes
102
+ back garbled or empty rather than as fluent invented text. A TrOCR alternative scored better on
103
+ neat English (2%) but rewrote what it could not read β€” including inventing liturgical Church
104
+ Slavonic from a blank strip β€” which is the wrong failure mode for a translation tool.
105
+
106
+ ## Not included
107
+
108
+ - **Cyrillic** β€” PaddleOCR's Cyrillic recognizers manage only 76-84% CER on handwriting, so
109
+ those projects use server transcription until a model trained on handwritten lines exists.
110
+ - **Hebrew** β€” no PaddleOCR model.
111
+ - **Greek** β€” not yet wired.
112
+
113
+ ## License
114
+
115
+ Apache-2.0, inherited from PaddleOCR. Please keep the attribution to the PaddleOCR project.