Skip to main content

Kiri OCR 📄

PyPI version License Python Versions Downloads Hugging Face Model Hugging Face Spaces

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

Kiri OCR

✨ 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:

📊 Benchmark

Results on synthetic test images (10 popular fonts):

Benchmark Graph

📁 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:

Join our Discord Community](https://discord.gg/Vcrw274RVC)

⚖️ License

Apache License 2.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kiri_ocr-0.2.15.tar.gz (84.5 kB view details)

Uploaded Source

Built Distribution

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

kiri_ocr-0.2.15-py3-none-any.whl (89.9 kB view details)

Uploaded Python 3

File details

Details for the file kiri_ocr-0.2.15.tar.gz.

File metadata

  • Download URL: kiri_ocr-0.2.15.tar.gz
  • Upload date:
  • Size: 84.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for kiri_ocr-0.2.15.tar.gz
Algorithm Hash digest
SHA256 feb4ef5b65cd862551abc44da760d4ad07b96f595b6353920c65b6485dc08aab
MD5 34c51df324cfbfa86a64442d48c49e75
BLAKE2b-256 03736c0de25d338ec3748b78cece30ca8d121fbc82197a38a27aa3953502d1e6

See more details on using hashes here.

File details

Details for the file kiri_ocr-0.2.15-py3-none-any.whl.

File metadata

  • Download URL: kiri_ocr-0.2.15-py3-none-any.whl
  • Upload date:
  • Size: 89.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for kiri_ocr-0.2.15-py3-none-any.whl
Algorithm Hash digest
SHA256 cd15330d2cebf787f43bb1df6802fcb6f011c5f03a289089b7bc079bb1826ac1
MD5 90a22adb8f5d59234779c409e1fd6a37
BLAKE2b-256 2d0bcde4028cb9a3bfb37d2fc8a04177990330e13dfc9055e490cca8fa90ac1c

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2.15 This release

2 files

0.2.14

2 files

0.2.13

2 files

0.2.12

2 files

0.2.11

2 files

0.2.10

2 files

0.2.9

2 files

0.2.8

2 files

0.2.7

2 files

0.2.6

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page