MyOCR is a highly extensible and customizable framework for building OCR systems. Engineers can easily train, integrate deep learning models into custom OCR pipelines for real-world applications.
Try the online demo on HuggingFace or ModelScope
🌟 Key Features:
⚡️ End-to-End OCR Development Framework – Designed for developers to build and integrate detection, recognition, and custom OCR models in a unified and flexible pipeline.
🛠️ Modular & Extensible – Mix and match components - swap models, predictors, or input output processors with minimal changes.
🔌 Developer-Friendly by Design - Clean Python APIs, prebuilt pipelines and processors, and straightforward customization for training and inference.
🚀 Production-Ready Performance – ONNX runtime support for fast CPU/GPU inference, support various ways of deployment.
📣 Updates
- 🔥2025.05.17 MyOCR v0.1.1 released
🛠️ Installation
📦 Requirements
- Python 3.11+
- CUDA: Version 12.6 or higher is recommended for GPU acceleration. CPU-only mode is also supported.
- Operating System: Linux, macOS, or Windows.
📥 Install Dependencies
# Clone the code from GitHub
git clone https://github.com/robbyzhaox/myocr.git
cd myocr
# You can create your own venv before the following steps
# Install dependencies
pip install -e .
# Development environment installation
pip install -e ".[dev]"
# Download pre-trained model weights to models
# for Linux, macOS
mkdir -p ~/.MyOCR/models/
# for Windows, the "models" directory can be created in the current path
Download weights from: https://drive.google.com/drive/folders/1RXppgx4XA_pBX9Ll4HFgWyhECh5JtHnY
# Alternative download link: https://pan.baidu.com/s/122p9zqepWfbEmZPKqkzGBA?pwd=yq6j
🚀 Quick Start
🖥️ Local Inference
Basic OCR Recognition
from myocr.pipelines import CommonOCRPipeline
# Initialize common OCR pipeline (using GPU)
pipeline = CommonOCRPipeline("cuda:0") # Use "cpu" for CPU mode
# Perform OCR recognition on an image
result = pipeline("path/to/your/image.jpg")
print(result)
Structured OCR Output (Example: Invoice Information Extraction)
config chat_bot in myocr.pipelines.config.structured_output_pipeline.yaml
chat_bot:
model: qwen2.5:14b
base_url: http://127.0.0.1:11434/v1
api_key: 'key'
Note: chat bot currently support:
- Ollama API
- OpenAI API
from pydantic import BaseModel, Field
from myocr.pipelines import StructuredOutputOCRPipeline
# Define output data model, refer to:
from myocr.pipelines.response_format import InvoiceModel
# Initialize structured OCR pipeline
pipeline = StructuredOutputOCRPipeline("cuda:0", InvoiceModel)
# Process image and get structured data
result = pipeline("path/to/invoice.jpg")
print(result.to_dict())
🐳 Docker Deployment
The framework provides support for Docker deployment, which can be built and run using the following commands:
Run the Docker Container
docker run -d -p 8000:8000 robbyzhaox/myocr:latest
# set the environment variables like following with -e option of docker run if you want use the StructuredOutputOCRPipline
docker run -d \
-p 8000:8000 \
-e CHAT_BOT_MODEL="qwen2.5:14b" \
-e CHAT_BOT_BASEURL="http://127.0.0.1:11434/v1" \
-e CHAT_BOT_APIKEY="key" \
robbyzhaox/myocr:latest
Accessing API Endpoints (Docker)
IMAGE_PATH="your_image.jpg"
BASE64_IMAGE=$(base64 -w 0 "$IMAGE_PATH") # Linux
#BASE64_IMAGE=$(base64 -i "$IMAGE_PATH" | tr -d '\n') # macOS
curl -X POST \
-H "Content-Type: application/json" \
-d "{\"image\": \"${BASE64_IMAGE}\"}" \
http://localhost:8000/ocr
🔗 Using Rest API
The framework provides a simple Flask API service that can be called via HTTP interface:
# Start the service default port: 5000
python main.py
API endpoints:
GET /ping: Check if the service is running properlyPOST /ocr: Basic OCR recognitionPOST /ocr-json: Structured OCR output
We also have a UI for these endpoints, please refer to doc-insight-ui
Star History
🎖 Contribution Guidelines
We welcome any form of contribution, including but not limited to:
- Submitting bug reports
- Adding new features
- Improving documentation
- Optimizing performance
📄 License
This project is open-sourced under the Apache 2.0 License, see the LICENSE file for details.
Metadata
Release files for myocr-kit 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| myocr_kit-0.1.1.tar.gz | 64.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| myocr_kit-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 133.1 kB
Release files / myocr_kit-0.1.1.tar.gz
| Download URL | myocr_kit-0.1.1.tar.gz |
|---|---|
| Size | 64.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c1d81db1798c583578ed3935b9f5a4101c0a6d3147751abda511adab9f167b4a
|
|
BLAKE2b-256 checksum How to use checksums |
352c2911add96218873006a915562624b54d07dc8b62d48990cd2b06a355f41d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.12
|
Release files / myocr_kit-0.1.1-py3-none-any.whl
| Download URL | myocr_kit-0.1.1-py3-none-any.whl |
|---|---|
| Size | 68.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
32b8593c9cb4435958435eb2901f83f1d1c7dd6fc114dc3deba765cd69576dee
|
|
BLAKE2b-256 checksum How to use checksums |
4cf9bf2169674955c049481dcfd26d521d99271cfb04045e34f83760d5fde6b5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.12
|