Disclaimer: The team releasing TrOCR did not write a model card for this model so this model card has been written by the Hugging Face team.
Model description
The TrOCR model is an encoder-decoder model, consisting of an image Transformer as encoder, and a text Transformer as decoder. The image encoder was initialized from the weights of BEiT, while the text decoder was initialized from the weights of RoBERTa.
Images are presented to the model as a sequence of fixed-size patches (resolution 16x16), which are linearly embedded. One also adds absolute position embeddings before feeding the sequence to the layers of the Transformer encoder. Next, the Transformer text decoder autoregressively generates tokens.
Intended uses & limitations
You can use the raw model for optical character recognition (OCR) on single text-line images. See the
model hub
to look for fine-tuned versions on a task that interests you.
How to use
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
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('microsoft/trocr-large-handwritten')
model = VisionEncoderDecoderModel.from_pretrained('microsoft/trocr-large-handwritten')
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]
BibTeX entry and citation info
@misc{li2021trocr,
title={TrOCR: Transformer-based Optical Character Recognition with Pre-trained Models},
author={Minghao Li and Tengchao Lv and Lei Cui and Yijuan Lu and Dinei Florencio and Cha Zhang and Zhoujun Li and Furu Wei},
year={2021},
eprint={2109.10282},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
Runs of microsoft trocr-large-handwritten on huggingface.co
65.5K
Total runs
0
24-hour runs
-3.8K
3-day runs
-5.0K
7-day runs
25.4K
30-day runs
More Information About trocr-large-handwritten huggingface.co Model
trocr-large-handwritten huggingface.co
trocr-large-handwritten huggingface.co is an AI model on huggingface.co that provides trocr-large-handwritten's model effect (), which can be used instantly with this microsoft trocr-large-handwritten model. huggingface.co supports a free trial of the trocr-large-handwritten model, and also provides paid use of the trocr-large-handwritten. Support call trocr-large-handwritten model through api, including Node.js, Python, http.
trocr-large-handwritten huggingface.co is an online trial and call api platform, which integrates trocr-large-handwritten's modeling effects, including api services, and provides a free online trial of trocr-large-handwritten, you can try trocr-large-handwritten online for free by clicking the link below.
microsoft trocr-large-handwritten online free url in huggingface.co:
trocr-large-handwritten is an open source model from GitHub that offers a free installation service, and any user can find trocr-large-handwritten on GitHub to install. At the same time, huggingface.co provides the effect of trocr-large-handwritten install, users can directly use trocr-large-handwritten installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
trocr-large-handwritten install url in huggingface.co: