File size: 6,137 Bytes
f862fbe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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
95
96
97
98
99
100
101
102
---
library_name: "fastforks"
pipeline_tag: "image-to-text"
license: "other"
license_name: "see-model-card"
license_link: "https://github.com/baudm/parseq/blob/1902db043c029a7e03a3818c616c06600af574be/LICENSE"
tags:
- "ocr"
- "text-recognition"
- "text-detection"
- "cuda"
- "pytorch"
- "fastforks"
- "fastforks-card"
---
# PARSeq (scene text recognition) (fastforks)

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.

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`.

Task: ocr. Tier: experimental. Outputs: `boxes`, `texts`, `scores`. Backends: `portable`.

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).

## Variants

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).

| variant | weights (author link) | SHA-256 | weights licence | commercial use |
|---|---|---|---|---|
| `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 |
| `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 |

## Licence

Original-code strings, recorded as they are (research-use package; check them before any other use). Code: Apache-2.0. Licence files: `LICENSE`, `NOTICE`.

Code licence: Apache-2.0; the authors do not state a separate weights licence.

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)..

Licence evidence: <https://github.com/baudm/parseq/blob/1902db043c029a7e03a3818c616c06600af574be/LICENSE>

## Input size

any H x W >= 32, padded to a multiple of 32
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)

## Speed and memory

### Ocr, synthetic

| model | input | time (ms): original fp32 | original | portable | peak memory (MiB, allocated / reserved): original | portable |
| --- | --- | --- | --- | --- | --- | --- |
| `parseq` | 32x128 | 15.9 | 19.6 | 3.62 | 126 / 144 | 79 / 100 |
| `parseq-tiny` | 32x128 | 14.6 | 18.0 | 2.10 | 56 / 58 | 44 / 54 |

### Startup and first call

| model | load (s): original | portable | kernels | first call (s): original | portable | kernels |
| --- | --- | --- | --- | --- | --- | --- |
| `parseq` | 0.53 (32x128) | 1.44 (32x128) | – | 1.04 (32x128) | 0.26 (32x128) | – |
| `parseq-tiny` | 0.34 (32x128) | 0.74 (32x128) | – | 0.95 (32x128) | 0.20 (32x128) | – |

### torch.compile and TensorRT

| 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) |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| `parseq` | 32x128 | 3.62 ms | 8.80 ms | 1.67 ms | – | 19.9 s | 114 s | 79 / 100 | 111 / 118 | – | 148 / 168 |
| `parseq-tiny` | 32x128 | 2.10 ms | 8.09 ms | 1.68 ms | – | 17.2 s | 96.8 s | 44 / 54 | 76 / 94 | – | 80 / 88 |

Fixed-size cells: time (ms) / peak allocated / peak reserved memory (MiB).

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.

## Accuracy

### Parity with the original code

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`).

## Usage

```python
from fastforks import ocr

model = ocr.load("parseq")  # mode="auto": the preferred backend from recorded measurements
result = model("receipt.jpg")
result.texts  # the text lines in reading order
result.boxes, result.scores  # [N, 4, 2] quads in input pixels, [N] confidences
result.backend  # what ran, e.g. Backend(mode='portable', device='cuda:0', dtype='float16')
```

Install with `pip install fastforks` (see <https://github.com/kleinicke/fastforks>). Other variants: `parseq`, `parseq-tiny`.

## Kernels backend

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).

<!-- staged from fastforks 1cbf1671 (2026-11-15) -->