Arabic HTR v2

A CNN–Transformer model trained from scratch for Arabic handwritten line recognition. Developed by Rakan Alzuair as part of an Arabic manuscript HTR senior project.

Model

  • Approximately 20.3 million parameters.
  • Four CNN stages, six Transformer encoder layers, and greedy CTC decoding.
  • Input: grayscale line images, resized to height 96 with the project's width rule.
  • Output vocabulary: 232 characters plus the CTC blank class (233 classes).
  • Full pages require line segmentation before recognition.

Training

  1. Initial training on Omar-al-Saleh, Muharaf, and AraMs-28k-HTR: 45 epochs.
  2. KHATT adaptation with the original data retained: 20 epochs.
  3. AHDQ adaptation using automatically aligned line crops: 18 epochs.
  4. Makhzan adaptation on Arabic manuscript line crops: 10 epochs.
  5. Learning-rate experiment starting at 3e-5: 20 epochs completed; epoch 19 selected by the lowest equal-weight mean validation CER across all six sources. The scheduler reduced the learning rate during the run.

The final mixture contains 81,674 training lines and 6,873 validation lines. AHDQ line labels are automatically aligned; Makhzan crops use the supplied annotations.

The released best.pt is output/experiment_lr_3e5/best.pt, epoch 19. It contains the model state, configuration, vocabulary, and training state. It replaces the earlier AHDQ release under the same repository filename.

Checkpoint SHA-256: e523f7fd1259c254f8a751e1be40ad795eb26eec110365600298fb9a47a86ad5.

Test results

Evaluated on 5 October 2026. Corpus error rates using the project's norm-v1 scorer; lower is better. These are test scores, not training or validation scores.

Dataset Test units Strict CER Strict WER Stripped CER Stripped WER
Omar-al-Saleh 2,095 lines 4.68% 21.09% 4.45% 20.91%
Muharaf 1,334 lines 15.62% 41.83% 11.60% 40.24%
AraMs-28k-HTR 6,744 lines 21.28% 62.17% 21.21% 62.03%
AHDQ-pages 32 pages / 481 crops 12.62% 43.16% 9.78% 26.11%

AHDQ's headline metric under norm-v1 is stripped page CER, 9.78%. Crop predictions were joined in page reading order and scored against page labels.

AraMs strict CER by held-out book: book 03 29.92%, book 05 9.79%, book 09 22.04%.

Full metrics and evaluation metadata are provided in benchmark/metrics.csv and benchmark/run.json.

Usage and limitations

Use the supplied model.py and config.py with PyTorch; this is a custom checkpoint, not a Transformers from_pretrained model. Instantiate the model using the checkpoint configuration and vocabulary. Preserve the training image preprocessing and vocabulary mapping.

The model predicts visual-order text; the demo uses an approximate inverse BiDi conversion for logical text. Evaluation used greedy CTC decoding, batch size 4, float32 inference with TF32 disabled, and norm-v1 scoring.

The model trained on AHDQ training data, so AHDQ is an adapted-source evaluation rather than unseen-source transfer. Its 481 test crops differ from the earlier comparison report's 455 crops. Frozen-file identity against that report and cross-dataset training/test overlap remain unaudited. The test benchmark has been inspected during development; these results do not constitute an untouched final evaluation.

Transcriptions may contain errors and should be reviewed, particularly for unfamiliar handwriting, decorated regions, and damaged crops. No universal state-of-the-art claim is made.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Dataset used to train rakansuliman/arabic-htr-v2