TrOCR-FP16
Text Recognizer
FP16
post
TrOCR: Optical Character Recognition

TrOCR (Transformer-based OCR) is an end-to-end OCR model from Microsoft Research, introduced in 2021. It combines a Vision Transformer (e.g. ViT/DeiT/BEiT) as an image encoder with a text Transformer (e.g. RoBERTa/UniLM) decoder.

  • Architecture: Full transformer encoder-decoder. The image is tokenized into patch embeddings and text is autoregressively generated.
  • Model Variants: Available in Small (62M params), Base (334M params), and Large (~558–608M params), catering to different deployment needs.
  • State-of-the-art Performance: Achieves top-tier results across printed, handwritten, and scene text benchmarks. On the IAM handwritten dataset, CER is 4.22% (Small), 3.42% (Base), and 2.89% (Large).
  • Optimized Variants: TrOCR‑Small‑Handwritten is fine-tuned for handwritten text, supporting batch inference and practical applications.

Source model

  • Input shape: 640x640
  • Number of paramaters: 68.89M
  • Model size: 277.39M
  • Output shape: 1x37x8400,1x32x160x160

Source model repository: TrOCR

Performance Reference

Device

Backend
Precision
Inference Time
Accuracy Loss
File Size
Model Optimization

When the user has fine-tuned the source model, the model conversion process must be performed again.

Users can refer to either of the following two methods to complete the model conversion:

  • Using AIMO for model conversion: Click Model Conversion Reference in the Performance Reference section on the right to view the conversion steps.

  • Using Qualcomm QNN for model conversion: Please refer to the Qualcomm QNN Documentation.

Model Inference

The model performance benchmarks and example code provided by Model Farm are all implemented based on the APLUX AidLite SDK.

For models in .bin format, you can use either of the following two inference engines to run inference on Qualcomm chips:

Inference using APLUX AidLite: please refer to the APLUX AidLite Developer Documentation

Inference using Qualcomm QNN: Please refer to the Qualcomm QNN Documentation

Inference Example Code

The inference example code is implemented using the AidLite SDK.

Click Model & Code to download the model files and the inference code package. The file structure is as follows:

/model_farm_{model_name}_aidlite
    
    |__ models # folder where model files are stored

    |__ python # aidlite python model inference example

    |__ cpp # aidlite cpp model inference example

    |__ README.md
License
Source Model:MIT
Deployable Model:APLUX-MODEL-FARM-LICENSE
Performance Reference

Device

Backend
Precision
Inference Time
Accuracy Loss
File Size