Flor commited on
Commit
79dd086
Β·
verified Β·
1 Parent(s): bcf9c84

card: update from fastforks 1cbf1671

Browse files
Files changed (1) hide show
  1. README.md +109 -0
README.md ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: "fastforks"
3
+ pipeline_tag: "image-to-text"
4
+ license: "apache-2.0"
5
+ tags:
6
+ - "ocr"
7
+ - "text-recognition"
8
+ - "text-detection"
9
+ - "cuda"
10
+ - "pytorch"
11
+ - "fastforks"
12
+ - "fastforks-card"
13
+ base_model:
14
+ - "PaddlePaddle/PP-OCRv5_mobile_det"
15
+ - "PaddlePaddle/PP-OCRv5_mobile_rec"
16
+ - "PaddlePaddle/PP-OCRv5_server_det"
17
+ - "PaddlePaddle/PP-OCRv5_server_rec"
18
+ ---
19
+ # PP-OCRv5 (server / mobile) (fastforks)
20
+
21
+ PP-OCRv5 (PaddleOCR 3, Baidu 2025): a DB text detector (PP-HGNetV2 + LKPAN for server, PP-LCNetV3 + RSE-FPN for mobile) finds text lines of any orientation as quads; each line is cut out with a perspective warp and read by a CTC recogniser (PP-HGNetV2 / PP-LCNetV3 with an SVTR neck) over 18 383 characters (simplified and traditional Chinese, English, Japanese, pinyin). Inference as PaddleX's OCR pipeline without the document unwarping and the text-line orientation classifier. The portable `module()` is the detector with its normalisation.
22
+
23
+ This repo is the model card only: it holds no weights. fastforks downloads the authors' weights from the links below and checks them against the SHA-256 in the model card. Code: <https://github.com/kleinicke/fastforks>. Kernels for the `kernels` backend: <https://huggingface.co/fastforks/kernels>. Original code: <https://github.com/PaddlePaddle/PaddleOCR> at `dab3fe353790`.
24
+
25
+ Author weight repos: <https://huggingface.co/PaddlePaddle/PP-OCRv5_mobile_det>, <https://huggingface.co/PaddlePaddle/PP-OCRv5_mobile_rec>, <https://huggingface.co/PaddlePaddle/PP-OCRv5_server_det>, <https://huggingface.co/PaddlePaddle/PP-OCRv5_server_rec>.
26
+
27
+ Task: ocr. Tier: experimental. Outputs: `boxes`, `texts`, `scores`. Backends: `portable`.
28
+
29
+ Input: one RGB image. Output: the text lines in reading order: a quad `[N, 4, 2]` per line, its text and a confidence `[N]` (text detector + recogniser; recognisers alone read the whole image as one line).
30
+
31
+ ## Variants
32
+
33
+ Weights are the authors' files (not hosted here). SHA-256 shortened to 12 hex digits; the full hashes are in [`card.toml`](https://github.com/kleinicke/fastforks/blob/main/src/fastforks/ocr/models/ppocrv5/card.toml).
34
+
35
+ | variant | weights (author link) | SHA-256 | weights licence | commercial use |
36
+ |---|---|---|---|---|
37
+ | `ppocrv5-mobile@1` | [PP-OCRv5_mobile_det/inference.json](https://huggingface.co/PaddlePaddle/PP-OCRv5_mobile_det/resolve/0d63e78e2b680928f6b1747d76a08db6e645efb7/inference.json)<br>[PP-OCRv5_mobile_det/inference.pdiparams](https://huggingface.co/PaddlePaddle/PP-OCRv5_mobile_det/resolve/0d63e78e2b680928f6b1747d76a08db6e645efb7/inference.pdiparams)<br>[PP-OCRv5_mobile_rec/inference.json](https://huggingface.co/PaddlePaddle/PP-OCRv5_mobile_rec/resolve/682f20538d8c086cb2128e5cfac775e6c4904e85/inference.json)<br>[PP-OCRv5_mobile_rec/inference.pdiparams](https://huggingface.co/PaddlePaddle/PP-OCRv5_mobile_rec/resolve/682f20538d8c086cb2128e5cfac775e6c4904e85/inference.pdiparams)<br>[PP-OCRv5_mobile_rec/config.json](https://huggingface.co/PaddlePaddle/PP-OCRv5_mobile_rec/resolve/682f20538d8c086cb2128e5cfac775e6c4904e85/config.json) | `05feef1acb00`<br>`afa1820cb16c`<br>`24587345250c`<br>`2460da908759`<br>`6df1587ae056` | Apache-2.0 | yes |
38
+ | `ppocrv5-server@1` | [PP-OCRv5_server_det/inference.json](https://huggingface.co/PaddlePaddle/PP-OCRv5_server_det/resolve/ca867c897ecbca8873081573a802ad70d499cb94/inference.json)<br>[PP-OCRv5_server_det/inference.pdiparams](https://huggingface.co/PaddlePaddle/PP-OCRv5_server_det/resolve/ca867c897ecbca8873081573a802ad70d499cb94/inference.pdiparams)<br>[PP-OCRv5_server_rec/inference.json](https://huggingface.co/PaddlePaddle/PP-OCRv5_server_rec/resolve/b26c3587fda8da3c8ec0ce357214b4d661ff1558/inference.json)<br>[PP-OCRv5_server_rec/inference.pdiparams](https://huggingface.co/PaddlePaddle/PP-OCRv5_server_rec/resolve/b26c3587fda8da3c8ec0ce357214b4d661ff1558/inference.pdiparams)<br>[PP-OCRv5_server_rec/config.json](https://huggingface.co/PaddlePaddle/PP-OCRv5_server_rec/resolve/b26c3587fda8da3c8ec0ce357214b4d661ff1558/config.json) | `af5876933d88`<br>`183146fe9d99`<br>`8e6e12e5d425`<br>`63853f062a5f`<br>`6a780e213d7a` | Apache-2.0 | yes |
39
+
40
+ ## Licence
41
+
42
+ Original-code strings, recorded as they are (research-use package; check them before any other use). Code: Apache-2.0. Licence files: `LICENSE`.
43
+
44
+ Training data: The PP-OCRv5 technical report describes public and synthetic text data plus Baidu's own data; the exact sets are not listed..
45
+
46
+ Licence evidence: https://github.com/PaddlePaddle/PaddleOCR/blob/dab3fe35379033fdcb2d0e9572fac0b36c9a9ebf/LICENSE ; https://huggingface.co/PaddlePaddle/PP-OCRv5_server_det
47
+
48
+ ## Input size
49
+
50
+ any H x W >= 32, padded to a multiple of 32
51
+ Tested up to (portable, fp16, RTX 5060 Ti 16 GB): `ppocrv5-mobile` 3000x4000 (1.4 GiB peak allocated, 2.3 reserved); `ppocrv5-server` 3000x4000 (7.1 GiB peak allocated, 9.8 reserved)
52
+
53
+ ## Speed and memory
54
+
55
+ ### Ocr, synthetic
56
+
57
+ | model | input | time (ms): original fp32 | original | portable | peak memory (MiB, allocated / reserved): original | portable |
58
+ | --- | --- | --- | --- | --- | --- | --- |
59
+ | `ppocrv5-mobile` | 1080x1920 | 619 | 418 | 153 | 393 / 1005 | 289 / 448 |
60
+ | `ppocrv5-server` | 1080x1920 | – | 762 (fp32) | 277 | 2355 / 2901 | 1357 / 1452 |
61
+
62
+ ### Startup and first call
63
+
64
+ | model | load (s): original | portable | kernels | first call (s): original | portable | kernels |
65
+ | --- | --- | --- | --- | --- | --- | --- |
66
+ | `ppocrv5-mobile` | 1.51 | 0.27 | – | 1.82 | 2.82 | – |
67
+ | `ppocrv5-server` | 2.07 | 0.56 | – | 2.03 | 1.87 | – |
68
+
69
+ ### torch.compile and TensorRT
70
+
71
+ | model | input | time: portable | compile | TensorRT fp16 | kernels | preparation: compile (cold first call) | ONNX + engine build | peak MiB (alloc / reserved): portable | compile | kernels | TensorRT (engine + torch) |
72
+ | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
73
+ | `ppocrv5-mobile` | 1080x1920 | 153 ms | 115 ms | 2.68 ms | – | 75.0 s | 156 s | 289 / 448 | 292 / 448 | – | 241 / 268 |
74
+ | `ppocrv5-server` | 1080x1920 | 277 ms | 277 ms | 25.1 ms | – | 105 s | 40.6 s | 1357 / 1452 | 958 / 1132 | – | 1131 / 1146 |
75
+
76
+ Fixed-size cells: time (ms) / peak allocated / peak reserved memory (MiB).
77
+
78
+ Hardware, protocol and caveats: [benchmarks](https://github.com/kleinicke/fastforks/blob/main/docs/benchmarks.md) (RTX 5060 Ti 16 GB, sm_120). Original = the original code named above at the precision of portable (fp16, or `(fp32)` where fp16 is unsupported or not finite); original fp32 = its default fp32 run. Peak memory is the torch allocator's.
79
+
80
+ ## Accuracy
81
+
82
+ ### Parity with the original code
83
+
84
+ Every variant is checked against reference outputs of the original code at its pinned commit. CPU, float32: max |diff| <= 0.001 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.5 and p99 <= 1.5 (absolute error of the output `boxes`).
85
+
86
+ ## Limitations
87
+
88
+ - No document orientation / unwarping and no text-line orientation classifier (upside-down lines are read as they are).
89
+ - The DB post-processing runs on the CPU (OpenCV-exact geometry); hole contours of the binary map are not boxed (upstream boxes them too; they rarely pass `box_threshold`).
90
+
91
+ ## Usage
92
+
93
+ ```python
94
+ from fastforks import ocr
95
+
96
+ model = ocr.load("ppocrv5-mobile") # mode="auto": the preferred backend from recorded measurements
97
+ result = model("receipt.jpg")
98
+ result.texts # the text lines in reading order
99
+ result.boxes, result.scores # [N, 4, 2] quads in input pixels, [N] confidences
100
+ result.backend # what ran, e.g. Backend(mode='portable', device='cuda:0', dtype='float16')
101
+ ```
102
+
103
+ Install with `pip install fastforks` (see <https://github.com/kleinicke/fastforks>). Other variants: `ppocrv5-mobile`, `ppocrv5-server`.
104
+
105
+ ## Kernels backend
106
+
107
+ No kernels backend: cuDNN convolutions are the networks; the time outside them is the per-line crop / resize and the CPU box geometry.
108
+
109
+ <!-- staged from fastforks 1cbf1671 (2026-11-15) -->