Downloads · 30 days
12
2% of all-time downloads
ycchen/TrOCR-base-ver021-v1
TrOCR-base-ver021-v1 is a image-text-to-text model from ycchen. Use it for the image-text-to-text task on the model card, and read the license before you ship it in a product. It is set up for transformers.
Here is how to use this model in PyTorch:
Downloads · 30 days
12
2% of all-time downloads
All-time downloads
604
Public
Repo size
1.3 GB
Likes
0
Public
Click a slice to open those files.
.bin639 MB · 100%
From the Hugging Face model README
Here is how to use this model in PyTorch:
from transformers import TrOCRProcessor, VisionEncoderDecoderModel
from PIL import Image
import requests
# load image from the IAM database (actually this model is meant to be used on printed text)
url = 'https://fki.tic.heia-fr.ch/static/img/a01-122-02-00.jpg'
image = Image.open(requests.get(url, stream=True).raw).convert("RGB")
processor = TrOCRProcessor.from_pretrained('ycchen/TrOCR-base-ver021-v1')
model = VisionEncoderDecoderModel.from_pretrained('ycchen/TrOCR-base-ver021-v1')
pixel_values = processor(images=image, return_tensors="pt").pixel_values
generated_ids = model.generate(pixel_values)
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]