Ransaka commited on
Commit
b4b20d3
·
verified ·
1 Parent(s): 2666b8e

Upload 6 files

Browse files
README.md ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: Ransaka/sinhala-ocr-model
3
+ model-index:
4
+ - name: sinhala-ocr-model-v2
5
+ results: []
6
+ pipeline_tag: image-to-text
7
+ language:
8
+ - si
9
+ ---
10
+
11
+ <!-- This model card has been generated automatically according to the information the Trainer had access to. You
12
+ should probably proofread and complete it, then remove this comment. -->
13
+
14
+ # TrOCR-Sinhala
15
+
16
+ See training metrics tab for performance details.
17
+
18
+ ## Model description
19
+
20
+ This model is finetuned version of Microsoft [TrOCR Printed](https://huggingface.co/microsoft/trocr-base-printed)
21
+
22
+ ## Intended uses & limitations
23
+
24
+ More information needed
25
+
26
+ ## Training and evaluation data
27
+
28
+ More information needed
29
+
30
+ ## Example
31
+ ```python
32
+ from PIL import Image
33
+ import requests
34
+ from io import BytesIO
35
+
36
+ from transformers import TrOCRProcessor, VisionEncoderDecoderModel, AutoTokenizer
37
+
38
+ image_url = "https://datasets-server.huggingface.co/assets/Ransaka/sinhala_synthetic_ocr/--/bf7c8a455b564cd73fe035031e19a5f39babb73b/--/default/train/0/image/image.jpg"
39
+ response = requests.get(image_url)
40
+ img = Image.open(BytesIO(response.content))
41
+
42
+ processor = TrOCRProcessor.from_pretrained('Ransaka/TrOCR-Sinhala')
43
+ model = VisionEncoderDecoderModel.from_pretrained('Ransaka/TrOCR-Sinhala')
44
+ model.to("cuda:0")
45
+
46
+ pixel_values = processor(img, return_tensors="pt").pixel_values.to('cuda:0')
47
+ generated_ids = model.generate(pixel_values,num_beams=2,early_stopping=True)
48
+ generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
49
+ generated_text #දිවයිනට බලයට ඇති ආපදා තත්ත්වය හමුවේ සබරගමුව පළාතේ
50
+ ```
51
+
52
+ ### Framework versions
53
+
54
+ - Transformers 4.35.2
55
+ - Pytorch 2.0.0
56
+ - Datasets 2.16.0
57
+ - Tokenizers 0.15.0
generation_config.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "pad_token_id": 0,
4
+ "transformers_version": "4.33.3"
5
+ }
special_tokens_map.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": "[CLS]",
3
+ "mask_token": "[MASK]",
4
+ "pad_token": "[PAD]",
5
+ "sep_token": "[SEP]",
6
+ "unk_token": "[UNK]"
7
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "clean_up_tokenization_spaces": true,
3
+ "cls_token": "[CLS]",
4
+ "do_lower_case": false,
5
+ "mask_token": "[MASK]",
6
+ "model_max_length": 512,
7
+ "pad_token": "[PAD]",
8
+ "sep_token": "[SEP]",
9
+ "strip_accents": null,
10
+ "tokenize_chinese_chars": true,
11
+ "tokenizer_class": "BertTokenizer",
12
+ "unk_token": "[UNK]"
13
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff