Skip to main content

OpenMLkit OCR

A lightweight, offline Python OCR (Optical Character Recognition) library utilizing highly optimized, mobile-ready Google ML Kit TFLite models. It performs text detection using a Region Proposal Network (RPN) and line recognition using a CRNN-CTC architecture.


Features

  • Fully Offline: Runs entirely local, no API keys or internet connection required after downloading models.
  • Multilingual Support: Supports 15+ languages and scripts (Cyrillic/Russian, Latin/English, Chinese, Japanese, Korean, Arabic, Hebrew, and various Indian scripts).
  • Auto-downloading: Automatically downloads and caches required models from Hugging Face if they are not present locally.
  • High Quality Stitching: Handles wide text lines without squishing by dividing them into overlapping chunks and merging them using fuzzy suffix-prefix alignment.

Installation

Install the package directly using pip:

pip install openmlkitOCR

Or install from source:

git clone https://github.com/0cve0/OpenMLkitOCR.git
cd OpenMLkitOCR
pip install -e .

Quick Start

import os
import cv2
from openmlkit import OpenMLKitOCR

# Configure Hugging Face model source (or use defaults)
os.environ["OPENMLKIT_MODEL_REPO"] = "0cve0/OpenMLKitOCR"

# Initialize OCR pipeline for Cyrillic (Russian) text
ocr = OpenMLKitOCR(lang='ru')

# Load image
img = cv2.imread("scratch/russian_test.png")

# Run OCR (detect and recognize text)
results = ocr.run(img, score_threshold=0.35)

# Output results
for r in results:
    print(f"Box: {r['box']} -> Text: {r['text']}")

Project Structure

  • openmlkit/ - Core Python package directory.
    • detector.py - RPN text detection logic.
    • recognizer.py - CRNN text recognition logic.
    • labelmap.py - Parse binary protobuf label maps.
    • pipeline.py - OCR pipeline joining detection, tiling, and recognition.

License

This project is licensed under the Apache 2.0 License. The model weights are subject to Google's terms and licenses for ML Kit.

Metadata

Release files for openmlkitOCR 1.0.3

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

Source distribution (sdist)

Source distribution for openmlkitOCR 1.0.3
File Size Uploaded
openmlkitocr-1.0.3.tar.gz 16.0 kB Details

Built distribution (wheel)

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

Total release size: 32.5 kB

Release files / openmlkitocr-1.0.3.tar.gz

Download URL openmlkitocr-1.0.3.tar.gz
Size 16.0 kB
Tags Source
SHA-256 checksum
How to use checksums
323a325abfb645b4f51e5a8dc832c53474a6a6fb17d9f6d49659bf396126feed
BLAKE2b-256 checksum
How to use checksums
a97570c73943366b98e22f90a557bcd7f3be06947489751f19fd04281e630ba8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.5

Release files / openmlkitocr-1.0.3-py3-none-any.whl

Download URL openmlkitocr-1.0.3-py3-none-any.whl
Size 16.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e0c3a506a23f0554a80b870b3779fa8a81dd945d08a7aad02f82aa157f621f8a
BLAKE2b-256 checksum
How to use checksums
bab40234f4946af69278bf0858694c651c0a456036e77d1bc7419ddabeace7e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.5

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.1

2 release files

1.0.0

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