A lightweight OCR library for Khmer and English documents
Project description
Kiri OCR 📄
Kiri OCR is a lightweight OCR library for English and Khmer documents. It provides document-level text detection, recognition, and rendering capabilities.
🚀 Try the Live Demo | 📚 Full Documentation
✨ Key Features
- High Accuracy: Transformer model with hybrid CTC + attention decoder
- Bi-lingual: Native support for English and Khmer (and mixed text)
- Document Processing: Automatic text line and word detection
- Streaming: Real-time character-by-character output (like LLM streaming)
- Easy to Use: Simple Python API and CLI
📦 Installation
pip install kiri-ocr
💻 Quick Start
CLI Tool
kiri-ocr document.jpg
Python API
from kiri_ocr import OCR
# Initialize (auto-downloads from Hugging Face)
ocr = OCR()
# Extract text from document
text, results = ocr.extract_text('document.jpg')
print(text)
# Get detailed box-by-box results
for line in results:
print(f"{line['text']} (confidence: {line['confidence']:.1%})")
Decoding Methods
Choose the decoding method based on your speed/quality tradeoff:
# Fast (CTC) - Fastest, good for batch processing
ocr = OCR(decode_method="fast")
# Accurate (Decoder) - Balanced speed and quality (default)
ocr = OCR(decode_method="accurate")
# Beam Search - Best quality, slowest
ocr = OCR(decode_method="beam")
Streaming Recognition
Get character-by-character output like LLM streaming:
from kiri_ocr import OCR
ocr = OCR(decode_method="accurate")
# Stream characters as they're decoded
for chunk in ocr.extract_text_stream_chars('document.jpg'):
print(chunk['token'], end='', flush=True)
if chunk['document_finished']:
print() # Done!
📚 Documentation
Full documentation is available on the Wiki:
- Installation
- Quick Start Guide
- Python API Reference
- CLI Reference
- Training Guide
- Detector API
- Architecture
📊 Benchmark
Results on synthetic test images (10 popular fonts):
📁 Project Structure
kiri_ocr/
├── core.py # OCR class
├── model.py # Transformer model
├── training.py # Training code
├── cli.py # Command-line interface
└── detector/ # Text detection
├── db/ # DB detector
└── craft/ # CRAFT detector
☕ Support
If you find this project useful:
- ⭐ Star this repository
- Buy Me a Coffee
- ABA Payway
⚖️ License
📚 Citation
@software{kiri_ocr,
author = {mrrtmob},
title = {Kiri OCR: Lightweight Khmer and English OCR},
year = {2026},
url = {https://github.com/mrrtmob/kiri-ocr}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kiri_ocr-0.2.13.tar.gz.
File metadata
- Download URL: kiri_ocr-0.2.13.tar.gz
- Upload date:
- Size: 84.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da849924b0ea43d9389a814208b4ca4f62df6750d06e29771ce67e365a4a6b6f
|
|
| MD5 |
289e39461ae0e331192153ba46bf234b
|
|
| BLAKE2b-256 |
f996a73df5a6101555a4038171c5691084e0c51a51221cd934de0cb8e12229ba
|
File details
Details for the file kiri_ocr-0.2.13-py3-none-any.whl.
File metadata
- Download URL: kiri_ocr-0.2.13-py3-none-any.whl
- Upload date:
- Size: 89.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
09eaaec453f3d896e2e5af578e4c0c785857fc366d522029d25cc67bf74f85a7
|
|
| MD5 |
4df7f443e70d0961cef3c4edc68d4602
|
|
| BLAKE2b-256 |
5cbc3ca91cd81e3e54fc3a2b3e47fb1258e18528f3e3f76c4385ca2731ac1dea
|