
Chandra OCR
github.com/datalab-to/chandra- Category
- AI Tools
- Rank
- No. 289Tools index
- Pricing
- Freemium
- Type
- TOOL
- Builder
- datalab-to
- GitHub
- 12.2k stars
- Latest release
- v0.2.0
- Date
About
State-of-the-art OCR model that converts images and PDFs into structured HTML/Markdown/JSON while preserving complex layouts. Handles handwriting, forms, tables, math equations, and supports 90+ languages with excellent accuracy.
What it does
Chandra turns each document page into a model request, then cleans the returned layout blocks into usable document artifacts. It rasterizes PDFs, scales page images, interprets model-produced HTML, preserves tables and math markup, crops detected figures, and records page-level metadata.
Why it's ranked here
The strongest case is breadth plus deployability. One pipeline covers PDFs, common image formats, directories, page selection, figures, forms, and layout-aware text. The published comparison reports strong results across tables and difficult scans. However, most comparison figures are the project’s own benchmarks, so validate representative documents before committing.
What's good
The output pipeline does more than copy model text. It filters blank pages, optionally removes headers and footers, repairs missing paragraph structure, retains HTML tables inside Markdown, preserves math delimiters, and crops figure regions into separate images. Batch controls and retry logic make the remote inference path practical for larger jobs.
Tradeoffs
Local inference pulls in Torch and Transformers, while the supplied vLLM launcher assumes Docker, NVIDIA GPUs, and elevated privileges. The managed service is described as more accurate than the open weights. Code uses Apache 2.0, but model weights carry commercial restrictions, including limits tied to company size and competition with the vendor API.
How to use it well
Use it for document conversion pipelines where page structure, formulas, tables, or extracted figures matter more than plain text alone. Start with the interactive app on representative pages, then move repeatable work to directory batches through vLLM. Choose local Hugging Face inference when self-contained execution matters. It does not supply the model runtime hardware for you.
Technical notes+
pyproject.toml defines the chandra-ocr Python package, optional hf and app dependency groups, and four console scripts. chandra/input.py renders PDFs through pypdfium2, flattens forms, and converts pages to RGB images. chandra/model/hf.py runs AutoModelForImageTextToText; chandra/model/vllm.py sends base64 images through the OpenAI client to an OpenAI-compatible vLLM endpoint, with concurrent workers and repeat-token retries. chandra/output.py parses top-level layout divs, rescales normalized bounding boxes, extracts figure crops, and converts HTML to Markdown while retaining tables and math. chandra/scripts/vllm.py launches a GPU-tuned Docker container.
Observed
- Code license
- Apache 2.0
- Model license
- Modified OpenRAIL-M with stated commercial-use restrictions
- Primary language
- Python
- Runtime requirement
- Python 3.10 or newer
- Installation surface
- pip package with optional Hugging Face, Streamlit app, and combined extras
- Interfaces
- Command-line tools, Streamlit application, local Hugging Face inference, and OpenAI-compatible vLLM inference
- Input surface
- Single files or directories containing PDFs and common raster image formats
- Output surface
- Markdown, HTML, JSON metadata, layout chunks, and extracted images
Read from README.md, pyproject.toml, chandra/util.py, chandra/input.py, chandra/output.py, chandra/prompts.py, chandra/settings.py, chandra/model/hf.py, chandra/model/util.py, chandra/model/vllm.py, chandra/scripts/app.py, chandra/scripts/cli.py, chandra/model/schema.py, chandra/scripts/vllm.py.
What it can do
Convert PDF documents to structured text
PDF file → HTML/Markdown/JSON text
Extract text from images
Image file → HTML/Markdown/JSON text
Convert handwritten text to digital text
Image or PDF with handwriting → Structured text preserving layout
Extract data from forms
Image or PDF containing forms → Structured data in HTML/Markdown/JSON
Convert tables to structured data
Image or PDF with tables → Structured table data in HTML/Markdown/JSON
Extract mathematical equations
Image or PDF with math equations → Structured mathematical notation
Process documents in multiple languages
Image or PDF in any of 90+ languages → Text in original language with preserved layout
Tags
Tech Stack
Comments (0)
No comments yet
Editorially curated, with community endorsements as a secondary signal. Corrections welcome.