Views
No views yet
Headline result (test set, 1,334 lines): CER 0.1331 · WER 0.3921 with the full pipeline (backbone + calibrated decode + neural-LM rerank + risk-aware reranker). The published backbone alone with plain greedy CTC decoding scores CER ~0.170.
pip install torch pillow numpy huggingface_hub1from huggingface_hub import snapshot_download
2import sys
3from PIL import Image
4
5# Download the repo (weights + helper code)
6local = snapshot_download("sdkv2/muharaf-arabic-ocr")
7sys.path.insert(0, local)
8
9from submission_code.torch_models import load_ctc_backbone, recognise_line
10
11model, charset, cfg = load_ctc_backbone(f"{local}/models/ctc_backbone/model.pt")
12
13image = Image.open(f"{local}/data/demo_samples/sample_02_test-00000-of-00001_1230.png")
14print(recognise_line(model, charset, image))
15# -> قبلات حارة لامته لها والف تحية وسلام وبعدهnotebooks/05_final_model_inference.ipynb.config.json # root model config (also the Hub download-count query file)
models/
ctc_backbone/ # the visual recogniser (this is the model you load for inference)
model.pt # torch checkpoint: {model_state, charset, model_config}
config.json # human/machine-readable architecture + metrics
training_metrics.json # full training history for this checkpoint
char_ngram_lm/
char_lm.json # character 5-gram LM used by the calibrated beam decoder
neural_char_lm/
char_transformer_lm.pt # neural character-level Transformer LM for N-best reranking
lm_metrics.json
rerank_summary.json # selected rerank weights + test metrics (V7 stage)
risk_reranker/
risk_reranker.pt # supervised risk-aware N-best reranker (final stage)
summary.json # selected config + final test/oracle metrics (V9 stage)
decode_config/
v5_antideletion_summary.json # calibrated-decode hyperparameters (blank penalty etc.)
submission_code/ # small, dependency-light helper package
torch_models.py # CNNTransformerCTC architecture + load/inference helpers
ocr_helpers.py # preprocessing, charset, greedy CTC decode, CER/WER
notebooks/ # Jupyter notebooks (training + inference)
data/
demo_samples/ # example line images + references for the inference demo
results/ # final metric table + report figures
manifests/ # CSV manifests (train/val/test splits) for reproductionmodels/ctc_backbone/model.pt (4.25M params)[0, 1].models/char_ngram_lm/char_lm.json + decode_config/lm_weight 0.2, length_bonus 0.1, blank_penalty 0.6, score_mode sum. Backbone + this decoder ≈ CER 0.1416.models/neural_char_lm/char_transformer_lm.ptacoustic 1.0, ngram_lm 0.15, neural_lm 0.2, length_bonus 0.14.models/risk_reranker/risk_reranker.pt (final stage)risk_weight 0.2, target_temperature 2.0). Selects the final hypothesis → CER 0.1331.Note: stages 2–4 are documented here with their exact selected configs and the weights are included, but the full beam-decode + N-best + rerank driver code lives in the original project scripts. For most uses the backbone + greedy (or a small beam) is the practical path; reproducing the exact 0.1331 requires the offline decode/rerank pipeline.
| Notebook | Contents |
|---|---|
01_preprocessing_and_dataset_audit.ipynb | Image preprocessing + text normalization policy, manifest checks |
02_ahcd_cnn_baseline.ipynb | AHCD isolated-character CNN baseline |
03_muharaf_crnn_ctc_baseline.ipynb | Line-level CRNN/CTC baseline workflow |
04_results_summary.ipynb | Final metric table + report figures |
05_final_model_inference.ipynb | Load the published backbone and run OCR on demo line images |
| Stage | Method | Test CER | Test WER |
|---|---|---|---|
| CRNN baseline | CNN/RNN/CTC baseline | 0.7060 | 1.0215 |
| TrOCR transfer | Best retained TrOCR run | ~0.7752 | ~0.9913 |
| V1 CNN-Transformer-CTC | New backbone, greedy | 0.2732 | 0.7603 |
| V2 aug + long | Light aug, longer training, beam | 0.1753 | 0.5621 |
| Calibrated CTC decoder | Blank/length calibration (V5/V6) | 0.1484 | 0.4392 |
| Neural-LM rerank (V7) | Neural char-LM N-best reranking | 0.1379–0.1455 | 0.408–0.423 |
| Learned reranker (V8) | Supervised N-best selection | 0.1395–0.1403 | 0.403–0.405 |
| Final (V13 + risk reranker) | Attention pooling + calibrated decode + risk-aware rerank | 0.1331 | 0.3921 |




crnn_baseline normalization (NFC, tatweel removed, spaces collapsed); 165-character vocabulary, zero OOV on val/test.zero_infinity=True), blank id 0, train-time blank-logit penalty 0.2.models/ctc_backbone/training_metrics.json.1@misc{muharaf_arabic_ocr_2026,
2 title = {Muharaf Arabic Handwriting OCR: a character-level CNN-Transformer-CTC pipeline},
3 author = {Shihadeh, Aiden},
4 year = {2026},
5 howpublished = {\url{https://huggingface.co/sdkv2/muharaf-arabic-ocr}}
6}