Add pennyocr input backend (hosted OCR API, stdlib-only) - #751
Open
imiraoui wants to merge 1 commit into
Open
Conversation
A stdlib-only input module for the PennyOCR API: uploads the document, returns plain text with form-feed page separators (matching pdftotext's convention). No local OCR engine, GPU or system binary needed; availability is gated on the PENNYOCR_API_KEY env var so it self-excludes when unset. Includes unit tests with the network mocked.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a new input backend for PennyOCR, a hosted VLM-based OCR API.
Why it fits invoice2data: users without a local OCR stack (no tesseract binary, no GPU for docTR/paddle, no GCS bucket for gvision) get scanned-invoice support with nothing but an env var. Handles scanned PDFs, photos and images; multipage output uses form-feed separators like the pdftotext backend, so existing templates behave identically.
Implementation notes
input/__interface__.py:to_text(path, area_details=None, **kwargs),SUPPORTS_AREA = False,is_available()gated onPENNYOCR_API_KEYso the backend self-excludes when unconfiguredINPUT_MODULESaspennyocr; README list updatedtests/test_pennyocr.py, network mocked): registration, availability gating, multipart request shape, error path — all passingService details, for transparency: commercial API, $0.75 per 1,000 pages with 100 free pages/month (no card), zero data retention by default. Disclosure: I'm the maintainer of PennyOCR. Happy to adjust anything — naming, error semantics, or moving it behind an extra if you prefer.
🤖 Generated with Claude Code