regnetx-8gf-polyline-hebrew-samaritan
Hebrew + Samaritan polyline baseline detector: RegNetX-8GF + D-FINE HybridEncoder + PolylineTransformer.
Hub repo:
johnlockejrr/regnetx-8gf-polyline-hebrew-samaritan
Primary file:best_cbad_f1.safetensors(~208 MB)
Paper (Zenodo preprint): doi:10.5281/zenodo.22059333
Recommended inference confidence:0.40(CLI--conf 0.4).0.50is a close alternative.
Code: regnetx-det (standalone sibling of dfine-det and convnextv2-det).
This is a domain fine-tune on Hebrew/Samaritan manuscripts from the native RegNetX Stage-0 foundation. For the multiscript Stage-0 checkpoint, see johnlockejrr/regnetx-8gf-polyline-baseline-stage0 (cbad_f1_max ≈ 0.936 on the shared Stage-0 val split; 0.953 zero-shot on this Hebrew+Samaritan val).
Model summary
| Architecture | RegNetXPolylineModel — timm RegNetX-8GF → HybridEncoder (C3/C4/C5) → PolylineTransformer |
| Backbone | regnetx_080.tv2_in1k (ImageNet-1K V2) |
| Neck | D-FINE HybridEncoder (hidden_dim=256, strides 8/16/32) |
| Parameters | ~54.1 M (all trainable after epoch 1) |
| Queries | 300 |
| Geometry | (K=8) cubic B-spline control points per line + height |
| Canvas | (1280\times1280) letterbox |
| Init | Native RegNetX Stage-0 (full model load, 1177 tensors — backbone + encoder + decoder) |
| Task | Document baseline / text-line detection → PAGE or ALTO export |
Detection is set prediction of scored polylines. Polygonal line environments (BLLA) are applied only at PAGE/ALTO serialize time.
Intended use
Use for
- Hebrew square-script and Samaritan manuscript baseline detection
- PAGE-XML / ALTO export for HTR pipelines (RTL:
--text-direction horizontal-rl) - Research comparing RegNetX vs ConvNeXt / D-FINE polyline siblings on the same Arrow
Not for
- Official ICDAR cBAD 2019 test claims (this val split is Hebrew+Samaritan only)
- Production OCR transcription (lines only; no text recognition)
- Layout region detection (paragraphs, tables, illustrations)
- Treating
cbad_f1@ conf 0.1 as the quality number (see operating point below)
Training data
Same Arrow as the dfine-det / convnextv2-det Hebrew+Samaritan combined recipes:
| Split | Pages |
|---|---|
| Train | 1758 |
| Val | 261 |
Sources (PAGE-XML baselines):
- Hebrew medieval manuscripts (
Hebrew_Medieval-seg) - Samaritan manuscripts (
sam_44_mss_pango_additional; manuscript-level split, seed 42)
Compiled with adaptive simplify → uniform cubic B-spline, (K=8), original-normalized coords (letterboxed at load time).
Training recipe
Config: configs/hebrew_samaritan_regnetx_stage0_finetune_balanced.yaml.
| Hyperparameter | Value |
|---|---|
| Init | Native RegNetX Stage-0 PRETRAIN/regnetx_stage0/best_cbad_f1.safetensors (full model load, 1177 tensors) |
| Optimizer | AdamW; base LR (3\times10^{-5}), backbone (0.2\times) |
| Freeze | backbone frozen for first 1 epoch (freeze_backbone_epochs: 1) |
| Schedule | Linear warmup 1 epoch + cosine |
| Precision | bf16-mixed |
| Effective batch | 8 (micro-batch 4 × accumulate 2) |
| Epochs (cap) | 150; early-stop on cbad_f1_max (patience 30, min_delta 0.0005, min 15) |
| Augment | Mild photometric + small rotation (OOB lines dropped) |
| Match distance | 20 px on the 1280 canvas |
| Monitor | cbad_f1_max over conf ∈ {0.1, 0.2, 0.3, 0.4, 0.5, 0.6} |
| Seed | 42 |
FPN-only recipes on the same data plateaued (~0.61 for 8GF, ~0.31 for 032). HybridEncoder + Stage-0 encoder transfer is the working path.
Training ran until early-stop (~epoch 90). The released snapshot is the monitored best (cbad_f1_max ≈ 0.969 at conf 0.40), not the last epoch.
Previous release used D-FINE Stage-0 warm-start (
configs/hebrew_samaritan_stage0_hybrid.yaml), reachingcbad_f1_max≈ 0.942. The native RegNetX Stage-0 balanced finetune improves this by +0.027 F1.
Evaluation (internal val)
Metric: cBAD-style line F1 — Hungarian matching of densified polylines with mean bidirectional Chamfer cost; TP if cost ≤ 20 px.
Released checkpoint
| Metric | Value | Notes |
|---|---|---|
cbad_f1_max | 0.969 | Best monitor; operating conf = 0.40 |
| Precision @ 0.4 | 0.967 | Best-epoch sweep |
| Recall @ 0.4 | 0.972 | Best-epoch sweep |
cbad_f1 @ 0.1 | 0.850 | Logged bar metric — not the production score |
| Weights | best_cbad_f1.safetensors | Also best_0.9713.safetensors |
Conf sweep (locked-in test on best checkpoint)
| conf | F1 | P | R | mean chamfer | Notes |
|---|---|---|---|---|---|
| 0.10 | 0.850 | 0.743 | 0.994 | 2.79 | Recall-heavy debug only |
| 0.20 | 0.949 | 0.912 | 0.990 | 3.21 | |
| 0.30 | 0.963 | 0.948 | 0.978 | 3.81 | Extra recall |
| 0.40 | 0.969 | 0.967 | 0.972 | 3.83 | Recommended |
| 0.50 | 0.966 | 0.975 | 0.957 | 3.87 | CLI default; close |
| 0.60 | 0.966 | 0.985 | 0.948 | 3.23 | High precision |
cbad_f1 on the train progress bar is fixed conf=0.1. cbad_f1_max is the sweep max. Compare systems on cbad_f1_max (or F1 at a stated conf).
Stage-0 zero-shot baseline (same val, same metric)
| conf | F1 | P | R | mean chamfer |
|---|---|---|---|---|
| 0.10 | 0.805 | 0.679 | 0.989 | 3.14 |
| 0.20 | 0.930 | 0.889 | 0.975 | 4.30 |
| 0.30 | 0.953 | 0.941 | 0.966 | 4.31 |
| 0.40 | 0.951 | 0.957 | 0.946 | 5.00 |
| 0.50 | 0.950 | 0.973 | 0.928 | 4.44 |
| 0.60 | 0.944 | 0.982 | 0.908 | 4.17 |
Stage-0 best: conf=0.30 cbad_f1=0.953. Finetune gain: +0.016 F1 (0.953 → 0.969) at respective best confs.
Sibling bake-off (same Hebrew+Samaritan Arrow family)
| Model | Neck | Init | Best cbad_f1_max |
|---|---|---|---|
| RegNetX-8GF + FPN | FPN | ImageNet | ~0.61 |
| ConvNeXtV2-Tiny + FPN | FPN | ImageNet | ~0.79 |
| ConvNeXtV2-Base + FPN | FPN | ImageNet | ~0.89–0.90 |
| RegNetX-8GF + HybridEncoder | HybridEncoder | D-FINE Stage-0 (prev. release) | 0.942 |
| RegNetX-8GF + HybridEncoder | HybridEncoder | Native Stage-0 zero-shot | 0.953 |
| This checkpoint | HybridEncoder | Native Stage-0 balanced | 0.969 |
| D-FINE-L Stage-1 (same domain, different stack) | HybridEncoder | D-FINE Stage-0 | ~0.95–0.96 |
Numbers are internal val, not a shared official test protocol.
How to use
Install
cd /path/to/regnetx-det
python3 -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
Inference (PAGE XML)
huggingface-cli download johnlockejrr/regnetx-8gf-polyline-hebrew-samaritan \
best_cbad_f1.safetensors --local-dir weights/hebrew_samaritan_hybrid
regnetx-det infer \
-w weights/hebrew_samaritan_hybrid/best_cbad_f1.safetensors \
--image page.jpg \
-o page.xml \
--format page \
--conf 0.4
# ATR-style per-page (RTL Hebrew/Samaritan):
regnetx-det infer-page \
-m weights/hebrew_samaritan_hybrid/best_cbad_f1.safetensors \
-d cuda:0 \
--conf 0.4 \
--text-direction horizontal-rl \
page.jpg
infer / infer-page default --conf is 0.5 (close to the sweep winner). Pass --conf 0.4 to match cbad_f1_max.
Fine-tune further
train:
load: best_cbad_f1.safetensors # this release (full weights)
backbone: regnetx_080.tv2_in1k
pretrained_backbone: false
monitor: cbad_f1_max
image_size: 1280
Files in this release
| File | Description |
|---|---|
best_cbad_f1.safetensors | Recommended weights (~208 MB) |
best_0.9713.safetensors | Same snapshot, score-tagged filename |
README.md | This model card |
Limitations
- Val F1 is Hebrew+Samaritan holdout, not official cBAD 2019 test.
- (K=8) control points underfit strongly curved / torn lines.
- Export uses EMA when warmed during train; released file is the monitored best snapshot.
- HybridEncoder
eval_spatial_sizemust match the canvas (1280). Do not run eval/infer at a different square size than training.
Citation & credits
Paper (prefer this)
Preprint: regnetx-det: Set-Prediction Polyline Baselines for Historical Documents with HybridEncoder Transfer (Zenodo, Aug 2026).
@misc{bors2026regnetxdet,
author = {Bors, Teodor},
title = {regnetx-det: Set-Prediction Polyline Baselines for Historical Documents with HybridEncoder Transfer},
year = {2026},
month = aug,
publisher = {Zenodo},
version = {v1},
doi = {10.5281/zenodo.22059333},
url = {https://doi.org/10.5281/zenodo.22059333}
}
D-FINE (HybridEncoder, deformable decoder, Stage-0 polyline weights)
@inproceedings{peng2025dfine,
title = {D-FINE: Redefine Regression Task in DETRs as Fine-grained Distribution Refinement},
author = {Peng, Yansong and Li, Hebei and Wu, Peixi and Zhang, Yueyi and Sun, Xiaoyan and Wu, Feng},
booktitle = {The Thirteenth International Conference on Learning Representations},
year = {2025},
url = {https://arxiv.org/abs/2410.13842}
}
- Code: github.com/Peterande/D-FINE
- Stage-0 foundation:
johnlockejrr/regnetx-8gf-polyline-baseline-stage0
RegNetX backbone
Radosavovic et al., Designing Network Design Spaces, CVPR 2020. Weights via timm regnetx_080.tv2_in1k.
This checkpoint (weights)
@software{regnetx_det_hebrew_samaritan_balanced,
title = {RegNetX-8GF HybridEncoder Polyline Baselines (Hebrew + Samaritan, Stage-0 Balanced Finetune)},
author = {Bors, Teodor},
year = {2026},
note = {Fine-tuned from native RegNetX Stage-0; cbad_f1_max 0.969 at conf 0.40; see Zenodo preprint doi:10.5281/zenodo.22059333},
url = {https://huggingface.co/johnlockejrr/regnetx-8gf-polyline-hebrew-samaritan}
}
Additional notices
- Vendored D-FINE modules:
THIRD_PARTY_NOTICES.md(Apache-2.0, © 2024 The D-FINE Authors). - PAGE polygonalization: Kraken/BLLA subset (Apache-2.0, © Benjamin Kiessling) — export only, hardened with CLAHE/Sauvola fallback.
- Training images: respect each corpus license; this card does not redistribute the PAGE/JPEG data.
License
Apache License 2.0 for regnetx-det code and these weights. Downstream users must also comply with licenses of datasets used in further fine-tuning.