Skip to main content

No project description provided

Project description

MyOCR - Advanced OCR Pipeline Builder

myocr logo

Docs HuggingFace Docker PyPI License

English | 简体中文

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

🌟 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.03 inner refactoring & update docs
  • 2025.04.28 release MyOCR alpha version:
    • Release image detection, class, recognition models
    • All components can work together

🛠️ Installation

📦 Requirements

  • Python 3.11+
  • Optional: CUDA 12.6+ (Recommended for GPU acceleration, but CPU mode is also supported)

📥 Install Dependencies

# Clone the code from GitHub
git clone https://github.com/robbyzhaox/myocr.git
cd myocr

# create venv
uv venv

# Install dependencies
pip install -e .

# Development environment installation
pip install -e ".[dev]"

# Download pre-trained model weights
mkdir -p ~/.MyOCR/models/
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'
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:cpu-0.1.0

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 properly
  • POST /ocr: Basic OCR recognition
  • POST /ocr-json: Structured OCR output

We also have a UI for these endpoints, please refer to doc-insight-ui

Star History

Star History Chart

🎖 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.

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

myocr_kit-0.1.0a3.tar.gz (62.4 kB view details)

Uploaded Source

Built Distribution

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

myocr_kit-0.1.0a3-py3-none-any.whl (66.8 kB view details)

Uploaded Python 3

File details

Details for the file myocr_kit-0.1.0a3.tar.gz.

File metadata

  • Download URL: myocr_kit-0.1.0a3.tar.gz
  • Upload date:
  • Size: 62.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.12

File hashes

Hashes for myocr_kit-0.1.0a3.tar.gz
Algorithm Hash digest
SHA256 13abcdfc3b7051bd79bf4c887ebbb3a5ded985e33bde8cb8d4a7b4444b3cc416
MD5 fd673ec6705e134ab123cd8d305f789d
BLAKE2b-256 b02e9cf9e686729efc4ae08aa1837dd6f3ad7d842a96e6598d3c7da5dede31c2

See more details on using hashes here.

File details

Details for the file myocr_kit-0.1.0a3-py3-none-any.whl.

File metadata

  • Download URL: myocr_kit-0.1.0a3-py3-none-any.whl
  • Upload date:
  • Size: 66.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.12

File hashes

Hashes for myocr_kit-0.1.0a3-py3-none-any.whl
Algorithm Hash digest
SHA256 27e4ab2437f3e1c47deca56550f84ab917d576cb420a3099a7ec981a1bcc12b8
MD5 2e3350f53ca573a1a1f8fe939a09954f
BLAKE2b-256 f603ed7c378fca6275884a44c1ac6aa4ad173df27c83c70312425b5d78840ad0

See more details on using hashes here.

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