davanstrien HF Staff commited on
Commit
196316d
·
verified ·
1 Parent(s): 62c242b

Update repo links after rename to davanstrien/page-script-id-hgnet

Browse files
Files changed (1) hide show
  1. README.md +5 -5
README.md CHANGED
@@ -54,12 +54,12 @@ tags:
54
 
55
  # Page script ID (HGNetV2-B0)
56
 
57
- The higher-accuracy sibling to [`davanstrien/page-script-id-v2`](https://huggingface.co/davanstrien/page-script-id-v2) (MobileNetV4-Small). It looks at a full document page (greyscale, `640 × 640`) and returns an independent calibrated probability for each of 21 writing scripts, or `unknown`, without running OCR.
58
 
59
  Built on **`hgnetv2_b0.ssld_stage2_ft_in1k`** (3.99M parameters, 16.0 MB ONNX): **~79 ms** on 1 CPU thread / **~28–36 ms** on 4 threads (~10× faster than ConvNeXt-Tiny on CPU), **621 pages/s** on an A10G in `bf16`. Compared to the 2.52M MobileNetV4-Small variant, it adds **+3.2 pts on photographed documents (88.0%, 97.6% 1-script accuracy)**, higher accuracy on government scans (**90.9%**), **100%** on square-padded Kannada crops, and **91.3%** refusal on real held-out 2026 Sinhala PDFs.
60
 
61
  - **Try it live:** [Page Script ID Demo Space](https://huggingface.co/spaces/davanstrien/page-script-id-demo) (side-by-side CPU comparison with MobileNetV4-Small)
62
- - **Faster sibling:** [`davanstrien/page-script-id-v2`](https://huggingface.co/davanstrien/page-script-id-v2) (MobileNetV4-Small, 2.52M, 33 ms 1t / 11 ms 4t CPU, 1,773 pages/s A10G)
63
 
64
  > **Check the thresholds on your own pages.** The default cut-offs (`0.55` for a script, `0.7314` for `unknown`) were chosen on held-out web-PDF validation pages (95% coverage). On government documents this refuses ~10% and on photographed documents ~29% (with 97.6% accuracy on answered single-script pages). Adjust `unknown_threshold` and `script_threshold` in `config.json` on a sample of your own collection.
65
 
@@ -90,9 +90,9 @@ import torch
90
  from huggingface_hub import hf_hub_download
91
  from PIL import Image
92
 
93
- model_id = "hf-hub:davanstrien/page-script-id-v2-hgnet"
94
  model = timm.create_model(model_id, pretrained=True).eval()
95
- cfg = json.loads(Path(hf_hub_download("davanstrien/page-script-id-v2-hgnet", "config.json")).read_text())["inference"]
96
  size = cfg["input_size"]
97
  mean = torch.tensor(model.pretrained_cfg["mean"]).view(3, 1, 1)
98
  std = torch.tensor(model.pretrained_cfg["std"]).view(3, 1, 1)
@@ -122,7 +122,7 @@ for path, p in zip(sys.argv[1:], probs):
122
 
123
  All test sets are strictly held out from training. Top-1 accuracy is unthresholded (before the `unknown` rule). "2 seeds" is the range over two distilled runs of this recipe (`s0` selected by `r2_val = 92.6%`; `s1` shown for spread).
124
 
125
- | Benchmark | Label | n | Sibling `v2` (MobileNetV4-S) | **This model (`v2-hgnet`)** | `v2-hgnet` (2 seeds) |
126
  |---|---|---:|---:|---:|---:|
127
  | Web PDFs (`r2_test`), text layer | text layer | 2,056 | 94.0% | **94.1%** | 94.0–94.1% |
128
  | Web PDFs (`r2_test`), doc label | doc language | 2,695 | 94.3% | **94.4%** | 94.0–94.4% |
 
54
 
55
  # Page script ID (HGNetV2-B0)
56
 
57
+ The higher-accuracy sibling to [`davanstrien/page-script-id`](https://huggingface.co/davanstrien/page-script-id) (MobileNetV4-Small). It looks at a full document page (greyscale, `640 × 640`) and returns an independent calibrated probability for each of 21 writing scripts, or `unknown`, without running OCR.
58
 
59
  Built on **`hgnetv2_b0.ssld_stage2_ft_in1k`** (3.99M parameters, 16.0 MB ONNX): **~79 ms** on 1 CPU thread / **~28–36 ms** on 4 threads (~10× faster than ConvNeXt-Tiny on CPU), **621 pages/s** on an A10G in `bf16`. Compared to the 2.52M MobileNetV4-Small variant, it adds **+3.2 pts on photographed documents (88.0%, 97.6% 1-script accuracy)**, higher accuracy on government scans (**90.9%**), **100%** on square-padded Kannada crops, and **91.3%** refusal on real held-out 2026 Sinhala PDFs.
60
 
61
  - **Try it live:** [Page Script ID Demo Space](https://huggingface.co/spaces/davanstrien/page-script-id-demo) (side-by-side CPU comparison with MobileNetV4-Small)
62
+ - **Faster sibling:** [`davanstrien/page-script-id`](https://huggingface.co/davanstrien/page-script-id) (MobileNetV4-Small, 2.52M, 33 ms 1t / 11 ms 4t CPU, 1,773 pages/s A10G)
63
 
64
  > **Check the thresholds on your own pages.** The default cut-offs (`0.55` for a script, `0.7314` for `unknown`) were chosen on held-out web-PDF validation pages (95% coverage). On government documents this refuses ~10% and on photographed documents ~29% (with 97.6% accuracy on answered single-script pages). Adjust `unknown_threshold` and `script_threshold` in `config.json` on a sample of your own collection.
65
 
 
90
  from huggingface_hub import hf_hub_download
91
  from PIL import Image
92
 
93
+ model_id = "hf-hub:davanstrien/page-script-id-hgnet"
94
  model = timm.create_model(model_id, pretrained=True).eval()
95
+ cfg = json.loads(Path(hf_hub_download("davanstrien/page-script-id-hgnet", "config.json")).read_text())["inference"]
96
  size = cfg["input_size"]
97
  mean = torch.tensor(model.pretrained_cfg["mean"]).view(3, 1, 1)
98
  std = torch.tensor(model.pretrained_cfg["std"]).view(3, 1, 1)
 
122
 
123
  All test sets are strictly held out from training. Top-1 accuracy is unthresholded (before the `unknown` rule). "2 seeds" is the range over two distilled runs of this recipe (`s0` selected by `r2_val = 92.6%`; `s1` shown for spread).
124
 
125
+ | Benchmark | Label | n | Sibling `page-script-id` (MobileNetV4-S) | **This model (`page-script-id-hgnet`)** | `page-script-id-hgnet` (2 seeds) |
126
  |---|---|---:|---:|---:|---:|
127
  | Web PDFs (`r2_test`), text layer | text layer | 2,056 | 94.0% | **94.1%** | 94.0–94.1% |
128
  | Web PDFs (`r2_test`), doc label | doc language | 2,695 | 94.3% | **94.4%** | 94.0–94.4% |