| --- |
| license: apache-2.0 |
| language: |
| - fa |
| pipeline_tag: image-to-text |
| library_name: paddleocr |
| tags: |
| - ocr |
| - persian |
| - handwriting |
| - printed-text |
| - paddleocr |
| - pp-ocrv6 |
| - ctc |
| datasets: |
| - Reza2kn/persian-handwriting-pages-3.69m |
| - Reza2kn/persian-printed-ocr-3.5m |
| --- |
| |
| # Bina 0.2 Rizeh |
|
|
| Bina 0.2 Rizeh is the **Medium** member of the Bina 0.2 Persian OCR family. It uses the `PP-OCRv6_medium_rec` CTC recognition architecture and contains **35,578,883 parameters (35.579M)**. The model targets Persian handwriting and printed text; preserving unrelated-language quality was not a training goal. |
|
|
| This is a complete recognizer release, not a loose checkpoint: exported inference graph and weights, preprocessing/postprocessing configuration with the embedded Persian character dictionary, best training checkpoint, benchmark provenance, portable logical-order inference wrappers, and an offline full-page detector are included. |
|
|
| ## Quick run |
|
|
| ```bash |
| git lfs install |
| git clone https://huggingface.co/Reza2kn/Bina-0.2-Rizeh |
| cd Bina-0.2-Rizeh |
| python -m pip install "paddlepaddle>=3.2,<4" "paddleocr>=3.3,<4" |
| python bina_page_ocr.py page.jpg --device cpu --output result.json |
| ``` |
|
|
| For a pre-cropped text line: |
|
|
| ```bash |
| python bina_text_recognition.py line.jpg --device cpu |
| ``` |
|
|
| See [`QUICKSTART.md`](./QUICKSTART.md) for CPU, NVIDIA, Python, image, and PDF examples in English and Persian. |
|
|
| ## What is self-contained? |
|
|
| - `inference/` is the exported Bina text recognizer. |
| - `detector/` is the pinned official `PaddlePaddle/PP-OCRv6_medium_det` release used for portable full-page OCR. |
| - `bina_text_recognition.py` performs logical-order Persian line recognition. |
| - `bina_page_ocr.py` detects, recognizes, orders, and emits full-page JSON without downloading model weights. |
| - `checkpoint/`, `benchmark/`, `MODEL_PROVENANCE.json`, and `SHA256SUMS` make the release auditable and reusable for continued fine-tuning. |
|
|
| The frozen benchmark used a more specialized `adaptive75` two-layer form/template pipeline. The portable full-page CLI is designed for general pages and is not claimed to reproduce that specialized layout isolation exactly. |
|
|
| ## Persian OCR Triple Threat |
|
|
| All models were evaluated on the same frozen 6,669 printed + 6,669 handwriting rows, with zero missing predictions. Lower is better. Triple Threat is `0.2 × WER + 0.2 × CER + 0.6 × S³`; overall is the equal split macro-average. |
|
|
| | Split | Rows | WER | CER | S³ | Essential error | Triple Threat | |
| |---|---:|---:|---:|---:|---:|---:| |
| | Handwriting | 6,669 | 19.0833 | 13.6399 | 13.7015 | 14.7567 | 14.7656 | |
| | Printed | 6,669 | 8.9257 | 2.3535 | 9.8512 | 12.0774 | 8.1666 | |
| | Equal-split overall | 13,338 | 14.0045 | 7.9967 | 11.7764 | 13.4171 | **11.4661** | |
|
|
| Leaderboard: [Persian OCR Triple Threat](https://huggingface.co/spaces/Reza2kn/PersianOCR-TripleThreat) |
|
|
| ## Training and provenance |
|
|
| - Architecture: `PP-OCRv6_medium_rec`. |
| - Public parameter count: `35,578,883`. |
| - Stage-8 recognition mix: 2,198,483 rows drawn from Persian handwriting, printed OCR, and native/form replay. |
| - Best held-out normalized edit similarity: handwriting `0.9671727`, printed `0.9071054`. |
| - Eval-linked checkpoint selection was active. The schedule ended while the selected checkpoint was still improving; no divergence stop fired. |
| - Medium training used hard-label CTC and serves as the distillation teacher for the smaller siblings. |
| - Frozen benchmark revision: `fefe25215114da8ac0ea21ff5e8f97204b2762d5`. |
| - Frozen detection SHA-256: `836044bd3d6dc4c2a66cb8a301e5bf86e48e305a7463ec92eec98f656f46e132`. |
| - Internal source release: `stage8-gate42-20260726`. |
|
|
| ## Input and output contract |
|
|
| The recognizer works best on horizontal, content-tight line crops. Its exported `inference.yml` is authoritative for resize/padding and the 161-symbol dictionary. The wrappers convert PaddleOCR visual-order Arabic output to logical Persian order while preserving Latin/numeric runs. |
|
|
| The full-page CLI emits JSON with assembled text plus every recognized line, box, confidence score, and raw visual-order output. For complex forms, grids, multi-column layouts, or exact benchmark reproduction, use the preserved specialized pipeline and layout stages rather than assuming generic detection has perfect reading order. |
|
|
| ## Limitations |
|
|
| - Persian-focused; other languages were not preserved or benchmarked. |
| - Handwriting remains harder than printed text, especially for the smaller siblings. |
| - Generic page detection may need layout-specific reading-order logic for forms and multi-column documents. |
| - Confidence scores are model scores, not calibrated probabilities. |
| - The benchmark measures the bundled family pipeline and should not be interpreted as universal document accuracy. |
|
|
| ## فارسی |
|
|
| Bina 0.2 Rizeh عضو **متوسط** خانواده OCR فارسی Bina 0.2 است و 35.579 میلیون پارامتر دارد. این مخزن فقط یک checkpoint نیست: مدل inference، تنظیمات و واژهنامه کاراکتری، checkpoint آموزش، آشکارساز صفحه، اسکریپت خط و صفحه کامل، نتایج دقیق benchmark و checksumها همگی داخل مخزن هستند. |
|
|
| اجرای سریع CPU: |
|
|
| ```bash |
| python -m pip install "paddlepaddle>=3.2,<4" "paddleocr>=3.3,<4" |
| python bina_page_ocr.py page.jpg --device cpu --output result.json |
| ``` |
|
|
| برای GPU نسخه PaddlePaddle سازگار با CUDA را نصب کنید و `--device gpu:0` بدهید. برای یک خط بریدهشده از `bina_text_recognition.py` استفاده کنید. خروجی فارسی به ترتیب منطقی خواندن برگردانده میشود. جزئیات بیشتر در [`QUICKSTART.md`](./QUICKSTART.md) آمده است. |
|
|
| ## License |
|
|
| Apache-2.0. The bundled detector is the official Apache-2.0 `PaddlePaddle/PP-OCRv6_medium_det` artifact pinned in `detector/SOURCE.json`. |
|
|