datalab-to/indra
1M param OCR model - runs on CPU, 15x faster than tesseract, close to 1B+ param models in accuracy
What is Indra OCR?
Indra OCR is a tiny (≈1 M‑parameter) optical‑character‑recognition model that runs on CPUs. It can read PDFs and images at up to 49 pages / second (≈230 ms per page on 4 x86 vCPUs) and outputs the result as markdown, plain text, or JSON with detailed layout information.
Key Features
- Speed – 11‑17× faster than Tesseract/PaddleOCR on the same hardware.
- Accuracy – OmniParseBench headline score 62.1, beating PaddleOCR’s full pipeline (58.4).
- Layout awareness – bounding boxes for every line and block, block labels (headings, tables, captions, footnotes, etc.) and reading order.
- Hybrid PDF handling – uses a PDF’s native text layer when it passes quality checks; otherwise falls back to OCR, saving work.
- Small footprint – ~18 MB ONNX model, no PyTorch, runs with ONNX Runtime, OpenCV and pypdfium2.
- Multi‑language OCR – Latin, Cyrillic, Greek, Devanagari, Bengali, Chinese (simplified & traditional). Digital PDFs support any script via the text layer.
- Optional math support –
--mathflag adds a classifier and a second recognizer that outputs LaTeX‑style inline math. - Local viewer –
indra-ocr-viewershows pages with overlayed boxes, markdown, JSON and timings.
Quick Start (CLI)
pip install indra-ocr # install the package
indra-ocr paper.pdf # markdown to stdout
indra-ocr *.pdf --out results/ # one .md per file, all cores
indra-ocr scan.png --format json # JSON with lines, boxes, confidences
indra-ocr-viewer # open http://localhost:8765
The first run downloads the ONNX model from Hugging Face (≈18 MB).
Python API (basic example)
import indra_ocr
conv = indra_ocr.load(threads=4) # auto mode (text‑layer + OCR)
for i, page in conv.convert("paper.pdf"):
print(page.markdown) # markdown with headings, tables, etc.
print(page.blocks) # list of layout blocks with labels
For bulk conversion use indra_ocr.convert_many([...], cores=None) which spawns one worker per CPU core.
Output structure
markdown– formatted text (headings, lists, tables as HTML). Headers/footers omitted unless--keep-furniture.text– plain‑text, one line per detected line.lines– list ofLine(box, text, confidence)objects.blocks– layout blocks withlabel,bbox,textin reading order.source–text(PDF layer),ocr,hybridorerror.timings– per‑stage milliseconds, plus total.- Additional meta like
rotation,skew, and a shortnoteexplaining the processing path.
When to use Indra OCR vs. the managed service
Indra OCR shines for clean printed documents where CPU‑only speed is essential. It is not suited for:
- Complex tables with merged cells or spanning rows.
- Handwritten text.
- Scripts outside the OCR list (Arabic, Hebrew, Thai, Japanese, Korean) – those work only via the PDF text layer.
- Very degraded or low‑resolution scans.
- Vertical text, banner‑wide pages, engineering‑drawing labels, or pages > 100 MP at 200 dpi. For those cases the authors recommend their higher‑accuracy, GPU‑backed model Chandra via the Datalab managed platform.
Licensing & Commercial Use
- Code – Apache 2.0.
- Model weights – Modified OpenRAIL‑M (free for research, personal use, and startups < $20 M revenue). Commercial use that competes with Datalab’s API requires a separate license (see the pricing page).
Installation notes
pip install indra-ocr # stable release
# or latest GitHub version
pip install git+https://github.com/datalab-to/indra.git
# optional Tesseract comparison support
pip install "indra-ocr[tesseract]"
Supported on Python 3.10+, Linux (x86_64 & aarch64) and macOS (Apple silicon). The package pulls ONNX Runtime, OpenCV and pypdfium2 automatically.
Benchmarks at a glance
| Metric | Indra OCR (default) | PaddleOCR PP‑OCRv6 (text only) | Tesseract 5 |
|---|---|---|---|
| Throughput (pages / s) – 32 cores | 49.4 | 4.28 | 2.92 |
| Median latency per page | 228 ms | 2 685 ms | 5 496 ms |
| OmniParseBench headline | 62.1 | – | – |
| Text score | 41.3 | 35.8 | 19.3 |
| Table score | 56.4 | 0.0 | 0.0 |
| Layout score | 88.6 | – | – |
Where to learn more
- Homepage: https://www.datalab.to
- Model on Hugging Face: https://huggingface.co/datalab-to/indra-ocr
- Docs & Playground: https://documentation.datalab.to & https://www.datalab.to/playground
- Discord community: https://discord.gg/KuZwXNGnfH
TL;DR
Indra OCR is a lightweight, CPU‑only OCR engine that delivers high speed and respectable accuracy for printed documents, with rich layout output and an easy‑to‑use CLI/Python API. It’s ideal for batch processing of clean PDFs or images when you need results fast and can tolerate its limitations on complex tables, handwriting, or non‑Latin scripts.
Related
- Project
- Project
- Project
- Project