Downloads · 30 days
0
LasinduVIduranga/sinhala-character-recognition-ml
sinhala-character-recognition-ml is a machine learning model from LasinduVIduranga. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
--- language: si license: openmdw libraryname: scikit-learn tags: - sinhala - character-recognition - knn - ocr - sinhala-nlp datasets: - sathiralamal/sinhala-letter-454 metrics: - accuracy pipelinetag: image-classifi…
Downloads · 30 days
0
Access
Public
Updated Jun 18, 2026
Repo size
1 GB
Likes
0
Public
Click a slice to open those files.
.npy558 MB · 56%
From the Hugging Face model README
language: si license: openmdw library_name: scikit-learn tags:
A K-Nearest Neighbors (KNN) classifier trained to recognize 454 Sinhala characters, including base characters, vowel modifications, and combined forms. This model is designed for handwritten Sinhala character recognition.
| Property | Value |
|---|---|
| Model Type | K-Nearest Neighbors (KNN) |
| k Value | 3 (default) |
| Classes | 454 Sinhala characters |
| Input Shape | 80×80 pixels (grayscale) |
| Feature Vector | 6400 (flattened image) |
| Accuracy | ~60% |
| Framework | Scikit-learn |
| Serialization | Joblib (.sav) |
This model was trained on the Sinhala Letter and Modifications Dataset.
| Property | Value |
|---|---|
| Source | Kaggle - Sinhala Letter 454 |
| Author | Sathira L. Amal |
| Classes | 454 Sinhala characters |
| Image Size | 80×80 pixels (grayscale) |
| Total Images | ~45,000 |
@dataset{sathiralamal_sinhala_2020,
author = {Sathira L. Amal},
title = {Sinhala Letter and Modifications},
year = {2020},
publisher = {Kaggle},
url = {https://www.kaggle.com/datasets/sathiralamal/sinhala-letter-454}
}
pip install joblib numpy opencv-python Pillow scikit-learn
import joblib
import numpy as np
import cv2
# Load the model
model = joblib.load('sinahala-character-knn.sav')
# Load and preprocess your image
def preprocess_image(image_path):
img = cv2.imread(image_path, 0) # Grayscale
img = cv2.resize(img, (80, 80)) # Resize to 80x80
img = img.flatten() # Flatten to 6400 features
return img.reshape(1, -1)
# Make prediction
image_path = 'path/to/your/sinhala_character.jpg'
features = preprocess_image(image_path)
prediction = model.predict(features)
print(f'Predicted class: {prediction[0]}')
label_dict = {
1: 'අ', 2: 'ආ', 3: 'ඇ', 4: 'ඈ', 5: 'ඉ',
6: 'ඊ', 7: 'උ', 8: 'එ', 9: 'ඒ', 10: 'ඔ',
11: 'ඕ', 12: 'ක', 13: 'කා', 14: 'කැ', 15: 'කෑ',
16: 'කි', 17: 'කී', 18: 'කු', 19: 'කූ', 20: 'ක්',
# ... full 454 mapping
}
# Map prediction to character
char = label_dict.get(prediction[0], 'Unknown')
print(f'Predicted character: {char}')
sinahala-character-knn/
├── sinahala-character-knn.sav # Trained KNN model (436 MB)
├── README.md # Model card
└── LICENSE # License file
| Metric | Value |
|---|---|
| Training Accuracy | ~65% |
| Testing Accuracy | ~60% |
| Precision (macro avg) | ~0.60 |
| Recall (macro avg) | ~0.59 |
| F1-Score (macro avg) | ~0.59 |
This model is licensed under the OpenMDW License - see the LICENSE file for details.
Lasindu Viduranga - [email protected]
Model Link: https://huggingface.co/LasinduViduranga/sinhala-character-knn
GitHub Link: https://github.com/LasinduViduranga/sinhala-character-recognition-ml
If you find this model useful, please:
Made with ❤️ for the Sinhala language community