Moroccan Arabic OCR β CNN + BiLSTM + CTC
This repository contains the trained line-recognition checkpoint from the companion project moroccan-darija-ocr.
The model was trained on Arabic printed text-line images from the Moroccan Official Gazette. It is an Arabic baseline for later Moroccan Darija adaptation; it was not trained on Darija and should not be presented as a Darija benchmark result.
Checkpoint
best.pt is a PyTorch checkpoint containing the model, vocabulary, optimizer state, scheduler state, AMP scaler state, and training configuration. The architecture is a grayscale CNN followed by a two-layer bidirectional LSTM and a CTC classifier. CTC blank index is 0; the vocabulary is in vocab.json.
Configuration: height 64, maximum input width 1600, hidden size 128, CNN channels 32, 92 character classes plus the CTC blank. The checkpoint has 1,940,797 parameters.
Reported evaluation
On the fixed 1,212-line official test split:
- CER: 1.49%
- WER: 6.94%
- exact line accuracy: 51.65%
These are printed Arabic Gazette results, using greedy CTC decoding without a language model. They do not measure Darija performance. The full metrics and independent verification are included as metrics.json and verification.json.
Test visualization
The executable test-gallery notebook is available at notebooks/03_test_images_transcriptions.ipynb. It displays test images with reference transcriptions, model predictions, and per-line CER. A generated gallery is available at test_artifacts/test_images_transcriptions_gallery.png.
Loading
import torch
checkpoint = torch.load("best.pt", map_location="cpu", weights_only=False)
print(checkpoint["characters"])
print(checkpoint["config"])
For inference and preprocessing, use the source code in the GitHub repository. The model expects already-cropped line images. A full page needs line detection and reading-order reconstruction before recognition.
Intended next step: Darija
AtlasOCR is audited in the GitHub repository. Its public rows expose page or paragraph images with text and metadata, but the inspected version does not expose reliable line boxes or line-level transcriptions. The adaptation tools therefore require vetted one-line image/transcription pairs and reject multiline text. AtlasOCRBench must remain a held-out evaluation set.
Data and attribution
The baseline data source is the Moroccan Official Gazette line-image corpus, Zenodo DOI 10.5281/zenodo.21702529, announced under CC BY 4.0. See the GitHub repository for the complete audit, preparation code, limitations, and attribution details.
- Downloads last month
- -
