How a Tiny OCR Model Finds, Reads and Orders Text on a Page Without a GPU

Many modern OCR models read a page with a large neural network, and they expect a GPU. They need CUDA and a PyTorch install that can be gigabytes in size. On a plain CPU, engines like Tesseract take seconds per page.

Indra OCR works from a much smaller model instead. It's from Datalab, and its main recognizer has about 1M parameters. It runs on ONNX Runtime, on the CPU, and the whole download is about 76 MB.

It does more than read text. For every page, it returns each line with a box, the layout blocks with labels like section header, list and table, and the reading order. You get it as markdown or JSON.

The code is Apache 2.0, and the weights use a modified OpenRAIL-M license. It's tested on Linux and macOS.

It isn't a large vision-language model. It's a set of small networks, and each one does one job: find the lines, read them, and put the blocks in order.

Datalab says it scores 66.7 on its own benchmark, OmniParseBench, ahead of PaddleOCR's full PP-StructureV3 pipeline (58.4). It also lists a median of 212 ms per page on 4 cores.

I found it interesting, so I tried it on a plain 4-core CPU with 7.6 GB of RAM and no GPU.

In this article, I'll install it and look at what's inside the download. Then I'll follow one page through its five stages, read pages with a few lines of Python, and compare the result with PaddleOCR's text models.

Setting it up

Indra OCR needs Python 3.10 or newer. Install it with pip:

pip install indra-ocr

It pulls in ONNX Runtime, OpenCV and pypdfium2, and no PyTorch. The first run downloads the models from Hugging Face and caches them.

Try it on a PDF from the command line:

indra-ocr paper.pdf

This prints markdown to the terminal. To get lines, boxes and confidence scores, ask for JSON:

indra-ocr scan.png --format json

There is also a local viewer. It draws the boxes and the reading order over each page, and your files stay on your machine:

indra-ocr-viewer --port 8765

I used indra-ocr 1.1.2 with models v1.1.0, on Linux, with 4 threads.

That first run is where the 76 MB comes from. So what is in it?

What's inside the 76 MB download

The first run downloads 12 files. That is about 74 MB compressed and 76 MB on disk. I expected a toy. The networks are small, and most of the download is language models.

File Size Job
det.onnx 0.39 MB Finds the lines of text
rec.onnx 5.04 MB Reads Latin, Cyrillic and Greek lines (~1.25M params)
rec_cjk.onnx 10.18 MB Reads Chinese, Japanese and Korean lines
rec_world.onnx 5.63 MB Reads Indic scripts, Thai, Khmer, Georgian and more
rec_rtl.onnx 4.81 MB Reads Arabic, Hebrew and other right-to-left lines
order.onnx 2.97 MB Sets the reading order and the layout labels
orient.onnx 0.37 MB Finds the page rotation
script.onnx 0.19 MB Picks a recognizer for each line
meta.json 0.21 MB Vocabulary and tensor shapes
lm.npz, lm_cjk.npz, lm_world.npz 46.30 MB N-gram language models, one per script group

In total, that is 76.1 MB on disk: 30 MB of networks and 46 MB of language models. All the default models together have 7.3M parameters. The math models add another 19.9 MB, but only if you use --math.

Why spend 46 MB on language models? Because they only run when they're needed. The recognizer gives each line a confidence score. When a line scores under 0.9, a beam search reads it again, and it weighs the recognizer's guess against how likely each word is in that language.

This suits a CPU budget well. The bytes go to fixing hard lines, like faint or noisy print, and not to a bigger network.

Each file has one job. Next, here is how a page moves through them.

How Indra OCR works

A page goes through five stages. Four of them are the small files from the table above.

1. Check the text layer. A digital PDF already has its text inside. In the default auto mode, Indra OCR uses that text where it passes its checks, and runs OCR on the rest. If a digital page has text inside an image, it reads that with OCR too. Each page reports which path it took in its source field: text, ocr or hybrid.

2. Orient the page. Scans are rarely straight. Indra OCR turns a sideways or upside-down page upright, and it straightens small tilts. Datalab says this works for tilts up to 45 degrees, and for light text on a dark background. The page keeps what it did in its rotation and skew fields.

3. Detect lines. det.onnx is the smallest network here, at 0.39 MB. It looks at the page and draws a box around every line of text. After this step, the model reads one line at a time.

