Punjabi OCR: nine free Tesseract runs, tested
85.9%
of letters, with pan best and one flag
Page mode beats a model swap
We ran Tesseract 5.5.4 on 28 proofread Gurmukhi pages from 10 books on pa.wikisource.
| Run | Letters | Words |
|---|---|---|
| pan best, --psm 6 | 85.9% | 77.2% |
| pan, --psm 6 | 85.0% | 75.0% |
| pan, tessdata repo | 84.4% | 76.3% |
| pan best | 84.4% | 76.1% |
| pan, Sauvola threshold | 84.2% | 74.6% |
| script/Gurmukhi best | 84.0% | 75.4% |
| pan | 83.5% | 73.8% |
| script/Gurmukhi | 83.2% | 72.7% |
| pan+eng | 79.2% | 71.7% |
The five Punjabi models sit within 1.2 points. The page mode moved more: --psm 6 added 1.6 points to pan best.
Without the 2018 book of phone photos, pan best with --psm 6 read 93.7%.
Letters are proofread letters found in order. Words are whole words right.
The command: one model, one flag
curl -LO https://raw.githubusercontent.com/tesseract-ocr/tessdata_best/4.1.0/pan.traineddata
mkdir -p tessdata && mv pan.traineddata tessdata/
tesseract page.png page --tessdata-dir tessdata -l pan --psm 6
It writes page.txt. The model file is 11.9 MB.
--psm 6 tells Tesseract to read the page as one block of
text. The default, --psm 3, finds the blocks itself.
With the flag, pan best took a median 4.5 s a page. Without it, 5.1 s.
Short on time? The fast pan with --psm 6 read
85.0% at 2.0 s a page. Homebrew's
brew install tesseract-lang has that fast pan, not pan
best.
Orange paper gains the most
| Printed | Default | --psm 6 |
|---|---|---|
| 1964 | 96.0% | 96.4% |
| 2010 | 82.7% | 88.8% |
| 2018, photos | 54.3% | 51.1% |
| No year given | 94.8% | 95.0% |
| No year given | 97.4% | 97.4% |
| No year given | 93.0% | 93.0% |
| No year given, orange paper | 79.6% | 94.4% |
| No year given | 89.0% | 88.9% |
| No year given | 94.7% | 93.9% |
| No year given | 88.3% | 92.8% |
The default mode skipped whole lines on the orange paper and in the 2010 poems. The flag got most back.
The 2018 book is phone photos, and its lines curve near the spine. Every run read 55% or less of it.
Page by page, the flag read more on 14 pages and fewer on 6.
The top slips: tippi and bindi
| Printed | Read as | Times |
|---|---|---|
| ਂ bindi | Nothing | 61 |
| ੰ tippi | ੈ vowel sign ai | 40 |
| ੰ tippi | ੌ vowel sign au | 19 |
| ਾ vowel sign aa | Nothing | 18 |
The 28 pages hold 540 tippi and 851 bindi.
pan best with the flag wrote 373 tippi and 685 bindi.
It wrote ਸੈਗ 18 times and the word ਮੈ 15 times. The books hold neither. They have ਸੰਗ and ਮੈਂ.
A scanned PDF: use the same flag
mkdir -p tessdata
cp -r "$(brew --prefix)/share/tessdata/configs" tessdata/
curl -L -o tessdata/pan.traineddata \
https://raw.githubusercontent.com/tesseract-ocr/tessdata_best/4.1.0/pan.traineddata
TESSDATA_PREFIX=$PWD/tessdata ocrmypdf -l pan --jobs 2 \
--tesseract-pagesegmode 6 \
--sidecar book.txt scan.pdf book.pdf
On our 28-page PDF: 107.5 s.
book.txt held 84.5% of letters, 79.2% without the flag.
| From | Letters in order | Words |
|---|---|---|
| book.txt | 84.5% | 76.1% |
| book.pdf, pdftotext | 82.1% | 65.0% |
| book.pdf, pdftotext -raw | 84.5% | 63.6% |
| book.pdf, PDFKit (macOS) | 83.9% | 75.1% |
PDFKit, the Mac framework behind Preview, read 704 ਿ signs from book.pdf. book.txt has 785. Search book.txt.
The PNG files read 85.9%. We did not test why the PDF read less.
Without the cp line (Homebrew), OCRmyPDF stops with
TesseractConfigError.
Four more things we checked
- pan+eng wrote 1,196 Latin letters on 27 pages that have none. pan and pan best wrote none.
- No Punjabi model here can write ੴ (ek onkar). Our 28 pages hold one.
- pan reads Gurmukhi only. tessdata has no Shahmukhi Punjabi model.
- Apple Vision on macOS 26.6 lists 30 languages, not Punjabi.
How we ran it
- Pages marked proofread or validated on pa.wikisource, from a seeded shuffle of books, 3 a book (2 for two books). Pages with footnotes, tables or running heads in the text were left out.
- All 28 pages came from PDFs, drawn at most 1,920 px wide.
- Scores count Gurmukhi letters and signs. Digits, punctuation, Latin letters and spaces are left out.
- Letters found in order is the longest common subsequence. Slips come from a second alignment, so counts are close, not exact.
- Models from tessdata_fast, tessdata_best and tessdata at tag 4.1.0.
- One thread a run, 2 runs at a time, at low priority, while other jobs ran. Times are rough.
- OCRmyPDF 17.13.0, pdftotext from Poppler 26.03.0, PDFKit on macOS 26.6. The PDF holds the 28 scans as JPEGs, one a page.
- Licenses: Tesseract and tessdata are Apache-2.0, OCRmyPDF is MPL-2.0. Of the 10 scan files, 6 are on Commons (5 CC BY-SA 4.0, 1 public domain) and 4 on pa.wikisource (3 PD-India, 1 untagged). We show no page images.
Scanned pages to text, no install
Run it yourself. Our Apify Actor turns a scanned PDF into Markdown or text. $0.006 a scanned page. It reads 18 languages, not Punjabi.
Or send us the scan. Tack, our AI, does the job for $29, up to 50 pages. First page free. For Punjabi, ask first.
Questions people ask
Does Tesseract support Punjabi?
Yes, in Gurmukhi, with pan or script/Gurmukhi. On our 28 pages, pan read 83.5% of letters, and pan best with --psm 6 read 85.9%.
Which Tesseract model is best for Punjabi?
The five Punjabi models sit within 1.2 points: 83.2% to 84.4% of letters. The page mode matters more than the model.
Why does Tesseract skip lines?
In the default page mode it lost whole lines on orange paper and in a book of poems. With --psm 6, pan best read 85.9%, not 84.4%. The flag did not help curved phone photos.
Can I OCR a Punjabi PDF?
Yes. OCRmyPDF with -l pan (pan best) and --tesseract-pagesegmode 6 found 84.5% of letters on our 28-page PDF. Without the flag it found 79.2%.
Can Tesseract read Shahmukhi Punjabi?
Not with pan: its character set has no Arabic letters. tessdata has no Shahmukhi Punjabi model, and we did not test urd on Shahmukhi.