tetrak_ocr.backends.armenian¶
OCR Armenian text with the project’s own EasyOCR recognition model.
Stock EasyOCR does not read Armenian: it scores 0.03 word recall on the evaluation pages, which is a polite way of saying it reads nothing. This backend swaps in tetrak_hy, a recogniser trained for the script by tetrak-hy-trainer and published as the tetrak-easyocr-armenian package. Detection is untouched – EasyOCR’s CRAFT detector already finds Armenian text; reading it was the missing half.
Registered as easyocr-hy rather than folded into the easyocr backend, for the same reason tesseract-auto is its own name: the harness scores backends, so the difference between stock EasyOCR and this one is a measurement rather than a claim.
Two things happen to the recogniser’s output here, and both matter more than they look:
The homoglyph fold. The recognition head has no language model, so inside an Armenian word it sometimes emits the visually identical Latin twin of an Armenian character – h for հ, a colon for the Armenian full stop ։. tetrak_hy.fold_script folds those back within any token that already holds an Armenian letter. It is worth about +0.035 word recall and costs one function call.
The word list. Where the installed tetrak-easyocr-armenian has released one, tetrak_hy.lexicon corrects out-of-vocabulary words from the recogniser’s own n-best readings (brief 013: 465 words fixed, 13 broken on the held-out registers; mean word recall +0.012). It needs the recogniser’s probabilities, which EasyOCR hands over only to its beam-search hook, so readtext is then called with decoder=”beamsearch”. Without a released list, decoding stays greedy.
Reading order. The pages this exists for are set in two columns, and joining detected regions in detector order interleaves them. That is invisible to word recall and ruinous to character similarity – the same text in the wrong order scores 0.12 against 0.70. Output is therefore serialised through tetrak_ocr.layout, which reads each column to its foot before starting the next. Not a midline split: that mishandles running headers, and measurably hurt two of the ten evaluation pages when it was tried.
- Requires:
pip install “tetrak[armenian]”
The recogniser’s weights (~15 MB) download on first use from the Hugging Face model repository, pinned to one immutable revision per release and checksum-verified; EasyOCR’s own detector weights (~80 MB) download alongside them. Both are cached and reused.
- Usage (standalone):
tetrak-ocr ocr workspace/scans/page.jpg –backend easyocr-hy
PDF support is not included; convert PDFs to images first.
Functions
|
Extract Armenian text from an image file. |