File size: 1,727 Bytes
5c4cee1 01547fb 5f4fff1 5c4cee1 ed30ec0 5c4cee1 ed30ec0 5c4cee1 ed30ec0 5c4cee1 ebbbe36 a0e8378 ebbbe36 5c4cee1 fdd4a2c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
---
base_model: Ransaka/sinhala-ocr-model
model-index:
- name: sinhala-ocr-model-v2
results: []
pipeline_tag: image-to-text
language:
- si
---
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
should probably proofread and complete it, then remove this comment. -->
# TrOCR-Sinhala
See training metrics tab for performance details.
## Model description
This model is finetuned version of Microsoft [TrOCR Printed](https://huggingface.co/microsoft/trocr-base-printed)
## Intended uses & limitations
More information needed
## Training and evaluation data
More information needed
## Example
```python
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 |