FixFips commited on
Commit
0ffa2d5
·
verified ·
1 Parent(s): ffd4d19

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +80 -0
README.md ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - ar
4
+ license: mit
5
+ library_name: pytorch
6
+ pipeline_tag: image-to-text
7
+ tags:
8
+ - ocr
9
+ - handwritten-text-recognition
10
+ - arabic
11
+ - khatt
12
+ - crnn
13
+ - ctc
14
+ ---
15
+
16
+ # ArabicOCR-KHATT — Arabic Handwritten Text Recognition (CRNN-CTC)
17
+
18
+ Line-level Arabic handwritten text recognition, trained on the
19
+ [KHATT](https://khatt.ideas2serve.net/) dataset (11,375 handwritten line images).
20
+
21
+ The architecture is a CRNN (CNN + BiLSTM) with CTC loss, with **Arabic-specific
22
+ design choices**: input height 96 so diacritic dots stay detectable, 3-zone
23
+ vertical pooling that preserves *where* dots sit (the only difference between
24
+ ba/ta/tha/nun/ya), dot-safe augmentation, and beam-search decoding with an
25
+ Arabic character bigram LM.
26
+
27
+ - **Code / training pipeline:** https://github.com/FixFips/ArabicOCR_KHATT
28
+ - **Python package:** `pip install arabicocr-khatt`
29
+
30
+ ## Usage
31
+
32
+ ```python
33
+ from arabicocr_khatt import ArabicOCR
34
+
35
+ ocr = ArabicOCR.from_pretrained("FixFips/arabicocr-khatt")
36
+ text = ocr.recognize("handwritten_page.jpg") # segments lines automatically
37
+ print(text)
38
+ ```
39
+
40
+ Or from the command line:
41
+
42
+ ```bash
43
+ pip install arabicocr-khatt
44
+ arabicocr handwritten_page.jpg
45
+ ```
46
+
47
+ ## Validation metrics (KHATT, best epoch 116)
48
+
49
+ | Metric | Value |
50
+ |--------|-------|
51
+ | CER | 6.09% |
52
+ | WER | 27.26% |
53
+ | WER (normalized) | 26.06% |
54
+ | Dot-group CER | 8.24% |
55
+
56
+ Dot-group CER measures errors only on dot-differentiated letter groups
57
+ (ba/ta/tha, jim/ha/kha, nun/ya) — the #1 error source in Arabic OCR.
58
+
59
+ ## Files
60
+
61
+ | File | Purpose |
62
+ |------|---------|
63
+ | `crnn_best.pt` | Model checkpoint: `{"model": state_dict, "vocab": list[str], "arch_version": 2}` |
64
+ | `bigram_lm.json` | Arabic character bigram LM for beam-search decoding |
65
+ | `charset_arabic.txt` | 75-class character set (70 characters + 5 special tokens) |
66
+
67
+ ## Limitations
68
+
69
+ - Line-level model: full pages are segmented into lines with classical
70
+ morphology before recognition; complex layouts may segment poorly.
71
+ - Trained only on KHATT handwriting; printed text, historical manuscripts, and
72
+ heavily diacritized text are out of domain.
73
+ - No word-level language model — output is not spell-corrected.
74
+
75
+ ## Citation
76
+
77
+ If you use this model, please also cite the KHATT dataset:
78
+
79
+ > Mahmoud, S. A., et al. "KHATT: An open Arabic offline handwritten text database."
80
+ > Pattern Recognition 47.3 (2014): 1096-1112.