maxall4 commited on
Commit
0c6158e
·
verified ·
1 Parent(s): a847a76

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +19 -1
README.md CHANGED
@@ -10,4 +10,22 @@ It was finetuned on the [biochemistry-ocr dataset](https://huggingface.co/datase
10
 
11
  ## Usage
12
 
13
- This model can be used just lile TrOCR just change the model name to `maxall4/TrOCR-biochemistry`. You can find the TrOCR docs [here](https://huggingface.co/docs/transformers/en/model_doc/trocr).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
  ## Usage
12
 
13
+ This model can be used just lile TrOCR just change the model name to `maxall4/TrOCR-biochemistry`. You can find the TrOCR docs [here](https://huggingface.co/docs/transformers/en/model_doc/trocr).
14
+
15
+ Example:
16
+ ```python
17
+ from transformers import TrOCRProcessor, VisionEncoderDecoderModel
18
+ import requests
19
+ from PIL import Image
20
+
21
+ processor = TrOCRProcessor.from_pretrained("microsoft/trocr-base-handwritten")
22
+ model = VisionEncoderDecoderModel.from_pretrained("maxall4/TrOCR-biochemistry")
23
+
24
+ image = Image.open('kikcat.png').convert("RGB")
25
+
26
+ pixel_values = processor(image, return_tensors="pt").pixel_values
27
+ generated_ids = model.generate(pixel_values)
28
+
29
+ generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
30
+ print(generated_text)
31
+ ```