microsoft / trocr-small-stage1

huggingface.co
Total runs: 19.2K
24-hour runs: 0
7-day runs: 519
30-day runs: 6.6K
Model's Last Updated: January 25 2023
image-to-text

Introduction of trocr-small-stage1

Model Details of trocr-small-stage1

TrOCR (small-sized model, pre-trained only)

TrOCR pre-trained only model. It was introduced in the paper TrOCR: Transformer-based Optical Character Recognition with Pre-trained Models by Li et al. and first released in this repository .

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 DeiT, while the text decoder was initialized from the weights of UniLM.

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
import torch

# 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-small-stage1')
model = VisionEncoderDecoderModel.from_pretrained('microsoft/trocr-small-stage1')

# training
pixel_values = processor(image, return_tensors="pt").pixel_values  # Batch size 1
decoder_input_ids = torch.tensor([[model.config.decoder.decoder_start_token_id]])
outputs = model(pixel_values=pixel_values, decoder_input_ids=decoder_input_ids)
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-small-stage1 on huggingface.co

19.2K
Total runs
0
24-hour runs
-23
3-day runs
519
7-day runs
6.6K
30-day runs

More Information About trocr-small-stage1 huggingface.co Model

trocr-small-stage1 huggingface.co

trocr-small-stage1 huggingface.co is an AI model on huggingface.co that provides trocr-small-stage1's model effect (), which can be used instantly with this microsoft trocr-small-stage1 model. huggingface.co supports a free trial of the trocr-small-stage1 model, and also provides paid use of the trocr-small-stage1. Support call trocr-small-stage1 model through api, including Node.js, Python, http.

trocr-small-stage1 huggingface.co Url

https://huggingface.co/microsoft/trocr-small-stage1

microsoft trocr-small-stage1 online free

trocr-small-stage1 huggingface.co is an online trial and call api platform, which integrates trocr-small-stage1's modeling effects, including api services, and provides a free online trial of trocr-small-stage1, you can try trocr-small-stage1 online for free by clicking the link below.

microsoft trocr-small-stage1 online free url in huggingface.co:

https://huggingface.co/microsoft/trocr-small-stage1

trocr-small-stage1 install

trocr-small-stage1 is an open source model from GitHub that offers a free installation service, and any user can find trocr-small-stage1 on GitHub to install. At the same time, huggingface.co provides the effect of trocr-small-stage1 install, users can directly use trocr-small-stage1 installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

trocr-small-stage1 install url in huggingface.co:

https://huggingface.co/microsoft/trocr-small-stage1

Url of trocr-small-stage1

trocr-small-stage1 huggingface.co Url

Provider of trocr-small-stage1 huggingface.co

microsoft
ORGANIZATIONS

Other API from microsoft

huggingface.co

Total runs: 681.1K
Run Growth: 208.0K
Growth Rate: 30.53%
Updated:February 03 2022
huggingface.co

Total runs: 595.8K
Run Growth: -131.1K
Growth Rate: -22.00%
Updated:November 25 2025
huggingface.co

Total runs: 535.6K
Run Growth: 307.0K
Growth Rate: 57.32%
Updated:April 08 2024
huggingface.co

Total runs: 511.8K
Run Growth: -531.5K
Growth Rate: -103.84%
Updated:December 08 2025
huggingface.co

Total runs: 289.1K
Run Growth: -22.3K
Growth Rate: -7.70%
Updated:February 14 2024
huggingface.co

Total runs: 117.8K
Run Growth: -147.4K
Growth Rate: -125.12%
Updated:November 08 2023
huggingface.co

Total runs: 117.6K
Run Growth: -1.2K
Growth Rate: -1.03%
Updated:February 29 2024
huggingface.co

Total runs: 100.0K
Run Growth: -425
Growth Rate: -0.42%
Updated:August 28 2025
huggingface.co

Total runs: 69.7K
Run Growth: -13.1K
Growth Rate: -18.74%
Updated:November 25 2025
huggingface.co

Total runs: 68.7K
Run Growth: -18.2K
Growth Rate: -26.47%
Updated:December 03 2025
huggingface.co

Total runs: 54.8K
Run Growth: -231.8K
Growth Rate: -422.83%
Updated:September 26 2022
huggingface.co

Total runs: 48.2K
Run Growth: -8.9K
Growth Rate: -18.47%
Updated:December 23 2021
huggingface.co

Total runs: 39.6K
Run Growth: -86.8K
Growth Rate: -219.35%
Updated:February 03 2023
huggingface.co

Total runs: 34.6K
Run Growth: -69.2K
Growth Rate: -200.07%
Updated:May 12 2026
huggingface.co

Total runs: 32.5K
Run Growth: 28.2K
Growth Rate: 86.85%
Updated:April 23 2026
huggingface.co

Total runs: 23.0K
Run Growth: -85.2K
Growth Rate: -314.46%
Updated:March 23 2023
huggingface.co

Total runs: 22.7K
Run Growth: -6.1K
Growth Rate: -25.79%
Updated:April 24 2023