4. Route and read. One page can mix scripts, so each line gets a small test first. script.onnx looks at the line and picks one of four recognizers, from the table above. If it isn't sure, the main recognizer reads the line as well, and the more confident reading wins.

The recognizers use CTC, which is a common way to read a line of text. The model looks at the line in small steps from one end to the other. At each step, it guesses a character, or a blank. Then repeated characters and blanks are collapsed into the final text. It never needs to know where one letter ends and the next begins, and that is a big reason why a small model can do this quickly.

When a line comes back under 0.9 confidence, the language model from the last section steps in and re-decodes it.

5. Order and label. order.onnx groups the lines into blocks. It gives each block a label, like text, section header, list, table, caption, footnote, or page header and footer. Then it puts the blocks in reading order. A right-to-left page reads its right column first.

Last, Indra OCR writes the markdown: headings, paragraphs, lists, and tables as HTML. Page headers and footers are left out unless you pass --keep-furniture.

Here is real output from Datalab's launch post. Every layout block has a label and a box, and every line has a thin box.

Image credit: Datalab, Indra OCR launch post.

Every box and label in that picture is also in the output. Next, here is how to get at them from code.

Reading a page with Python

The command line is enough for a quick look. In code, reading a PDF takes a few lines:

import indra_ocr

conv = indra_ocr.load(threads=4)  # mode: "auto", "ocr" or "text"

for i, page in conv.convert("scan.pdf"):
    print(f"page {i}: source={page.source}, {page.timings['total_ms']:.0f} ms")
    print(page.markdown)

load reads the models once. convert then gives you one page at a time. Each page carries the results of the stages above:

  • page.source, page.rotation and page.skew come from stages 1 and 2.
  • page.lines holds stages 3 and 4: every line, with its box, text and confidence.
  • page.blocks and page.markdown come from stage 5.
  • page.timings has the time of each step, with total_ms for the whole page.

To see the layout blocks and the lines, loop over them:

for block in page.blocks:  # in reading order
    print(block["label"], block["bbox"])

for line in page.lines:  # in reading order
    print(round(line.conf, 2), line.text)

The confidence on each line is useful. A quick way to find the lines worth a second look:

unsure = [ln for ln in page.lines if ln.conf < 0.9]

If your PDFs are scans, load it in ocr mode. This skips the text-layer check, which would fail anyway:

conv = indra_ocr.load(threads=4, mode="ocr")

For an image you already have in memory, pass a grayscale array to conv.ocr:

import cv2

gray = cv2.cvtColor(cv2.imread("photo.jpg"), cv2.COLOR_BGR2GRAY)
page = conv.ocr(gray)
print(page.text)

For a whole folder, convert_many runs one worker process per core:

import indra_ocr

if __name__ == "__main__":  # worker processes re-import this file
    for path, result in indra_ocr.convert_many(["a.pdf", "b.pdf"], cores=None):
        if isinstance(result, indra_ocr.InputError):
            continue  # unreadable or locked file
        for i, page in result:
            print(path, i, page.source)

With the code ready, I ran it on two real files.

Trying it on a rotated scan and an invoice

I used a rotated scanned PDF and a clean digital invoice. Page 1 of the scan has 138 lines in 33 blocks, and page 2 has 21 lines in 4 blocks. The invoice has 56 lines. I didn't turn the scan upright first.

I rendered the pages at 200 dpi, with 4 threads. Before I trusted the times, I checked the source. total_ms adds up every stage, including PDF rendering and the text-layer check. So these are end-to-end times per page, not a timer around the model alone.

Input Lines / blocks Mode Time
Scan, page 1 138 / 33 auto, first run 4.73 s
Scan, page 1 138 / 33 auto, second run 3.86 s
Scan, page 2 21 / 4 auto 3.00 s
Scan, page 2 21 / 4 ocr + math 1.70 s
Invoice 56 / 12 ocr + math 2.29 s

Three things stood out:

  • The first page is slower. It includes the ONNX session warm-up. The same page went from 4.73 s to 3.86 s on a second run.
  • Single runs are noisy on a small machine. The same page took 4.65 s on one run and 8.64 s on the next. I can't fully explain it. It could be thermal throttling, background load, or swap. Run each page twice and keep the second number.
  • Scans do better in ocr mode. Page 2 took 3.00 s in auto and 1.70 s in ocr mode. auto checks for a text layer first, and a scan has none.

The invoice was a clean page with no rotation and no text layer, and it still took 2.29 s. So even a simple page takes seconds on this CPU, and a dense scan takes a few more.

Seconds on its own doesn't mean much. So I looked for another CPU engine to compare it with.

Indra OCR vs PaddleOCR's text models

PaddleOCR itself doesn't run on this CPU. import paddle dies with Illegal instruction, because the CPU is a Celeron N4100 with no AVX, and the PaddlePaddle wheel expects it.

I could still run its text models. RapidOCR 3.10 ships PP-OCRv6 small on ONNX Runtime, and ONNX Runtime can fall back to SSE. I used the same page images, 4 threads, and one warm-up plus two timed runs.

Page Indra OCR PP-OCRv6 small (RapidOCR) Ratio
Scan, page 1 (138 lines) 8.3 s 87.6 s 10.6×
Scan, page 2 (21 lines) 4.3 s 31.6 s 7.3×
Invoice 6.4 s 26.9 s 4.2×

The machine was busy during these runs, so the seconds are inflated. Trust the ratios, not the seconds. RapidOCR also shrinks the long side of the page to 2,000 px, and Indra OCR uses the full 2,338 px. That helps RapidOCR's speed and hurts its accuracy on small print. Peak memory was 553 MB for Indra OCR and 711 MB for RapidOCR.

I also checked accuracy on fields I could read in the scan:

  • Invoice: Indra OCR got 16 of 16 fields. RapidOCR got 15 of 16, because it dropped the first line of a two-line product description.
  • Scan, page 2: both got 8 of 8.
  • Scan, page 1: RapidOCR got 12 of 12, and Indra OCR got 10 of 12. It missed the certificate number and a notice in the margin, and it garbled the masthead. Its footer was noisier too.

So the PaddleOCR models read tiny header and margin print better. Indra OCR was 4× to 11× faster, and it gave me tables and reading order, where RapidOCR gives lines.

That's my side. Here is how it sits next to what Datalab says.

How my numbers compare with Datalab's claims

Datalab publishes its own numbers. Here is the short version, next to what I saw:

Datalab says What I saw
Time per page, 4 cores 212 ms (median) 3.86 s on a dense scan, 2.29 s on a clean invoice
Speed vs PaddleOCR's text models About 10× at 32 cores 4× to 11× on my CPU
Accuracy 66.7 headline, ahead of PP-StructureV3 (58.4) Better on the invoice and on structure, worse on small header print

The speed gap has a simple reason. The 212 ms is a median over 2,937 pages, and most of them are digital PDFs that never need OCR. My dense scan went through every stage. A median tells you about a typical page, not about yours.

Hardware matters too. Datalab's README says throughput depends on the CPU. Across different x86 server types, it measured 25 to 51 pages per second at 32 cores. It also says median latency moves by about 15% between runs of the same code. So a Celeron with 4 cores will not match a server.

On accuracy, the win comes from layout and tables. On plain text, PP-StructureV3 scores higher (55.6 against 46.7), and Indra OCR only passes it with --math on (62.7).

None of this changes what I think of the model. It just means 212 ms is where to start, not what to expect. Before you rely on it, here are a few things to watch for.

What to watch for

  • Dense scans take seconds. Plan for this if your documents are scans, and use ocr mode for them.
  • Complex tables are a weak spot. Merged cells, nested headers and tables with no ruling lines can lose their structure. Simple grid tables read well.
  • Handwriting and degraded scans are weak. Datalab's own scores are 25.2% on its handwriting tests and 29.5% on degraded scans. For those, Datalab points to its managed Chandra model.
  • Math is plain text unless you turn on --math. That mode is slower, 357 ms against 212 ms in Datalab's runs.
  • The worker cap uses total RAM, not free RAM. convert_many starts one process per core, capped at RAM / 1.5 GB. On an 8 GB machine with other apps open, set cores yourself.
  • Check the license. The code is Apache 2.0. The weights are free for research, personal use, and startups under $20M in funding or revenue, and they can't be used to compete with Datalab's API.

So, is it worth trying?

I think so. It's small, it installs with one pip install, and the markdown output is usable as it is. It also doesn't drag a PyTorch install behind it. It's the first CPU-only OCR I've tried that I'd leave running on a low-end machine.

Just don't plan around 212 ms. Time a few of your own pages, twice each, and keep the second number.

If you've run it on your own scans, I'd like to see your numbers. Especially the ugly ones.