TrOCR-Sinhala / README.md
Ransaka's picture
Update README.md
5f4fff1
metadata
base_model: Ransaka/sinhala-ocr-model
model-index:
  - name: sinhala-ocr-model-v2
    results: []
pipeline_tag: image-to-text
language:
  - si

TrOCR-Sinhala

See training metrics tab for performance details.

Model description

This model is finetuned version of Microsoft TrOCR Printed

Intended uses & limitations

More information needed

Training and evaluation data

More information needed

Example

from PIL import Image
import requests
from io import BytesIO

from transformers import TrOCRProcessor, VisionEncoderDecoderModel, AutoTokenizer

image_url = "https://datasets-server.huggingface.co/assets/Ransaka/sinhala_synthetic_ocr/--/bf7c8a455b564cd73fe035031e19a5f39babb73b/--/default/train/0/image/image.jpg"
response = requests.get(image_url)
img = Image.open(BytesIO(response.content))

processor = TrOCRProcessor.from_pretrained('Ransaka/TrOCR-Sinhala')
model = VisionEncoderDecoderModel.from_pretrained('Ransaka/TrOCR-Sinhala')
model.to("cuda:0")

pixel_values = processor(img, return_tensors="pt").pixel_values.to('cuda:0')  
generated_ids = model.generate(pixel_values,num_beams=2,early_stopping=True)
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
generated_text #දිවයිනට බලයට ඇති ආපදා තත්ත්වය හමුවේ සබරගමුව පළාතේ

Framework versions

  • Transformers 4.35.2
  • Pytorch 2.0.0
  • Datasets 2.16.0
  • Tokenizers 0.15.0