msluszniak commited on
Commit
397738f
Β·
verified Β·
1 Parent(s): 82ab60f

Apply the model card standard

Browse files
Files changed (1) hide show
  1. README.md +41 -73
README.md CHANGED
@@ -4,80 +4,54 @@ pipeline_tag: image-to-text
4
  library_name: executorch
5
  ---
6
 
7
- # Introduction
8
 
9
- This repository hosts [PaddleOCR PP-OCRv6](https://github.com/PaddlePaddle/PaddleOCR) (the
10
- [detector](https://huggingface.co/PaddlePaddle/PP-OCRv6_small_det_safetensors) +
11
- [recognizer](https://huggingface.co/PaddlePaddle/PP-OCRv6_small_rec_safetensors)) for the
12
- [React Native ExecuTorch](https://www.npmjs.com/package/react-native-executorch) library,
13
- exported to `.pte` for the **ExecuTorch** runtime (XNNPACK, CoreML and Vulkan backends).
14
 
15
- If you'd like to run these models in your own ExecuTorch runtime, refer to the
16
- [official documentation](https://pytorch.org/executorch/stable/index.html) for setup instructions.
17
 
18
- PP-OCRv6 is the **primary** OCR pipeline β€” smallest and fastest. It ships as **one fused
19
- `.pte`** per backend with a single **dynamic** `detect` and `recognize` method each (no
20
- per-size method buckets). The `.pte` is a pure tensor→tensor function; all pre/post-processing
21
- (resize, normalize, DBNet box decode, perspective crop, CTC decode) is the client's job and is
22
- driven by `config.json`. One model covers **all languages** (18 709-entry multilingual charset).
23
 
24
- ## Repository layout
25
 
26
- ```
27
- <backend>/config.json # per-backend spec (see the schema link inside)
28
- <backend>/pp_ocrv6_<backend>_<precision>.pte
29
- charset.txt # 18 709 entries; charset[i] -> logit i+1, blank = 0
30
- ```
31
-
32
- ## Methods & I/O contract
33
-
34
- | method | input | output |
35
- |---|---|---|
36
- | `detect` (DBNet) | `[1,3,H,W]` f32 RGB, **ImageNet-normalized by the client**: `(x/255 βˆ’ mean)/std`, `mean=[0.485,0.456,0.406]`, `std=[0.229,0.224,0.225]` | `[1,1,H,W]` probability map (sigmoid baked) |
37
- | `recognize` (SVTR) | `[1,3,48,W]` f32 RGB, client-normalized `(x/255 βˆ’ 0.5)/0.5` | `[1,W/8,18710]` probs (softmax baked); `charset[i]` β†’ logit `i+1`, blank = 0 |
38
-
39
- **Nothing is baked for input normalization** β€” the client normalizes before calling.
40
- Note the two methods use *different* norms (ImageNet for detect, `0.5/0.5` for recognize).
41
-
42
- ## Shape discovery (`get_model_schema`)
43
 
44
- Every `.pte` exports one no-arg constant method, **`get_model_schema`**, returning a JSON
45
- `ModelSpec` string: per method, the input and output parameter specs (dtype plus a domain per
46
- dimension β€” `constant`, `range` with `{min, max, step}`, or `enum` with explicit `choices`) and
47
- the runtime constraints the method declares over its dimensions. Methods absent from the JSON
48
- are fully static and described by ExecuTorch's own `MethodMeta`. The schema is validated
49
- against
50
- [`config.schema.json`'s `ModelSpec`](https://huggingface.co/software-mansion/react-native-executorch-spec)
51
- counterpart in the library at load time. The older `get_dynamic_dims_<m>` / `get_enum_shapes_<m>`
52
- companion methods are **gone** β€” everything they carried now lives in this one document.
53
 
54
- | backend | `detect` H, W | `recognize` W (H fixed 48) |
55
- |---|---|---|
56
- | `xnnpack`, `vulkan` | `range` `[640, 1280]` step 32 | `range` `[160, 1280]` step 8 |
57
- | `coreml` | `enum` `640, 960, 1280` per dimension | `enum` `160, 320, 480, 640, 1280` |
58
-
59
- `recognize` additionally declares a **linear runtime constraint** tying its input width to its
60
- CTC timestep count β€” `width = 8 Γ— timesteps + 0` β€” so a client can size the probs output for
61
- whatever width it picks instead of inferring a ratio.
 
 
 
62
 
63
- ## Backends
64
 
65
- | backend | target | detect | recognize | warm latency (detect @960Β² / recognize) |
66
- |---|---|---|---|---|
67
- | `xnnpack` | CPU | static int8, true-dynamic | fp32, true-dynamic | ~28 ms recognize (Galaxy S24) |
68
- | `coreml` | Apple ANE | weight-only int8, enumerated | weight-only int8, enumerated | ~12–15 ms / ~2 ms (Apple M-series ANE) |
69
- | `vulkan` | Android GPU | fp16, true-dynamic (resize) | fp32 on **XNNPACK** (mixed-delegate) | ~73 ms / ~27 ms (Galaxy S24, Xclipse 940) |
70
 
71
- > **Vulkan is mixed-delegate**: DBNet detects on the GPU, the SVTR recognizer runs on the CPU
72
- > (XNNPACK) β€” the 18 709-token vocab head is not Vulkan-safe, and int8 SVTR is lossy, so the
73
- > recognizer stays fp32 on CPU for correctness.
74
 
75
- > **Why int8 detect but fp32 recognize?** The detector is static-activation int8, calibrated on
76
- > real pages at 1280. It was previously shipped as fp32 on the belief that int8 was unstable
77
- > across dynamic input sizes; re-measured in 2026-08 that no longer holds (correlation 0.956 to
78
- > 0.994 against eager fp32 from 640 to 1280 square, best at 1280), and on-device the int8 build
79
- > returns the same detections about 15% faster end to end at 23.9 MB instead of 31.1 MB. The
80
- > SVTR recognizer stays fp32: int8 is lossy on its attention stack.
81
 
82
  ## CoreML notes (iOS)
83
 
@@ -87,14 +61,8 @@ whatever width it picks instead of inferring a ratio.
87
  - First-ever load on a device triggers a one-time per-shape ANE specialization (OS-cached
88
  afterwards) β€” warm each model once after install.
89
 
90
- ## Compatibility
91
-
92
- If you intend to use these models outside of React Native ExecuTorch, make sure your runtime is
93
- compatible with the **ExecuTorch** version used to export the `.pte` files. For more details, see
94
- the compatibility note in the
95
- [ExecuTorch GitHub repository](https://github.com/pytorch/executorch/blob/main/runtime/COMPATIBILITY.md).
96
- If you work with React Native ExecuTorch, the library constants guarantee compatibility with the
97
- runtime used behind the scenes.
98
 
99
- These models were exported with ExecuTorch 1.3.1 and **no forward compatibility** is
100
- guaranteed; older runtimes may not load them.
 
 
4
  library_name: executorch
5
  ---
6
 
7
+ # pp-ocrv6
8
 
9
+ This repository hosts the **pp-ocrv6** models exported for the
10
+ [React Native ExecuTorch](https://www.npmjs.com/package/react-native-executorch)
11
+ library as ExecuTorch `.pte` programs, ready to run on device.
 
 
12
 
13
+ Upstream models:
 
14
 
15
+ - [PaddleOCR PP-OCRv6](https://github.com/PaddlePaddle/PaddleOCR)
16
+ - [detector](https://huggingface.co/PaddlePaddle/PP-OCRv6_small_det_safetensors)
17
+ - [recognizer](https://huggingface.co/PaddlePaddle/PP-OCRv6_small_rec_safetensors)
 
 
18
 
19
+ ## Variants
20
 
21
+ | Path | Backend | Precision |
22
+ | --- | --- | --- |
23
+ | `coreml/pp_ocrv6_coreml_int8.pte` | coreml | int8 |
24
+ | `vulkan/pp_ocrv6_vulkan_fp16.pte` | vulkan | fp16 |
25
+ | `xnnpack/pp_ocrv6_xnnpack_fp32.pte` | xnnpack | fp32 |
26
+ | `xnnpack/pp_ocrv6_xnnpack_int8.pte` | xnnpack | int8 |
 
 
 
 
 
 
 
 
 
 
 
27
 
28
+ ## Repository structure
 
 
 
 
 
 
 
 
29
 
30
+ ```
31
+ charset.json 128 kB
32
+ config.json 30 B
33
+ coreml/config.json 1.3 kB
34
+ coreml/pp_ocrv6_coreml_int8.pte 7.9 MB
35
+ vulkan/config.json 1.3 kB
36
+ vulkan/pp_ocrv6_vulkan_fp16.pte 25.0 MB
37
+ xnnpack/config.json 2.3 kB
38
+ xnnpack/pp_ocrv6_xnnpack_fp32.pte 29.6 MB
39
+ xnnpack/pp_ocrv6_xnnpack_int8.pte 22.8 MB
40
+ ```
41
 
42
+ ## Compatibility
43
 
44
+ These files are published for the **ExecuTorch v1.4.1** runtime. ExecuTorch
45
+ gives no forward compatibility guarantee, so an older runtime may fail to load
46
+ them.
 
 
47
 
48
+ To use them in React Native ExecuTorch, pass the model constant shipped in the
49
+ library's model registry to the corresponding task pipeline. See the
50
+ [documentation](https://docs.swmansion.com/react-native-executorch/docs/fundamentals/loading-models).
51
 
52
+ To load these files in your own ExecuTorch runtime, read the
53
+ [compatibility note](https://github.com/pytorch/executorch/blob/main/runtime/COMPATIBILITY.md)
54
+ first.
 
 
 
55
 
56
  ## CoreML notes (iOS)
57
 
 
61
  - First-ever load on a device triggers a one-time per-shape ANE specialization (OS-cached
62
  afterwards) β€” warm each model once after install.
63
 
64
+ ## Model details
 
 
 
 
 
 
 
65
 
66
+ The recognizer's output is a probability distribution over the charset with
67
+ softmax already baked in. Index `0` is the CTC blank, so `charset[i]`
68
+ corresponds to logit `i + 1`.