DeepOCR
OCR pipeline for historical and esoteric texts. Two engines, transformer-based layout detection, structured output — built to read documents most tools ignore.
The Problem
Most OCR tools are built for clean, modern documents. Feed them a 17th-century manuscript, a scanned esoteric treatise, or a book with drop capitals, margin notes, and decorative borders — and they produce garbage. They flatten the structure, lose the footnotes, and have no concept of reading order.
DeepOCR is built for the documents everyone else ignores.
Two Engines, One Pipeline
Vision engine for scanned and image-heavy PDFs — pages rendered and sent to a LightOn 2B model on a HuggingFace Inference Endpoint. This is the path for old books, manuscripts, anything without a machine-readable text layer.
Text engine for born-digital PDFs — PyMuPDF extracts the embedded text layer directly as Markdown. No vision model, no API calls, no cost.
Auto mode samples the first five pages and picks the right engine. The pipeline assumes nothing about the input.
Layout Detection for Old Books
A D-FINE transformer model trained on LADaS — a multi-century dataset from the 17th century to present — identifies 37 region types: paragraphs, headings, margin notes, drop capitals, tables, figures, stamps, music notation, decorative elements. SegmOnto controlled vocabulary throughout.
Kraken's baseline segmentation then detects individual text lines as polygon boundaries — not rectangles, but shapes that follow the actual curve of text on warped pages. Lines are assigned to their enclosing region by centroid. The result is a reading order that respects the page, not just its bounding box.
Structured Output, Not a Text Dump
Each source produces a single book.json — body text, margin notes,
footnotes, headers, figures, tables, page numbers, and catchwords in separate fields.
Detected figures and tables are automatically cropped to JPEG and saved alongside.
This is what makes DeepOCR useful as infrastructure. Downstream apps read
book.json from Supabase S3 and work with the data directly. The primary
consumer is monsieur.lib — a library reader that serves the OCR text
next to the original scan, renders markdown, and inlines cropped figures. A single-page
re-OCR button delegates back to DeepOCR without either system knowing the other's internals.
What It Can Read
Tested on 17th-century printed books, esoteric and hermetic treatises, manuscripts with handwritten marginal additions, academic papers, auction catalogs, and modern reports. The LADaS training set covers monographs, PhD theses, magazines, and multi-script documents — Latin, Hebrew, Arabic, blackletter.
If a document has been digitized, DeepOCR can give it structure.
In Use