Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1 |
-
---
|
2 |
-
license: mit
|
3 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: mit
|
3 |
+
---
|
4 |
+
from transformers import TrOCRProcessor, VisionEncoderDecoderModel
|
5 |
+
from PIL import Image
|
6 |
+
import requests
|
7 |
+
|
8 |
+
# load image from the IAM database
|
9 |
+
url = 'https://fki.tic.heia-fr.ch/static/img/a01-122-02-00.jpg'
|
10 |
+
image = Image.open(requests.get(url, stream=True).raw).convert("RGB")
|
11 |
+
|
12 |
+
processor = TrOCRProcessor.from_pretrained('kun826/trocr_handwrite_option4')
|
13 |
+
model = VisionEncoderDecoderModel.from_pretrained('kun826/trocr_handwrite_option4')
|
14 |
+
pixel_values = processor(images=image, return_tensors="pt").pixel_values
|
15 |
+
|
16 |
+
generated_ids = model.generate(pixel_values)
|
17 |
+
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
|