This repository contains a custom-trained Tesseract OCR model for recognizing printed Sinhala text.
The main trained model file is:
sin_custom_v3.traineddata
This model was trained and evaluated as part of a Sinhala OCR research component for extracting Sinhala text from educational documents.
.
├── sin_custom_v3.traineddata # Custom trained Tesseract Sinhala OCR model
├── run-wer-cer.ipynb # Notebook used to evaluate WER and CER
└── README.md # Project documentation
sin_custom_v3.traineddata is a custom Tesseract LSTM OCR model trained for printed Sinhala text recognition.
The model was trained by the researcher using a Sinhala OCR training dataset containing both printed and handwritten Sinhala samples. For this Tesseract model, the evaluation was focused only on the printed Sinhala samples.
The dataset used for training and evaluation was:
Sinhala OCR Training Data
Kaggle Dataset:
https://www.kaggle.com/datasets/hasindukoshitha/sinhala-ocr-training-data
Dataset summary:
| Dataset Detail | Value |
|---|---|
| Printed samples | 2,840 |
| Successfully processed printed samples | 2,829 |
The custom Tesseract model was trained using the Tesseract LSTM training pipeline. During training, the model showed a significant reduction in internal training error rates.
| Metric | Value |
|---|---|
| Model name | sin_custom_v3 |
| OCR engine | Tesseract LSTM |
| Output classes | 117 |
| Total model weights | 940,693 |
| Initial BCER | 22.239% |
| Initial BWER | 50.684% |
| Best BCER | 4.167% |
| BWER at best checkpoint | 14.322% |
The best model checkpoint was selected based on the minimum training Best Character Error Rate (BCER).
The model was evaluated using the notebook:
run-wer-cer.ipynb
The notebook loads the trained Tesseract model, runs OCR on printed Sinhala image samples, and compares the OCR output with the ground-truth text from metadata.csv.
Evaluation was performed using:
- WER - Word Error Rate
- CER - Character Error Rate
Final printed OCR evaluation results:
| Metric | Value |
|---|---|
| Average WER | 0.1574 |
| Average WER percentage | 15.74% |
| Average CER | 0.0346 |
| Average CER percentage | 3.46% |
The trained Tesseract model achieved a Character Error Rate of 3.46% and a Word Error Rate of 15.74% on printed Sinhala text samples.
The low CER indicates that the model performs well at recognizing individual Sinhala characters. However, the WER is higher because a word is counted as incorrect even when only one character inside the word is wrongly recognized.
This is especially important in Sinhala OCR because small character, vowel sign, or diacritic errors can change the full word.
Copy sin_custom_v3.traineddata into your Tesseract tessdata directory.
Example on Windows:
C:\Program Files\Tesseract-OCR\tessdata
Example on Linux:
/usr/share/tesseract-ocr/4.00/tessdata/or:
/usr/share/tesseract-ocr/5/tessdata/tesseract input_image.png output -l sin_custom_v3 --oem 3 --psm 6This will generate:
output.txt
import pytesseract
from PIL import Image
image = Image.open("sample_image.png")
text = pytesseract.image_to_string(
image,
lang="sin_custom_v3",
config="--oem 3 --psm 6"
)
print(text)The run-wer-cer.ipynb notebook performs the following steps:
- Loads the dataset metadata.
- Filters printed Sinhala samples.
- Runs OCR using
sin_custom_v3. - Compares predicted text with ground-truth text.
- Calculates WER and CER using the
jiwerlibrary. - Reports average WER and CER.
Install the required Python libraries:
pip install pytesseract pillow pandas jiwer matplotlibTesseract OCR must also be installed on the system.
This model is mainly designed for printed Sinhala OCR.
Current limitations include:
- Not optimized for handwritten Sinhala text.
- May struggle with noisy, blurred, skewed, or low-resolution images.
- May produce errors for unsupported symbols, mixed English-Sinhala text, and punctuation.
- Word-level accuracy is lower than character-level accuracy.
- Further improvement is needed for full-page OCR with complex layouts.
Future improvements may include:
- Expanding the Sinhala character set.
- Cleaning unsupported symbols from training text.
- Adding more printed Sinhala font variations.
- Improving preprocessing for noisy document images.
- Evaluating with a separate unseen test dataset.
- Combining Tesseract printed OCR with a separate handwritten OCR model.
This model was developed for Sinhala OCR research and educational document processing. It can be used in Sinhala document digitization pipelines, educational assistant systems, and OCR-based search or question-answering systems.
Model name: sin_custom_v3
File: sin_custom_v3.traineddata
OCR engine: Tesseract LSTM
Task: Printed Sinhala OCR
Evaluation CER: 3.46%
Evaluation WER: 15.74%
If this model or dataset is used in academic work, please cite the dataset and mention that the custom Tesseract OCR model was trained for printed Sinhala text recognition.
Dataset:
H. Koshitha, "Sinhala OCR Training Data," Kaggle Dataset.
Available: https://www.kaggle.com/datasets/hasindukoshitha/sinhala-ocr-training-data