7 Mogra OCR
I spent the last couple of weeks trying to build an OCR engine for Devanagari and Latin texts. I call it Mogra. LLMs are fine, and Google Cloud Vision works reasonably well on old Sanskrit books. But we need something like Tesseract: OSS that runs easily on a toaster.
After several false starts with C(R)NN+CTC+BiLSTM, I scrapped the design in favor of a template-matching system. It works as follows:
- You add a book to the project and extract the images
- The app provides a UI that lets you tag character boxes with the actual character. The mapping is stored
- The app uses this mapping to rapidly perform a sliding-window match across the entire book
I ran a test with Stephen Leacock's Sunshine Sketches of a Little Town. The best Tesseract timing was 39s for those 296 pages using:
export OMP_NUM_THREADS =8
mkdir -p ./output
parallel -j 8 tesseract -l eng {} ./output/{/.} ::: ./input/*.png
Mogra's mogra-mt1 backend does it in 6s. And the output is comparable to Tesseract.

With more work, beating Tesseract is feasible. The drawback is that you need to spend 15-30 min doing the mapping manually for each book.
The project is presently on the back burner as I am busy with Bhāṣikā and some other stuff. But I will revisit it soon enough.
- mt = metal-type ↩