Ghazouaniwala commited on
Commit
b7829de
·
verified ·
1 Parent(s): 203be43

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +90 -0
README.md ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ language:
4
+ - ar
5
+ - aeb
6
+ pipeline_tag: image-to-text
7
+ base_model: microsoft/trocr-base-handwritten
8
+ tags:
9
+ - image-to-text
10
+ - ocr
11
+ - handwriting-recognition
12
+ - htr
13
+ - arabic
14
+ - tunisian
15
+ - trocr
16
+ - vision-encoder-decoder
17
+ - offline
18
+ ---
19
+
20
+ # trocr-tunisian-arabic — handwritten Tunisian Arabic recognition
21
+
22
+ A TrOCR vision-encoder/decoder fine-tuned for **handwritten Tunisian Arabic**, with a 30k-token Arabic-native vocabulary.
23
+
24
+ ## Why this exists
25
+
26
+ Cloud OCR services handle printed Arabic reasonably and handwritten dialectal Arabic poorly. For the use case this was built for, they were not an option at all: Tunisian legal documents contain privileged client data that cannot leave the premises under the country's data-protection regime. That ruled out every managed service and required a model that runs fully offline.
27
+
28
+ ## Intended use
29
+
30
+ Offline extraction of handwritten Arabic from structured forms.
31
+
32
+ Built for and deployed in [Wathiqa](https://github.com/GhwazouaniWala/Wathiqa), which turns handwritten Tunisian legal forms into structured, searchable client records without any cloud dependency.
33
+
34
+ **This is a word-level model.** In Wathiqa it sits behind a segmentation stage: the ink mask is dilated horizontally by a kernel scaled to text height — Arabic joins letters within a word but not between words, so inter-word gaps are the reliable separator — and the resulting components are read right to left. Feeding a full unsegmented line will not work well.
35
+
36
+ ## Usage
37
+
38
+ <!-- Paste the VisionEncoderDecoderModel loading and generation code you have
39
+ actually run, including the processor and any generation config used. -->
40
+
41
+ ## Where it sits in a real pipeline
42
+
43
+ Wathiqa routes each field type to a purpose-built engine rather than asking one model to cover everything:
44
+
45
+ | Field type | Engine |
46
+ |---|---|
47
+ | Arabic text, names, notes | **This model** |
48
+ | CIN, passport, number, phone, date | Dedicated digit recogniser with a constrained alphabet and shape validation |
49
+ | Printed captions | EasyOCR (Arabic + Latin) |
50
+ | Checkboxes | Fill-ratio detector |
51
+ | Signatures | Ink-presence detector |
52
+
53
+ That routing exists because these are genuinely different problems, and the limitations below are the reason.
54
+
55
+ ## Limitations
56
+
57
+ - **Trained on isolated words**, not lines or sentences. Word segmentation is the caller's responsibility.
58
+ - **Not for digits.** Numeric fields need a separate path — a word model asked for a digit string produces confident nonsense. Wathiqa isolates characters, constrains the alphabet to `0-9` and separators, then validates the assembled value against the field's expected shape.
59
+ - **Not for printed text.** Printed captions are a different problem and route elsewhere.
60
+ - **A blank crop returns confident nonsense rather than silence.** Empty-field detection must happen before the model is called; Wathiqa reports fields with no ink as empty and never sends them to a model.
61
+ - Trained on Tunisian handwriting. Performance on other regional Arabic hands is untested.
62
+
63
+ ## Training
64
+
65
+ Fine-tuned from [`microsoft/trocr-base-handwritten`](https://huggingface.co/microsoft/trocr-base-handwritten) on handwritten Tunisian Arabic, with the decoder vocabulary replaced by a 30k-token Arabic-native vocabulary.
66
+
67
+ <!-- Optional but worth adding: number of training samples, how the corpus was
68
+ collected and labelled, image preprocessing, and CER/WER on a held-out set. -->
69
+
70
+ ## Related work
71
+
72
+ | Model | Purpose |
73
+ |---|---|
74
+ | [`Ghazouaniwala/emotions_speech`](https://huggingface.co/Ghazouaniwala/emotions_speech) | Speaker-independent speech emotion recognition |
75
+ | [`Ghazouaniwala/silma-tts-derja`](https://huggingface.co/Ghazouaniwala/silma-tts-derja) | Tunisian Derja speech synthesis |
76
+
77
+ ## Citation
78
+
79
+ ```bibtex
80
+ @misc{ghazouani2025trocrtunisian,
81
+ author = {Ghazouani, Wala Eddine},
82
+ title = {trocr-tunisian-arabic: handwritten Tunisian Arabic recognition},
83
+ year = {2025},
84
+ url = {https://huggingface.co/Ghazouaniwala/trocr-tunisian-arabic}
85
+ }
86
+ ```
87
+
88
+ ---
89
+
90
+ Built by [Wala Eddine Ghazouani](https://www.walaghazouani.com) · [GitHub](https://github.com/GhwazouaniWala) · [LinkedIn](https://www.linkedin.com/in/ghazouani-wala-eddine)