mlboydaisuke commited on
Commit
1877087
·
verified ·
1 Parent(s): 5c5af03

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +85 -0
README.md ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ tags:
4
+ - executorch
5
+ - xnnpack
6
+ - pte
7
+ - on-device
8
+ - object-detection
9
+ - text-detection
10
+ ---
11
+ # docTR DB-MobileNetV3-Large — ExecuTorch
12
+
13
+ Text **detection**: where the words are. The other half of the pair is
14
+ [CRNN-MobileNetV3-Small](https://huggingface.co/mlboydaisuke/docTR-CRNN-MobileNetV3-Small-ExecuTorch),
15
+ which reads them.
16
+
17
+ - **Source**: [mindee/doctr](https://github.com/mindee/doctr) `db_mobilenet_v3_large`,
18
+ 4.2M parameters
19
+ - **License**: Apache-2.0
20
+ - **Input**: `[1, 3, 1024, 1024]`, normalised with docTR's own mean (0.798, 0.785, 0.772)
21
+ and std (0.264, 0.2749, 0.287) — not ImageNet's
22
+ - **Output**: `[1, 1, 1024, 1024]`, one probability per pixel of belonging to a word
23
+
24
+ Differentiable Binarization returns a *shrunk* region per word; turning the map into boxes
25
+ is docTR's `postprocessor`, which unshrinks the polygons. That stays on the caller, the way
26
+ the shelf's other detectors leave NMS outside.
27
+
28
+ ## Verification (Mac arm64, 2026-08-23)
29
+
30
+ | build | size | latency | worst corr |
31
+ |---|---|---|---|
32
+ | XNNPACK fp32 | 16.1 MB | 46.9 ms | 1.000000 |
33
+ | Core ML fp32 | 8.6 MB | **13.1 ms** | 0.999714 |
34
+
35
+ Eager fp32 for the same input is 309 ms. Delegation is 100% (224/224 ops, one subgraph).
36
+
37
+ **Read end to end**, both `.pte` files through docTR's own post-processing, on a London
38
+ street photograph (`convert/check_doctr.py`):
39
+
40
+ ```
41
+ boxes: 10
42
+ read: TIUZABXPRESS | Chrisiophers | Place | STREE! | LAG | BAR!
43
+ ```
44
+
45
+ The signs in that photograph say PIZZA EXPRESS and Christopher's Place. Approximate, and
46
+ that is the point of quoting it: correlation against eager says the tensors match, and says
47
+ nothing about whether the map thresholds to any boxes at all.
48
+
49
+ ## Not shipped, and why
50
+
51
+ - **int8**: worst corr **0.627**. It is 4.3 MB against 16.1, which is the trade this shelf
52
+ would normally take, but not at that number.
53
+ - **fp16**: corr 0.999879 and it passes, but the file is the same 16.1 MB — the weights are
54
+ convolutions XNNPACK already runs in fp32, so there is nothing to buy.
55
+
56
+ ## The mistake worth repeating back
57
+
58
+ The harness gates on correlation against eager for **random** input. This file scored
59
+ 1.000000 there and then produced a map that thresholded to zero boxes on a real photograph.
60
+ The cause was not the export:
61
+
62
+ ```
63
+ corr pte max pixels > 0.3
64
+ as built 0.024711 0.2385 0
65
+ .contiguous() 1.000000 0.5639 1816
66
+ ```
67
+
68
+ `np.transpose` leaves the array in HWC order with permuted strides, and ExecuTorch reads a
69
+ tensor in memory order rather than by its strides. Random and all-zero inputs are
70
+ contiguous, so the gate never saw it. Anything built with `transpose` needs
71
+ `np.ascontiguousarray` before it reaches a `.pte`.
72
+
73
+ ## Conversion
74
+
75
+ ```bash
76
+ python convert/export_doctr.py detect
77
+ python convert/check_doctr.py <image>
78
+ ```
79
+
80
+ docTR's `forward` runs its post-processing in numpy whether or not it was asked to, which
81
+ `torch.export` refuses (`.numpy() is not supported for tensor subclasses`). The model
82
+ carries an `exportable` flag that skips it and returns raw logits; the wrapper sets that and
83
+ applies the sigmoid itself.
84
+
85
+ (conversion scripts: [executorch-models](https://github.com/john-rocky/executorch-models))