benito47's picture
fixed the readmes
7d10dfa
|
Raw
History Blame Contribute Delete
3.24 kB
---
license: apache-2.0
---
# Introduction
This repository hosts the **PaddleOCR document helper models** — page-orientation
classification, dewarping, and table-structure recognition — for the
[React Native ExecuTorch](https://www.npmjs.com/package/react-native-executorch) library,
fused into **one multi-method `.pte`** per backend for the **ExecuTorch** runtime
(XNNPACK, CoreML, Vulkan). These are document pre/post-processing companions to
[`react-native-executorch-pp-ocrv6`](https://huggingface.co/software-mansion/react-native-executorch-pp-ocrv6) —
not an OCR model on their own.
If you'd like to run these models in your own ExecuTorch runtime, refer to the
[official documentation](https://pytorch.org/executorch/stable/index.html) for setup instructions.
## Methods
The fused `.pte` exposes **four methods** (the `.pte` is pure tensor→tensor; the client
does normalization, `argmax`/`softmax`, grid-sampling and the decode loop). All methods are
**fixed-shape** — the exact input shapes below are also declared in `config.json`; there are
no shape-discovery companion methods on this model.
| method | source model | input | output | purpose |
|---|---|---|---|---|
| `orientation` | [PP-LCNet doc_ori](https://huggingface.co/PaddlePaddle/PP-LCNet_x1_0_doc_ori_safetensors) | `[1,3,224,224]` | `logits[1,4]` | page rotation **0 / 90 / 180 / 270°** (argmax) |
| `dewarp` | [UVDoc](https://huggingface.co/PaddlePaddle/UVDoc_safetensors) | `[1,3,712,488]` | `grid[1,2,45,31]` | sampling grid → `grid_sample` to unwarp a curved/folded page |
| `table_encode` | [SLANeXt](https://huggingface.co/PaddlePaddle/SLANeXt_wired_safetensors) | `[1,3,488,488]` | `feat[1,256,96]` | encode a cropped table image (run **once**) |
| `table_decode_step` | SLANeXt decoder | `(feat[1,256,96], hidden[1,256], onehot[1,50])` | `(probs[1,50], hidden[1,256])` | one **autoregressive** structure-token step |
## Backends, precision & latency (warm)
| backend | target | precision | size | orientation / table_encode / dewarp / decode_step |
|---|---|---|---|---|
| `xnnpack` | CPU | **dynamic int8** (qd8 — lossless; static int8 is lossy on the regressors) | ~28 MB | 2.0 / 30 / 209 / 0.21 ms (Galaxy S24) |
| `coreml` | Apple ANE | weight-only int8 | **11.9 MB** | 0.3 / 1.4 / 4.7 / 0.13 ms (Apple M-series ANE) |
| `vulkan` | Android GPU | fp16, except the table path → XNNPACK (mixed-delegate) | 23 MB | 6.0 / 17 / 66 / 0.21 ms (Galaxy S24) |
- The GPU wins on the heavy CNNs (dewarp 3×); the tiny `orientation` and the dispatch-bound
autoregressive `table_decode_step` are faster on CPU — hence the Vulkan build routes the
table path to XNNPACK.
- `table_decode_step` is always computed at full precision on CPU (autoregressive stability).
## Compatibility
If you intend to use these models outside of React Native ExecuTorch, make sure your runtime is
compatible with the **ExecuTorch** version used to export the `.pte` files. For more details, see
the compatibility note in the
[ExecuTorch GitHub repository](https://github.com/pytorch/executorch/blob/main/runtime/COMPATIBILITY.md).
If you work with React Native ExecuTorch, the library constants guarantee compatibility with the
runtime used behind the scenes.