Layered OCR workhorse: extract text from scanned PDFs and images (tesseract, PyMuPDF, easyocr, paddleocr, vision).
Project description
pro-ledin-ocr
Layered OCR workhorse for scanned PDFs and images (PNG/JPG/TIFF/HEIC/WEBP). Baseline OCR uses Poppler and Tesseract; EasyOCR, PaddleOCR, and automated vision are opt-in engines.
- Import name:
pro.ledin.ocr - Console scripts:
ocr,peepshow-sink-ocr - Interactive vision handoff:
python -m pro.ledin.ocr.vision_handoff - PyPI:
pro-ledin-ocr
Install
pip install pro-ledin-ocr # baseline
pip install "pro-ledin-ocr[easyocr]" # EasyOCR
pip install "pro-ledin-ocr[paddle]" # PaddleOCR
pip install "pro-ledin-ocr[vision]" # automated OpenAI-compatible vision
pip install "pro-ledin-ocr[all]" # all optional Python engines/tools
Baseline PDF OCR also needs Poppler (pdftoppm, pdftotext, pdfinfo) and
Tesseract with required language data:
brew install poppler tesseract tesseract-lang # macOS
sudo apt install poppler-utils tesseract-ocr-all # Debian/Ubuntu
Windows and engine-specific setup: skills/ocr/references/engine-setup.md.
CLI
ocr myfile.pdf --probe # triage only; NDJSON result
ocr myfile.pdf --format md,json # multiple formats to stdout
ocr myfile.pdf --format md,txt,json --out results/
ocr scan.png --format md
ocr russian_doc.pdf --lang rus+eng --format md
ocr scan.pdf --preprocess full
ocr slides.pdf --engine vision --pages 9,12 \
--vision-api-key "$KEY" --vision-model my-vision-model \
--vision-prompt "Preserve tables and empty cells"
ocr scan.pdf --auto-escalate easyocr,vision \
--vision-api-key "$KEY" --vision-model my-vision-model
Engine resolution is explicit: --engine overrides OCR_ENGINE, otherwise
tesseract is used. There is no auto engine. Valid engines are tesseract,
easyocr, paddleocr, and vision. vision is automated, headless extraction
through an OpenAI-compatible endpoint; former automated-engine alias is gone.
--auto-escalate overrides OCR_AUTO_ESCALATE. Both accept an ordered,
comma-separated chain such as easyocr,vision. OCR validates every dependency
before baseline work. Flagged pages run through every engine in chain, in order.
Any attempt failure stops run and prevents workflow-cache write. Without a
configured chain, quality report recommends targeted page rerun.
Interactive multimodal-agent handoff is separate and does not call vision API:
python -m pro.ledin.ocr.vision_handoff slides.pdf \
--pages 9,12 --dpi 200 \
--vision-prompt "Read visible text and preserve table structure"
Handoff accepts --pages, --dpi, --vision-prompt, and
--vision-prompt-file; it intentionally has no --max-pages option.
See ocr --help for complete flag reference.
Output formats
--format accepts md, txt, json, comma-separated combinations, or all
(md,txt,json). Comma-format behavior introduced in 0.4.0 remains unchanged:
with multiple formats, --out is a directory and files use input stem. Multiple
inputs also use directory mode; duplicate stems are rejected. JSON output for
multiple inputs requires --out; --searchable-pdf accepts one input.
--json-report was removed in 0.4.0. Use
--format json --out report.json for JSON-only output or
--format md,json --out results/ for multiple files. One invocation cannot mix
stdout format with independently named JSON sidecar.
Peepshow sink
peepshow-sink-ocr reads peepshow JSON from stdin, recognizes primary frames,
and atomically writes <outputDir>/ocr.json:
peepshow video.mp4 --sink ocr
peepshow video.mp4 \
--sink-cmd 'peepshow-sink-ocr --engine tesseract --lang rus+eng'
Named sink configuration uses PEEPSHOW_SINK_OCR_* variables, including
PEEPSHOW_SINK_OCR_AUTO_ESCALATE. Automated vision works in sink mode with
pro-ledin-ocr[vision], key, and model. Interactive handoff does not run inside
sink processes. See skills/ocr/references/peepshow-sinks.md.
Library
from pro.ledin import ocr
pages = ocr.recognize(
"scan.pdf",
ocr.RecognizeOptions(
engine="vision",
vision_api_key="key",
vision_model="model",
vision_prompt="Preserve checkbox states and labels.",
),
)
markdown = ocr.to_markdown(pages, "scan.pdf")
recognize() never calls sys.exit(); catch ocr.OcrError for recoverable
failures such as unsupported input, missing dependencies, or vision config.
Engine tiers
| Tier | Engine | Best for | Cost |
|---|---|---|---|
| 0 | pdftotext / PyMuPDF | Real text layers | Free, instant |
| 1 | tesseract (default) | Clean scans and typed text | Free |
| 2 | easyocr | Handwriting and degraded scans | Free, heavy |
| 2.5 | paddleocr | CJK, multilingual, angled text | Free, heavy |
| 3 | vision | Automated tables, charts, complex layouts | API cost |
| Handoff | python -m pro.ledin.ocr.vision_handoff |
Interactive agent reading | Agent/model tokens |
Full docs: skills/ocr/SKILL.md,
skills/ocr/references/engines.md,
skills/ocr/references/engine-setup.md,
skills/ocr/references/peepshow-sinks.md, and
skills/ocr/references/troubleshooting.md.
Development
uv sync --extra dev
uv run --extra dev pytest
uv build
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pro_ledin_ocr-0.5.0.tar.gz.
File metadata
- Download URL: pro_ledin_ocr-0.5.0.tar.gz
- Upload date:
- Size: 50.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
77104620e5d091d53d95e1c511855499641a669fbacd2228d5f2c515e55d2304
|
|
| MD5 |
412a322b1f7259dceca2485ceb49ef8f
|
|
| BLAKE2b-256 |
d87b12e24a14b54bef3248d8a830f4c776fcae2a073f8f9733c2c145ef5843f6
|
File details
Details for the file pro_ledin_ocr-0.5.0-py3-none-any.whl.
File metadata
- Download URL: pro_ledin_ocr-0.5.0-py3-none-any.whl
- Upload date:
- Size: 33.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab6ac83fa567b692a1344b2c9990eb12f0eead9a51354d272672d113f1d8ccd4
|
|
| MD5 |
b4a098610f9214855bb32a0d46ad264c
|
|
| BLAKE2b-256 |
f4668561880570428e28cef3c13c499912a2deb104b627db920552454d9cff1b
|