v2 word-level — mAP50=0.9949
Browse files- .gitattributes +1 -0
- README.md +24 -45
- bengali_det.onnx +2 -2
- bengali_det.pt +2 -2
- dataset.yaml +1 -1
- detection_results.png +2 -2
- word_level_preview.png +3 -0
.gitattributes
CHANGED
|
@@ -35,3 +35,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
detection_results.png filter=lfs diff=lfs merge=lfs -text
|
| 37 |
sample_pages.png filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
detection_results.png filter=lfs diff=lfs merge=lfs -text
|
| 37 |
sample_pages.png filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
word_level_preview.png filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
|
@@ -6,64 +6,43 @@ tags:
|
|
| 6 |
- ocr
|
| 7 |
- bengali
|
| 8 |
- yolov8
|
| 9 |
-
-
|
| 10 |
metrics:
|
| 11 |
- map
|
| 12 |
---
|
| 13 |
|
| 14 |
-
# Bengali OCR — Text Detection
|
| 15 |
|
| 16 |
-
**
|
| 17 |
-
**
|
| 18 |
-
**
|
| 19 |
-
**Companion recognition model:** `Sarjinkhan2003/bengali-ocr-recognition`
|
| 20 |
|
| 21 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
|
|
|
| 23 |
| Metric | Value |
|
| 24 |
|---|---|
|
| 25 |
-
| mAP@0.5 | 0.
|
| 26 |
-
|
|
| 27 |
-
|
|
| 28 |
-
| Recall | 0.8519 |
|
| 29 |
-
|
| 30 |
-
## Quick start — full pipeline
|
| 31 |
-
|
| 32 |
-
```python
|
| 33 |
-
# pip install ultralytics huggingface_hub torch torchvision Pillow
|
| 34 |
-
from pipeline import BengaliDocOCR
|
| 35 |
-
|
| 36 |
-
# Load both detection + recognition from HuggingFace
|
| 37 |
-
ocr = BengaliDocOCR.from_hub(device="cuda") # or "cpu"
|
| 38 |
-
|
| 39 |
-
# Run on a document
|
| 40 |
-
result = ocr.read_document("bengali_doc.jpg")
|
| 41 |
-
print(result["text"]) # full text
|
| 42 |
-
for item in result["items"]: # word-level
|
| 43 |
-
print(item["bbox"], item["text"])
|
| 44 |
-
```
|
| 45 |
|
| 46 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
|
|
|
| 48 |
```python
|
| 49 |
from ultralytics import YOLO
|
| 50 |
from huggingface_hub import hf_hub_download
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
results = model.predict("doc.jpg", conf=0.25)
|
| 55 |
for box in results[0].boxes:
|
| 56 |
-
print(box.xyxy[0].tolist()
|
| 57 |
```
|
| 58 |
-
|
| 59 |
-
## Files
|
| 60 |
-
| File | Description |
|
| 61 |
-
|---|---|
|
| 62 |
-
| `bengali_det.pt` | YOLOv8 weights (PyTorch) |
|
| 63 |
-
| `bengali_det.onnx` | ONNX export (CPU-friendly) |
|
| 64 |
-
| `pipeline.py` | Combined detection + recognition pipeline |
|
| 65 |
-
| `dataset.yaml` | Dataset config used for training |
|
| 66 |
-
|
| 67 |
-
## Training data
|
| 68 |
-
- BN-HTRd: real annotated Bengali handwritten document pages
|
| 69 |
-
- 3,000 synthetic pages (auto-generated with Pillow)
|
|
|
|
| 6 |
- ocr
|
| 7 |
- bengali
|
| 8 |
- yolov8
|
| 9 |
+
- word-detection
|
| 10 |
metrics:
|
| 11 |
- map
|
| 12 |
---
|
| 13 |
|
| 14 |
+
# Bengali OCR — Word-Level Text Detection (v2)
|
| 15 |
|
| 16 |
+
**Architecture:** YOLOv8n
|
| 17 |
+
**Task:** Detect individual word bounding boxes
|
| 18 |
+
**Companion:** `Sarjinkhan2003/bengali-ocr-recognition`
|
|
|
|
| 19 |
|
| 20 |
+
## v2 vs v1
|
| 21 |
+
| Version | Box level | OCR result |
|
| 22 |
+
|---|---|---|
|
| 23 |
+
| v1 | Paragraph | Garbled text |
|
| 24 |
+
| **v2** | **Word** | **Clean text** |
|
| 25 |
|
| 26 |
+
## Results
|
| 27 |
| Metric | Value |
|
| 28 |
|---|---|
|
| 29 |
+
| mAP@0.5 | 0.9949 |
|
| 30 |
+
| Precision | 0.9961 |
|
| 31 |
+
| Recall | 0.9945 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
+
## Training data
|
| 34 |
+
| Source | Type | Pages |
|
| 35 |
+
|---|---|---|
|
| 36 |
+
| Synthetic printed | Printed NID/form/newspaper | 8,000 |
|
| 37 |
+
| BN-HTRd | Handwritten (capped) | 0 |
|
| 38 |
|
| 39 |
+
## Usage
|
| 40 |
```python
|
| 41 |
from ultralytics import YOLO
|
| 42 |
from huggingface_hub import hf_hub_download
|
| 43 |
+
path = hf_hub_download("Sarjinkhan2003/bengali-ocr-detection", "bengali_det.pt")
|
| 44 |
+
model = YOLO(path)
|
| 45 |
+
results = model.predict("nid.jpg", conf=0.25)
|
|
|
|
| 46 |
for box in results[0].boxes:
|
| 47 |
+
print(box.xyxy[0].tolist()) # one word per box
|
| 48 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bengali_det.onnx
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c5bdcbe92a7132a805068fae7d4ccf7473eb483e8af1411cec582aaa8fb6f80d
|
| 3 |
+
size 12256378
|
bengali_det.pt
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8e8ed6f24fe1c465c06a6eb5897b7eb68d5c164964366f460f1e98fd26adf3c6
|
| 3 |
+
size 24475747
|
dataset.yaml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
names:
|
| 2 |
- word
|
| 3 |
nc: 1
|
| 4 |
-
path: /content/
|
| 5 |
train: images/train
|
| 6 |
val: images/val
|
|
|
|
| 1 |
names:
|
| 2 |
- word
|
| 3 |
nc: 1
|
| 4 |
+
path: /content/word_det_data
|
| 5 |
train: images/train
|
| 6 |
val: images/val
|
detection_results.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
word_level_preview.png
ADDED
|
Git LFS Details
|