CoolFace
Modelpublic

eshangj/TrOCR-Sinhala-finetuned

sourceHugging Faceupdated 1y agoView on Hugging Face
3likes112downloads
Model Card

Model Card for eshangj/TrOCR-Sinhala-finetuned

This model is a fine-tuned version of Microsoft's TrOCR model for Sinhala handwritten and printed text recognition. It can extract Sinhala text from scanned documents, printed text, and handwriting with high accuracy.


🧠 Model Details

Model Description

This is a Sinhala Optical Character Recognition (OCR) model based on the TrOCR architecture. It has been fine-tuned by Eshan Gayanga on a custom Sinhala dataset containing printed and handwritten text samples. The model builds on top of Ransaka Ravihara’s pretrained checkpoint, which was adapted and extended for improved Sinhala text recognition.

  • β€”Developed by: Eshan Gayanga
  • β€”Acknowledgments: Credit to Ransaka Ravihara for providing the original TrOCR Sinhala checkpoint used for fine-tuning.
  • β€”Model type: VisionEncoderDecoderModel (TrOCR)
  • β€”Language: Sinhala (si)
  • β€”License: MIT
  • β€”Finetuned from: RansakaRavihara/TrOCR-Sinhala-base

πŸ“‚ Model Sources


πŸš€ Uses

Direct Use

This model can be directly used for text recognition (OCR) in Sinhala language images. It performs well on:

  • β€”Scanned documents
  • β€”Printed Sinhala text
  • β€”Handwritten Sinhala notes

Example Use Case

  • β€”Digitizing old Sinhala printed or handwritten archives
  • β€”Building document understanding systems for Sinhala-language text
  • β€”Automatic marking and grading of Sinhala handwritten scripts

Downstream Use

This model can be further fine-tuned for:

  • β€”Scene-text recognition in Sinhala
  • β€”Multi-language OCR (Sinhala + English)
  • β€”Document layout extraction pipelines

Out-of-Scope Use

  • β€”Recognition of non-Sinhala scripts (Tamil, English, etc.)
  • β€”Highly degraded or extremely noisy handwritten documents

⚠️ Bias, Risks, and Limitations

  • β€”Model accuracy may drop for low-quality, blurred, or tilted images.
  • β€”Some handwritten characters may be misread, especially with non-standard handwriting.
  • β€”The model is not designed for recognizing mixed-language text.

Recommendations

Users should:

  • β€”Preprocess input images (resize, denoise, binarize if needed).
  • β€”Avoid using the model for sensitive personal documents.
  • β€”Use post-processing (e.g., spell correction) to refine results.

πŸ’» How to Get Started with the Model

python
from PIL import Image
from transformers import TrOCRProcessor, VisionEncoderDecoderModel

# Load model and processor
processor = TrOCRProcessor.from_pretrained("eshangj/TrOCR-Sinhala-finetuned")
model = VisionEncoderDecoderModel.from_pretrained("eshangj/TrOCR-Sinhala-finetuned").to("cuda")

# Load image
img = Image.open("<path-to-your-image>")

# OCR Inference
pixel_values = processor(images=img, return_tensors="pt").pixel_values.to("cuda")
generated_ids = model.generate(pixel_values, num_beams=3, early_stopping=True)
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
print(generated_text)