OpenThai 2.0 OCR Text: a free Thai OCR model that runs on any CPU
OpenThai 2.1 OCR Text is out. It keeps the model files described here and adds a new runtime and a second recognizer: it keeps the tone marks of old books, reads loopless fonts such as Kanit and Prompt, and keeps one-character table cells. This post describes version 2.0, which stays available under the tag v2.0.0; the download links below now lead to version 2.1.
Today we are releasing OpenThai 2.0 OCR Text, a model from OpenThai (formerly OpenThaiGPT) that reads printed Thai and English text from scanned pages and page images. It is small: 1.02 million parameters in two files that together take 4.2 MB. It reads a dense A4 page in 0.39 seconds on an ordinary CPU, with no GPU and no internet connection, so documents never leave the computer that reads them. It is a free download from Hugging Face under the Apache-2.0 licence, and it is the engine behind iApp's OCR Text API.
Model page: iapp.co.th/openmodels/openthai2p0-ocr-text · Weights: huggingface.co/iapp/OpenThai2.1-OCR-Text-20261118
What it does
Give it a page image and it returns the page's text in reading order. Every line also comes with its box, in the coordinates of the image you passed in, and a confidence between 0 and 1, so that doubtful lines can be sent for a person to check.
Before it reads, it prepares the page the way real scans need:
- Orientation: sideways and upside-down pages are turned the way their lines read best.
- Tilt: scans tilted by more than 2.5 degrees are straightened, and the boxes are returned in the original image's coordinates.
- Reading order: two- and three-column pages are read column by column; tables, budget pages and lists keep their row order.
- Colour: each column's background is subtracted, so light text on dark backgrounds, coloured slides and gradients read.
It passed all 22 conditions of its robustness suite (rotation, tilt, very large and very small text, colour, faded print, photocopy noise, phone photos, tables and columns), with 20 held-out pages each and pass marks fixed before the first run.
It writes text, not tables. For whole pages whose tables must stay tables, use OpenThai 2.0 OCR Markdown, released the same day.
Why a small model
Many organisations cannot send their documents to an outside service: government offices, hospitals, banks and law firms among them. A model that runs on the CPU of the computer that holds the documents reads them where they are. A reading process needs 0.5 CPU-seconds and about 450 MB of memory per page, so one 8-core server reads about 950 pages a minute: a million pages in under a day, with no GPU.
Results
The model card tests 15 OCR engines on the same pages and scores them the same way: character accuracy, 100 × (1 − character error rate), higher is better, after markup is stripped from both sides, with reading order counted. The average covers 12 printed sets: Thai parliament budget documents, Royal Gazette pages, old books, court judgments, ThaiOCRBench pages and others. Four of the engines run on a CPU:
| Runs on a CPU | Average, 12 printed sets | Royal Gazette | Budget documents, verified | Old books | ThaiOCRBench pages | Seconds a page | CPU-seconds a page |
|---|---|---|---|---|---|---|---|
| OpenThai 2.0 OCR Text | 87.8 | 96.3 | 99.5 | 77.1 | 82.0 | 0.39 | 0.50 |
| OneOCR (Microsoft, Windows) | 85.0 | 96.6 | 99.8 | 78.6 | 81.8 | 0.72 | 2.22 |
| PaddleOCR 3, PP-OCRv5 Thai | 81.1 | 82.9 | 93.1 | 55.5 | 75.8 | 15.20 | 16.29 |
| Tesseract 5, Thai and English | 75.4 | 82.3 | 71.3 | 52.2 | 75.0 | 1.40 | 1.66 |
Of the CPU engines it has the best average and is the fastest. OneOCR, which ships with Windows, is slightly ahead on the Royal Gazette, budget documents and old books, by 0.3 to 1.5 points, and needs over four times the CPU time per page. Tesseract, a widely used open-source engine, averages 12.4 points lower.
Models that run on a GPU score higher on average: 89.6 for Typhoon OCR V2 2B and 90.3 for OpenThai 2.0 OCR Markdown. They also read handwriting, tables and photographs far better: on handwriting they score 76.7 and 78.9, against 10.3 for this model.
Speed is one page at a time on the same 24 printed pages; CPU-seconds are one single-threaded worker on an Intel Xeon 8468 core. On a MacBook Pro with M3 Max, with ONNX Runtime, the 12 Thai document pages of the demo set on our OCR API page took a median of 0.35 seconds each. The full table of 15 engines and the list of the 12 sets are in the model card.
Run it
pip install onnxruntime opencv-python-headless pyclipper numpy pillow huggingface_hub
hf download iapp/OpenThai2.1-OCR-Text-20261118 --local-dir OpenThai-OCR-Text
cd OpenThai-OCR-Text
from runtime.line_engine import LineOCR
ocr = LineOCR(".", threads=1)
r = ocr.read("page.png") # a path, bytes, a BGR array or a PIL image
print(r["text"]) # the page's text in reading order
for line in r["lines"]: # every line with its confidence and its box
print(line["confidence"], line["box"], line["text"])
The download gives the latest version; add --revision v2.0.0 to the hf download line for the version this post describes. For thousands of pages, run one process per CPU core with threads=1; threads in one process stop helping after about two cores.
- Step by step on Windows, Mac and Linux, with a script for PDFs: How to run OpenThai OCR on your own computer.
- Without writing code: Chinda Bot, our free desktop assistant, reads PDFs with this model on your own computer.
- As a hosted service: the OCR Text API runs this model, at 0.049 IC a page for text, and 0.15 IC a page for layout JSON or a Word, PowerPoint, Excel or searchable PDF file.
Limits
- Printed text only. Handwriting and scene text read poorly. Handwritten parts of a printed page are left out, such as the handwritten date on the letter in the picture above.
- Decorative display fonts: short labels in heavily stylised fonts can be misread.
- Stamps and seals come out as text, since they are text on the page.
- The quoted 0.39 seconds needs AMX (Intel Sapphire Rapids or later), where it runs in bfloat16; other CPUs run it in float32, more slowly.
- Court judgments are in-domain: Administrative Court scans, other than the 150 tested documents, are in its training data, so its court score (97.0, the best of the 15 engines) is not a test on unseen kinds of documents.
How we built it
The model has two parts: a text-line detector (1.8 MB) and a Thai line recognizer (2.4 MB). The recognizer was given a new Thai output layer and fine-tuned on 410,270 real text lines:
- 261,877 lines from Administrative Court scans, labelled with the court's own text;
- 41,101 lines from the Thai parliament's budget PDFs, kept only where the PDF's text layer and the recognizer agree;
- 107,292 lines from Wikisource old books;
and on synthetic Thai and English lines rendered from 85 open-licence fonts. No personal-data sets were used, and every benchmark document was left out of training. The recognizer's weights are in the repository for further training.
Licence
Apache-2.0, commercial use included. The detector is PaddlePaddle's PP-OCRv6-tiny as shipped, and the recognizer was fine-tuned from PP-OCRv6-tiny's; both are Apache-2.0, and the notices are in the repository.
Developed by iApp, launched with AIEAT. Trained on NVIDIA H100 GPUs provided by Siam AI Corporation.
If a Thai document does not read well, write to us at sale@iapp.co.th with a sample that holds no personal data; those pages help us improve the next version.