Update README.md
Browse files
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 |
+
```
|