Skip to main content

MLX-OCR

⚡️ Fast and Efficient OCR Library using Apple MLX Framework 🍎


🚀 Quick Start

Install the library using pip:

pip install mlx-ocr

Then, badabim badabum, you can use the library like this:

from mlx_ocr import MLXOCR

ocr = MLXOCR(det_lang="eng", rec_lang="eng")
img = "path/to/image.jpg"
result = ocr(img)
print(result)

Check out the examples directory for more usage examples!

💡 Current Models & Future Models

Current Models (PP-OCRv3):

Currently, mlx-ocr implements the detection and recognition models from the student version of PP-OCRv3. These models are known for their efficiency and good performance.

  • Text Detection: Implemented and ready to use.
  • Text Recognition: Implemented and ready to use.

As the PP-OCRv3 language models share the same architecture and training configuration, weights should be broadly compatible across different languages. Refer to the PaddleOCR model list for detailed model information.

Future Model Implementations:

The focus will be on expanding model coverage and algorithmic improvements. Planned model additions include:

  • Angle Classification Model (PP-OCRv3): To enhance accuracy by correcting text orientation.
  • PP-OCRv4 Models: Exploring implementation of the next generation PP-OCRv4 models for potential performance gains.
  • Experimentation with other architectures: Investigating and potentially implementing other state-of-the-art OCR models within the MLX framework.

✨ Upcoming Features

  • [Planned] Beginner-Friendly Fine-tuning Tools: Creating user-friendly tools and guides for fine-tuning models and training new models, making the library more accessible to users with varying levels of expertise.
  • [Planned] Enhanced Documentation and Examples: Expanding documentation with more detailed explanations, tutorials, and diverse usage examples to improve user onboarding and understanding.

🥲 Disclaimer

Many functionalities are missing, and some parts of the code is not optimized. The models on their own are very performant, but preprocessing and postprocessing needs more work.

People who are used to training models and preparing datasets can easily use the models in this repository. However, I will try to make the library more beginner-friendly in the future, for fine-tuning and training new models.

🙌 Contributing

Contributions are welcome and encouraged! We strive to keep dependencies minimal and appreciate contributions in various forms:

  • Model Implementations: Help implement new OCR models within the MLX framework.
  • Algorithmic Improvements: Contribute to pre-processing, post-processing, or other algorithmic enhancements.
  • Bug Reports: Report any issues or unexpected behavior you encounter.
  • Feature Requests: Suggest new features or improvements you'd like to see.
  • Documentation: Help improve documentation, tutorials, and examples.
  • Code Review: Review and provide feedback on code changes.

The mlx_ocr/models directory is intentionally kept lightweight, depending only on mlx. We use pypdfium2 for PDF operations due to its permissive licensing (Apache 2.0 and BSD 3-Clause).

🙏 Acknowledgements

This project is inspired by and builds upon the excellent work of the PaddleOCR library. Code is adapted and translated (sometimes directly) from PaddleOCR. We are committed to proper citation and will continue to refine attributions. If you notice any missing citations, please let us know.

We also acknowledge inspiration from the mlx-vlm repository for code style and project structure.

Metadata

Release files for mlx-ocr 0.2.1

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

Source distribution (sdist)

Source distribution for mlx-ocr 0.2.1
File Size Uploaded Provenance Actions
mlx_ocr-0.2.1.tar.gz 312.6 kB Without provenance Details for mlx_ocr-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mlx-ocr 0.2.1
File Interpreter ABI Platform Actions
mlx_ocr-0.2.1-py3-none-any.whl Python 3 none any Details for mlx_ocr-0.2.1-py3-none-any.whl

Total release size: 632.1 kB

Release files / mlx_ocr-0.2.1.tar.gz

Download URL mlx_ocr-0.2.1.tar.gz
Size 312.6 kB
Tags Source
SHA-256 checksum
How to use checksums
9614d65c8d428c51d9dc81940b750a01fce7a0d9ac78af2efe9c5ef739fe723c
BLAKE2b-256 checksum
How to use checksums
fdd95df22f57b7540d1d6a50ac667dfd7dd0fab0224f0bd6377232a68483cf10
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.7

Release files / mlx_ocr-0.2.1-py3-none-any.whl

Download URL mlx_ocr-0.2.1-py3-none-any.whl
Size 319.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a3bb38e0c0300342f84fc316c44819bd9c3b99c49778d031b39bb86d371816a4
BLAKE2b-256 checksum
How to use checksums
85b9ae657421a980a818a4e2816f4f579ef51d2fe88b625faca5a94ba5b867ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.7

Security for mlx-ocr 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files No provenance

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