Flor commited on
Commit
f862fbe
·
verified ·
1 Parent(s): 874a9dd

card: update from fastforks 1cbf1671

Browse files
Files changed (1) hide show
  1. README.md +101 -0
README.md ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: "fastforks"
3
+ pipeline_tag: "image-to-text"
4
+ license: "other"
5
+ license_name: "see-model-card"
6
+ license_link: "https://github.com/baudm/parseq/blob/1902db043c029a7e03a3818c616c06600af574be/LICENSE"
7
+ tags:
8
+ - "ocr"
9
+ - "text-recognition"
10
+ - "text-detection"
11
+ - "cuda"
12
+ - "pytorch"
13
+ - "fastforks"
14
+ - "fastforks-card"
15
+ ---
16
+ # PARSeq (scene text recognition) (fastforks)
17
+
18
+ PARSeq (Bautista and Atienza, ECCV 2022): a ViT encoder over the word crop (32 x 128) and one two-stream Transformer decoder layer trained with permuted autoregressive sequence modelling; reads one cropped word or short line (94 characters: Latin letters, digits, ASCII punctuation; no space). Greedy autoregressive decoding plus one refinement pass, as upstream `read.py`. A recogniser only: the whole input is one line (one quad over the image); pair it with a detector (e.g. `ppocrv5-mobile` boxes) for full pages.
19
+
20
+ 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/baudm/parseq> at `1902db043c02`.
21
+
22
+ Task: ocr. Tier: experimental. Outputs: `boxes`, `texts`, `scores`. Backends: `portable`.
23
+
24
+ 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).
25
+
26
+ ## Variants
27
+
28
+ 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/parseq/card.toml).
29
+
30
+ | variant | weights (author link) | SHA-256 | weights licence | commercial use |
31
+ |---|---|---|---|---|
32
+ | `parseq@1` | [parseq-bb5792a6.pt](https://github.com/baudm/parseq/releases/download/v1.0.0/parseq-bb5792a6.pt) | `bb5792a68e36` | Apache-2.0 (assumed from code) | yes |
33
+ | `parseq-tiny@1` | [parseq_tiny-e7a21b54.pt](https://github.com/baudm/parseq/releases/download/v1.0.0/parseq_tiny-e7a21b54.pt) | `e7a21b543c98` | Apache-2.0 (assumed from code) | yes |
34
+
35
+ ## Licence
36
+
37
+ Original-code strings, recorded as they are (research-use package; check them before any other use). Code: Apache-2.0. Licence files: `LICENSE`, `NOTICE`.
38
+
39
+ Code licence: Apache-2.0; the authors do not state a separate weights licence.
40
+
41
+ Training data: The README does not say which data the released checkpoints were trained on; the paper's best models use its real-data union (COCO-Text, RCTW17, Uber-Text, ArT, LSVT, MLT19, ReCTS, TextOCR, OpenVINO; Datasets.md)..
42
+
43
+ Licence evidence: <https://github.com/baudm/parseq/blob/1902db043c029a7e03a3818c616c06600af574be/LICENSE>
44
+
45
+ ## Input size
46
+
47
+ any H x W >= 32, padded to a multiple of 32
48
+ Tested up to (portable, fp16, RTX 5060 Ti 16 GB): `parseq` 3000x4000 (0.3 GiB peak allocated, 0.3 reserved); `parseq-tiny` 3000x4000 (0.3 GiB peak allocated, 0.3 reserved)
49
+
50
+ ## Speed and memory
51
+
52
+ ### Ocr, synthetic
53
+
54
+ | model | input | time (ms): original fp32 | original | portable | peak memory (MiB, allocated / reserved): original | portable |
55
+ | --- | --- | --- | --- | --- | --- | --- |
56
+ | `parseq` | 32x128 | 15.9 | 19.6 | 3.62 | 126 / 144 | 79 / 100 |
57
+ | `parseq-tiny` | 32x128 | 14.6 | 18.0 | 2.10 | 56 / 58 | 44 / 54 |
58
+
59
+ ### Startup and first call
60
+
61
+ | model | load (s): original | portable | kernels | first call (s): original | portable | kernels |
62
+ | --- | --- | --- | --- | --- | --- | --- |
63
+ | `parseq` | 0.53 (32x128) | 1.44 (32x128) | – | 1.04 (32x128) | 0.26 (32x128) | – |
64
+ | `parseq-tiny` | 0.34 (32x128) | 0.74 (32x128) | – | 0.95 (32x128) | 0.20 (32x128) | – |
65
+
66
+ ### torch.compile and TensorRT
67
+
68
+ | 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) |
69
+ | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
70
+ | `parseq` | 32x128 | 3.62 ms | 8.80 ms | 1.67 ms | – | 19.9 s | 114 s | 79 / 100 | 111 / 118 | – | 148 / 168 |
71
+ | `parseq-tiny` | 32x128 | 2.10 ms | 8.09 ms | 1.68 ms | – | 17.2 s | 96.8 s | 44 / 54 | 76 / 94 | – | 80 / 88 |
72
+
73
+ Fixed-size cells: time (ms) / peak allocated / peak reserved memory (MiB).
74
+
75
+ 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.
76
+
77
+ ## Accuracy
78
+
79
+ ### Parity with the original code
80
+
81
+ 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.01 and p99 <= 0.01 (absolute error of the output `boxes`).
82
+
83
+ ## Usage
84
+
85
+ ```python
86
+ from fastforks import ocr
87
+
88
+ model = ocr.load("parseq") # mode="auto": the preferred backend from recorded measurements
89
+ result = model("receipt.jpg")
90
+ result.texts # the text lines in reading order
91
+ result.boxes, result.scores # [N, 4, 2] quads in input pixels, [N] confidences
92
+ result.backend # what ran, e.g. Backend(mode='portable', device='cuda:0', dtype='float16')
93
+ ```
94
+
95
+ Install with `pip install fastforks` (see <https://github.com/kleinicke/fastforks>). Other variants: `parseq`, `parseq-tiny`.
96
+
97
+ ## Kernels backend
98
+
99
+ No kernels backend: the 26-step decoding loop is launch-bound, not kernel-bound, and portable already replays it as one CUDA graph (`cuda_graphs`, exports unchanged: `module()` is the plain network): 12.6 -> 3.6 ms (parseq) and 11.6 -> 2.1 ms (parseq-tiny) vs the original 19.6 / 18.0 ms fp16, same logits and memory; SDPA / cuBLAS are already the compute and no library in the manifests helps, so a kernels mode would only repeat the graph (measured 2026-11-15).
100
+
101
+ <!-- staged from fastforks 1cbf1671 (2026-11-15) -->