A lightweight PP-OCRv6-inspired Amharic/Fidel line OCR recognizer with teacher–student distillation.
# Amharic Line Recognizer for Fidel
A from-scratch, ~24.5M-parameter CTC recognizer for Amharic sentence/line
OCR, trained on the Fidel dataset
(CMU Africa / Upanzi Network). Architecturally inspired by PP-OCRv6's
recognition module (lightweight CNN backbone + local/global attention neck),
rebuilt in PyTorch with a custom Amharic character vocabulary, since
PP-OCRv6's own pretrained weights don't cover Ethiopic script.
Current published SOTA on Fidel is **2.64% CER / 7.29% WER** (fine-tuned
SuryaOCR, per the Fidel paper) — that's the number this project is trying
to approach or beat at a fraction of the parameter count.
## Files
| File | What it does |
|---|---|
| `audit_fidel.py` | Scans the label CSVs (+ images, if present) and reports type balance, character vocabulary, text/image stats, writer overlap, and corrupt files. Run this first against any new copy of the dataset. |
| `vocab.json` | The final, cleaned 355-class character vocabulary (354 real characters + 1 CTC blank token), built from the actual audit output. This is the model's output alphabet — don't regenerate it casually, since a vocab change requires retraining from scratch. |
| `model.py` | The recognizer architecture: `AmharicRecognizer`. CTC head is the only one used at inference; an auxiliary NRTR (encoder-decoder) head is trained jointly for regularization, then discarded. |
| `dataset.py` | `FidelLineDataset` (reads the CSVs + images, resizes preserving aspect ratio, encodes text via `vocab.json`) and `make_writer_disjoint_split` (see **Known Issues** below). |
| `train.py` | The training loop: combined CTC + NRTR loss, a 4-phase curriculum (synthetic → typed → handwritten → balanced mix), CER tracking, checkpointing. Run with `--self_test` to sanity-check the whole pipeline without real images. |
| `char_vocab.txt`, `rare_chars.csv`, `summary.json` | Raw outputs from the most recent audit run (on `train_labels.csv` / `test_labels.csv` only — image-level stats not yet run, see below). |
# …