Skip to main content

Plugin to run OCRmyPDF with the EasyOCR engine

Project description

OCRmyPDF EasyOCR

This is a plugin to run OCRmyPDF with the EasyOCR engine instead of Tesseract OCR, the default OCR engine for OCRmyPDF. Since EasyOCR is based on PyTorch, it makes use of Nvidia GPUs. Hopefully it will be more performant and accurate than Tesseract OCR.

It is currently experimental and does not implement all of the features of OCRmyPDF with Tesseract, and still relies on Tesseract for certain operations.

Requirements

  • OCRmyPDF 17 or newer. As of 0.3.0, this plugin returns structured OCR results to OCRmyPDF, which renders the text layer itself using its built-in renderer. (For OCRmyPDF 14–16, use a < 0.3.0 release of this plugin.)
  • Python 3.11 or newer.

Installation

To use this plugin, first install PyTorch according to the official instructions, which may differ for your platform.

Then install OCRmyPDF-EasyOCR into the same virtual environment or conda environment as you installed PyTorch:

pip install git+https://github.com/ocrmypdf/OCRmyPDF-EasyOCR.git

Once installed, the plugin is discovered automatically through its entry point, and OCRmyPDF uses EasyOCR for OCR by default (i.e. for --ocr-engine auto). You can also select it explicitly with --ocr-engine easyocr, or fall back to the built-in engines with --ocr-engine tesseract / --ocr-engine none. OCR still depends on Tesseract for some non-OCR tasks (see below).

Development

This project uses uv for package management.

uv sync --group test   # create the virtual environment and install dependencies
uv run pytest          # run the test suite

The tests need poppler's pdftotext and a Tesseract installation available on PATH, and will download EasyOCR's models on first run.

Troubleshooting

If you see a log message Neither CUDA nor MPS are available - defaulting to CPU. Note: This module is much faster with a GPU then PyTorch is not installed with GPU support.

Pass --easyocr-no-gpu to force CPU mode, or --easyocr-batch-size to tune the EasyOCR batch size.

To do

Contributions, especially pull requests, are quite welcome!

This plugin is experimental and is missing some features:

  • Tesseract is still required to determine page orientation.
  • EasyOCR is effectively single-threaded, to eliminate race conditions; OCRmyPDF still parallelizes other stages of the pipeline across pages.

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

ocrmypdf_easyocr-0.3.0.tar.gz (188.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ocrmypdf_easyocr-0.3.0-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file ocrmypdf_easyocr-0.3.0.tar.gz.

File metadata

  • Download URL: ocrmypdf_easyocr-0.3.0.tar.gz
  • Upload date:
  • Size: 188.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ocrmypdf_easyocr-0.3.0.tar.gz
Algorithm Hash digest
SHA256 0f9d2d28ca6eb5e32f07133bf8c94c0990c7f73af50d0480f6ec48b6bc6456a9
MD5 030a4d16d7f4c803a39f6dc8b74cbe15
BLAKE2b-256 a8002dd828cd51b38f72f570cd17c80bddca5c1bab55ccb5fa07b6ad44ad995c

See more details on using hashes here.

Provenance

The following attestation bundles were made for ocrmypdf_easyocr-0.3.0.tar.gz:

Publisher: publish.yml on ocrmypdf/OCRmyPDF-EasyOCR

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ocrmypdf_easyocr-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for ocrmypdf_easyocr-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 22ebb336a70f9d0d598034fb52314a60b624d748759a140ab84be3d03697ba52
MD5 0af0c4321caea549d920206ae3340a35
BLAKE2b-256 3eaec7a20ae350d9d8d66f8f9e96036c54dc28b83463dba8f0372148ae3bb958

See more details on using hashes here.

Provenance

The following attestation bundles were made for ocrmypdf_easyocr-0.3.0-py3-none-any.whl:

Publisher: publish.yml on ocrmypdf/OCRmyPDF-EasyOCR

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page