a devlog on machines & languages

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:

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.

Mogra output comparison for Sunshine Sketches

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.

  1. mt = metal-type