Coptic OCR (Sahidic manuscripts and print)
This model reads Coptic text from photos or scans of whole pages. It was trained mainly on Sahidic manuscripts from the White Monastery (Vatican, Borg. copt. 109). It also handles printed Sahidic reasonably well.
The pipeline has three parts:
- Line finder: Kraken BLLA baseline segmentation, fine-tuned on SCAM pages, plus column-aware reading order.
- Recognizer: reads each line. It's a CTC model: an ImageNet ResNet-50, cut after layer3, followed by a 2-layer BiLSTM with 512 units.
- Language model: a 5-gram character model trained on Coptic Scriptorium text, used during CTC beam search (shallow fusion, α=0.35, β=0.5, beam 12).
Files
| File | What it is |
|---|---|
models/recognizer.safetensors + .json |
The default line recognizer (run E17s1): ResNet-50, trained on gold plus self-labelled lines, with simulated show-through. Best overall. |
models/recognizer_manuscript.safetensors + .json |
A ResNet-34 recognizer fine-tuned on gold lines only (run E10a). Slightly better on full test pages, much worse on print. |
models/segmenter.safetensors |
Kraken BLLA line segmenter, fine-tuned on SCAM pages |
models/coptic_char5.pkl |
5-gram character language model, stored as a pickle of plain Python dicts |
scripts/ |
Inference code: transcribe.py is the entry point. Training code is in train_crnn.py. |
Usage
pip install -r requirements.txt # torch, torchvision, kraken 7.2, pillow, numpy, safetensors
python scripts/transcribe.py page.jpg # one line of text per detected line, in reading order
python scripts/transcribe.py page.jpg --overlay boxes.jpg
python scripts/transcribe.py line1.png line2.png --lines # inputs are already single-line crops
python scripts/transcribe.py page.jpg --rec models/recognizer_manuscript.safetensors
python scripts/transcribe.py page.jpg --no-lm # greedy decoding without the language model
It runs on CPU or CUDA. A page takes about 2 s on a laptop GPU.
Results
CER is the character error rate, counting a letter and its marks as one character (as the SCAM paper does), so lower is better. The ignoring spaces column matters because the manuscripts have no word spaces, which makes word division a matter of convention.
| Benchmark | E17s1 (default) | E10a (manuscript) |
|---|---|---|
| SCAM-A test lines, official CER | 11.52 | 11.99 |
| SCAM-A test lines, ignoring spaces | 8.01 | 8.50 |
| SCAM-A test, full pages (automatic segmentation) | 7.04 | 6.69 |
| 35 held-out leaves by unseen scribes, letter CER vs. the Sahidic Bible* | 10.99 | 10.98 |
| Printed: Horner's Sahidic Luke, letter CER vs. the edition* | 18.11 | 30.62 |
* These pages have no gold transcription. Each page's letters are compared with the matching passage of a printed edition, ignoring diacritics, punctuation and spaces. Lectionary pages that switch passage are scored one passage at a time. Real spelling differences between the scribe and the edition count as errors, so these numbers overstate the true error rate. Use them to compare models, not as absolute accuracy.
Published results on the same SCAM-A test lines: VAN 7.50, CRNN 13.91, TrOCR-L 14.99 (SCAM paper). This model beats the paper's line-level baselines. It does not match VAN, which reads whole paragraphs at once.
Training data
- SCAM (CC-BY 4.0): gold line transcriptions of a Sahidic manuscript. Only the training split was used; val selected the model and test was scored once.
- About 22k self-labelled lines from other Borg. copt. 109 leaves (Vatican Library digitizations). The model's own transcriptions were kept where a strict agreement filter passed. Held-out fascicles used for evaluation were excluded.
- Synthetic lines rendered in Coptic fonts from Coptic Scriptorium text (CC-BY 4.0), which also trained the language model.
- Horner's printed Sahidic New Testament (public domain), with lines aligned to the edition text.
Training images are not included in this repo. Manuscript images are © Biblioteca Apostolica Vaticana.
Limitations
- Sahidic only. It was trained on Sahidic, mostly one scriptorium's style. Bohairic, other dialects and very different hands will be worse.
- Damage hurts. Errors cluster on damaged lines (bleed-through, tears, marginal notes).
- Simple page layouts. It expects one or two text columns. Ornaments, marginalia and complex layouts may be split into lines or ordered wrongly.
- Output conventions follow the SCAM transcription: lowercase letters with combining marks (superlinear stroke, dots, trema), and spaces as word division.