Skip to main content

medhaocr

OCR for scanned and digital documents that runs on a normal CPU - no GPU, no cloud. Give it a PDF, JPG, JPEG or PNG (the type is detected automatically) and it prints the text of every page, keeping headings, side-by-side fields and tables in place.

Install

Python 3.10 or newer, then:

pip install medhaocr

The first run downloads the OCR models once (~250 MB, needs internet); after that it works offline.

Use from the command line

medhaocr scan.pdf
medhaocr photo.jpg
medhaocr scan.pdf > scan.txt        # save the text to a file

Output - the file name and page number, then that page's text:

scan.pdf - Page 1
# INVOICE
Invoice No   : 1234                    Date : 01/01/2025
| Item     | Qty | Amount |
|----------|-----|--------|
| Paper A4 | 2   | 500.00 |

scan.pdf - Page 2
...

Use from Python

from medhaocr import extract, extract_text

for page in extract("scan.pdf"):          # one result per page
    print(page["file"], page["page"], page["seconds"])
    print(page["text"])

text = extract_text("photo.jpg")          # all pages as one string

What it does

Per page: crop scanner borders, straighten tilted scans, remove punch holes -> detect and read every text line (PP-OCRv6; a fast model reads every line, a stronger one re-reads uncertain lines) -> find headings, text blocks, tables and logos (PP-DocLayout v2) -> rebuild table rows and columns (SLANet+) -> print in reading order. Typically 4-9 seconds per page on a laptop CPU.

Best on digital and scanned printed documents. Handwriting is not supported. Always check important values (numbers, dates, IDs) against the original.

License

Apache-2.0

Metadata

Release files for medhaocr 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for medhaocr 0.1.0
File Size Uploaded
medhaocr-0.1.0.tar.gz 19.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for medhaocr 0.1.0
File Interpreter ABI Platform
medhaocr-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 39.0 kB

Release files / medhaocr-0.1.0.tar.gz

Download URL medhaocr-0.1.0.tar.gz
Size 19.7 kB
Tags Source
SHA-256 checksum
How to use checksums
41c02bfbfacb1b698afe598f97560f93add7de073babf54c6e9a5a5dc9fa425f
BLAKE2b-256 checksum
How to use checksums
6ac0b8dcbf30f1aaa8d1c1d15d6a7f65fa2aec16e0b66bb50a51b81bd68d6bd4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / medhaocr-0.1.0-py3-none-any.whl

Download URL medhaocr-0.1.0-py3-none-any.whl
Size 19.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0e1ee92936e617be56d3730fed218e409ad501ff8e55884de4a0b6ef82a77539
BLAKE2b-256 checksum
How to use checksums
48c464abc9ccfcaf1d24bbc621b057d6ec49318e69bc13fb52363f55737871ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page