Update README.md
Browse files
README.md
CHANGED
|
@@ -19,13 +19,13 @@ tags:
|
|
| 19 |
|
| 20 |
# Thai Handwritten OCR (TrOCR)
|
| 21 |
|
| 22 |
-
|
| 23 |
|
| 24 |
## Model Details
|
| 25 |
|
| 26 |
### Model Description
|
| 27 |
|
| 28 |
-
|
| 29 |
|
| 30 |
- **Developed by:** Warit Sirikosityanggoon
|
| 31 |
- **Model type:** Vision Encoder-Decoder (TrOCR)
|
|
@@ -41,28 +41,28 @@ tags:
|
|
| 41 |
|
| 42 |
### Direct Use
|
| 43 |
|
| 44 |
-
|
| 45 |
-
-
|
| 46 |
-
-
|
| 47 |
-
-
|
| 48 |
|
| 49 |
### Out-of-Scope Use
|
| 50 |
|
| 51 |
-
-
|
| 52 |
-
-
|
| 53 |
|
| 54 |
## Training Details
|
| 55 |
|
| 56 |
### Training Data
|
| 57 |
|
| 58 |
-
|
| 59 |
|
| 60 |
### Tokenizer
|
| 61 |
|
| 62 |
-
|
| 63 |
-
-
|
| 64 |
-
-
|
| 65 |
-
-
|
| 66 |
|
| 67 |
**Tokenizer Configuration:**
|
| 68 |
- Vocab Size: 30,000
|
|
@@ -98,7 +98,7 @@ tags:
|
|
| 98 |
import editdistance
|
| 99 |
|
| 100 |
def calculate_cer(pred, label):
|
| 101 |
-
"""Character Error Rate (
|
| 102 |
if len(label) == 0:
|
| 103 |
return 1.0 if len(pred) > 0 else 0.0
|
| 104 |
distance = editdistance.eval(pred, label)
|
|
@@ -156,23 +156,28 @@ print(text)
|
|
| 156 |
|
| 157 |
```
|
| 158 |
Input Image
|
| 159 |
-
|
|
|
|
| 160 |
Vision Transformer (ViT) Encoder
|
| 161 |
-
|
|
|
|
| 162 |
Cross-Attention
|
| 163 |
-
|
|
|
|
| 164 |
Transformer Decoder
|
| 165 |
-
|
|
|
|
| 166 |
SentencePiece Tokenizer (Unigram)
|
| 167 |
-
|
|
|
|
| 168 |
Thai Text Output
|
| 169 |
```
|
| 170 |
|
| 171 |
## Limitations
|
| 172 |
|
| 173 |
-
-
|
| 174 |
-
-
|
| 175 |
-
-
|
| 176 |
|
| 177 |
## Citation
|
| 178 |
|
|
@@ -188,9 +193,9 @@ Thai Text Output
|
|
| 188 |
|
| 189 |
## Acknowledgements
|
| 190 |
|
| 191 |
-
- [Microsoft TrOCR](https://huggingface.co/microsoft/trocr-base-handwritten)
|
| 192 |
-
- [iApp Technology](https://huggingface.co/datasets/iapp/thai_handwriting_dataset)
|
| 193 |
-
- [SentencePiece](https://github.com/google/sentencepiece)
|
| 194 |
|
| 195 |
## Model Card Contact
|
| 196 |
|
|
|
|
| 19 |
|
| 20 |
# Thai Handwritten OCR (TrOCR)
|
| 21 |
|
| 22 |
+
A Thai Handwritten OCR model fine-tuned from Microsoft TrOCR for recognizing Thai handwritten text.
|
| 23 |
|
| 24 |
## Model Details
|
| 25 |
|
| 26 |
### Model Description
|
| 27 |
|
| 28 |
+
This model is developed to convert Thai handwritten images into text using the TrOCR architecture, which combines Vision Transformer (ViT) for image processing and Transformer Decoder for text generation.
|
| 29 |
|
| 30 |
- **Developed by:** Warit Sirikosityanggoon
|
| 31 |
- **Model type:** Vision Encoder-Decoder (TrOCR)
|
|
|
|
| 41 |
|
| 42 |
### Direct Use
|
| 43 |
|
| 44 |
+
This model can be used directly for converting Thai handwritten images into text. Suitable for:
|
| 45 |
+
- Converting Thai handwritten documents
|
| 46 |
+
- Real-time handwriting recognition systems
|
| 47 |
+
- Digitizing handwritten notes
|
| 48 |
|
| 49 |
### Out-of-Scope Use
|
| 50 |
|
| 51 |
+
- Not suitable for languages other than Thai
|
| 52 |
+
- May not perform well on extremely difficult handwriting or low-quality images
|
| 53 |
|
| 54 |
## Training Details
|
| 55 |
|
| 56 |
### Training Data
|
| 57 |
|
| 58 |
+
Trained on [iapp/thai_handwriting_dataset](https://huggingface.co/datasets/iapp/thai_handwriting_dataset), which contains Thai handwritten images paired with their corresponding text labels.
|
| 59 |
|
| 60 |
### Tokenizer
|
| 61 |
|
| 62 |
+
Uses **SentencePiece with Unigram algorithm** instead of Dictionary-based Word Segmentation because:
|
| 63 |
+
- Handles Out-of-Vocabulary words effectively
|
| 64 |
+
- Supports misspelled or incomplete words from handwriting
|
| 65 |
+
- No pre-tokenization required
|
| 66 |
|
| 67 |
**Tokenizer Configuration:**
|
| 68 |
- Vocab Size: 30,000
|
|
|
|
| 98 |
import editdistance
|
| 99 |
|
| 100 |
def calculate_cer(pred, label):
|
| 101 |
+
"""Character Error Rate (lower is better)"""
|
| 102 |
if len(label) == 0:
|
| 103 |
return 1.0 if len(pred) > 0 else 0.0
|
| 104 |
distance = editdistance.eval(pred, label)
|
|
|
|
| 156 |
|
| 157 |
```
|
| 158 |
Input Image
|
| 159 |
+
|
|
| 160 |
+
v
|
| 161 |
Vision Transformer (ViT) Encoder
|
| 162 |
+
|
|
| 163 |
+
v
|
| 164 |
Cross-Attention
|
| 165 |
+
|
|
| 166 |
+
v
|
| 167 |
Transformer Decoder
|
| 168 |
+
|
|
| 169 |
+
v
|
| 170 |
SentencePiece Tokenizer (Unigram)
|
| 171 |
+
|
|
| 172 |
+
v
|
| 173 |
Thai Text Output
|
| 174 |
```
|
| 175 |
|
| 176 |
## Limitations
|
| 177 |
|
| 178 |
+
- Performance depends on image quality and handwriting clarity
|
| 179 |
+
- May not perform well on handwriting styles significantly different from training data
|
| 180 |
+
- Supports Thai language only
|
| 181 |
|
| 182 |
## Citation
|
| 183 |
|
|
|
|
| 193 |
|
| 194 |
## Acknowledgements
|
| 195 |
|
| 196 |
+
- [Microsoft TrOCR](https://huggingface.co/microsoft/trocr-base-handwritten) for Pretrained Model
|
| 197 |
+
- [iApp Technology](https://huggingface.co/datasets/iapp/thai_handwriting_dataset) for Thai Handwriting Dataset
|
| 198 |
+
- [SentencePiece](https://github.com/google/sentencepiece) for Tokenizer
|
| 199 |
|
| 200 |
## Model Card Contact
|
| 201 |
|