Update README.md
Browse files
README.md
CHANGED
|
@@ -4,27 +4,68 @@ language:
|
|
| 4 |
- km
|
| 5 |
tags:
|
| 6 |
- ocr
|
|
|
|
| 7 |
- pytorch
|
|
|
|
| 8 |
- handwritten
|
|
|
|
|
|
|
| 9 |
license: apache-2.0
|
| 10 |
datasets:
|
| 11 |
- mrrtmob/km_en_image_line
|
| 12 |
-
- mrrtmob/khmer_english_ocr_image_line
|
|
|
|
|
|
|
| 13 |
---
|
| 14 |
|
| 15 |
# Kiri OCR Model
|
| 16 |
|
| 17 |
-
**Kiri OCR** is a lightweight
|
| 18 |
|
| 19 |
## β¨ Key Features
|
| 20 |
|
| 21 |
-
- **Lightweight**: Compact model optimized for speed and efficiency
|
| 22 |
-
- **
|
| 23 |
-
- **Document Processing**: Automatic text line and word detection
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
## π Dataset
|
| 26 |
|
| 27 |
-
The model is trained on the [mrrtmob/khmer_english_ocr_image_line](https://huggingface.co/datasets/mrrtmob/khmer_english_ocr_image_line) dataset,
|
| 28 |
|
| 29 |
## π» Usage
|
| 30 |
|
|
@@ -39,29 +80,76 @@ pip install kiri-ocr
|
|
| 39 |
```python
|
| 40 |
from kiri_ocr import OCR
|
| 41 |
|
| 42 |
-
# Initialize (
|
| 43 |
ocr = OCR()
|
| 44 |
|
| 45 |
-
# Extract text
|
| 46 |
-
text, results = ocr.extract_text(
|
| 47 |
print(text)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
```
|
| 49 |
|
| 50 |
### CLI Tool
|
| 51 |
|
| 52 |
```bash
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
kiri-ocr predict path/to/document.jpg --output results/
|
| 54 |
```
|
| 55 |
|
| 56 |
-
## Model Details
|
| 57 |
-
- **Architecture**: CRNN (CNN + LSTM + CTC)
|
| 58 |
-
- **Framework**: PyTorch
|
| 59 |
-
- **Input Size**: Height 32px (width variable)
|
| 60 |
-
|
| 61 |
## π Benchmarks
|
| 62 |
|
| 63 |
Results on synthetic test images (10 popular fonts):
|
| 64 |
|
| 65 |
-
 dataset, containing **12 million** synthetic images of Khmer and English text lines.
|
| 69 |
|
| 70 |
## π» Usage
|
| 71 |
|
|
|
|
| 80 |
```python
|
| 81 |
from kiri_ocr import OCR
|
| 82 |
|
| 83 |
+
# Initialize (downloads from Hugging Face automatically)
|
| 84 |
ocr = OCR()
|
| 85 |
|
| 86 |
+
# Extract text from document
|
| 87 |
+
text, results = ocr.extract_text("document.jpg")
|
| 88 |
print(text)
|
| 89 |
+
|
| 90 |
+
# Access detailed results
|
| 91 |
+
for result in results:
|
| 92 |
+
print(f"Text: {result.text}")
|
| 93 |
+
print(f"Confidence: {result.confidence:.2%}")
|
| 94 |
```
|
| 95 |
|
| 96 |
### CLI Tool
|
| 97 |
|
| 98 |
```bash
|
| 99 |
+
# Basic usage
|
| 100 |
+
kiri-ocr predict path/to/document.jpg
|
| 101 |
+
|
| 102 |
+
# With output directory
|
| 103 |
kiri-ocr predict path/to/document.jpg --output results/
|
| 104 |
```
|
| 105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
## π Benchmarks
|
| 107 |
|
| 108 |
Results on synthetic test images (10 popular fonts):
|
| 109 |
|
| 110 |
+

|
| 111 |
+
|
| 112 |
+

|
| 113 |
+
|
| 114 |
+
## βοΈ Configuration
|
| 115 |
+
|
| 116 |
+
Default inference parameters:
|
| 117 |
+
|
| 118 |
+
| Parameter | Value | Description |
|
| 119 |
+
|-----------|-------|-------------|
|
| 120 |
+
| `beam_width` | 4 | Beam search width |
|
| 121 |
+
| `ctc_fusion_alpha` | 0.5 | CTC score fusion weight |
|
| 122 |
+
| `lm_fusion_alpha` | 0.35 | Language model fusion weight |
|
| 123 |
+
| `max_length` | 260 | Maximum output sequence length |
|
| 124 |
+
|
| 125 |
+
## π Model Files
|
| 126 |
+
|
| 127 |
+
```
|
| 128 |
+
kiri-ocr/
|
| 129 |
+
βββ config.json # Model configuration
|
| 130 |
+
βββ vocab.json # Character vocabulary
|
| 131 |
+
βββ model.safetensors # Model weights
|
| 132 |
+
βββ README.md # This file
|
| 133 |
+
```
|
| 134 |
+
|
| 135 |
+
## π Links
|
| 136 |
+
|
| 137 |
+
- **GitHub**: [github.com/mrrtmob/kiri-ocr](https://github.com/mrrtmob/kiri-ocr)
|
| 138 |
+
- **Dataset**: [mrrtmob/khmer_english_ocr_image_line](https://huggingface.co/datasets/mrrtmob/khmer_english_ocr_image_line)
|
| 139 |
+
- **PyPI**: [pypi.org/project/kiri-ocr](https://pypi.org/project/kiri-ocr)
|
| 140 |
+
|
| 141 |
+
## π Citation
|
| 142 |
+
|
| 143 |
+
```bibtex
|
| 144 |
+
@software{kiri_ocr,
|
| 145 |
+
author = {mrrtmob},
|
| 146 |
+
title = {Kiri OCR: Lightweight OCR for English and Khmer},
|
| 147 |
+
year = {2026},
|
| 148 |
+
url = {https://huggingface.co/mrrtmob/kiri-ocr}
|
| 149 |
+
}
|
| 150 |
+
```
|
| 151 |
+
|
| 152 |
+
## π License
|
| 153 |
|
| 154 |
+
This model is released under the [Apache 2.0 License](LICENSE).
|
| 155 |
+
| Formatting | Inconsistent | Consistent tables and code blocks |
|