TrOCR: Optimized for Qualcomm Devices
End-to-end text recognition approach with pre-trained image transformer and text transformer models for both image understanding and wordpiece-level text generation.
This is based on the implementation of TrOCR found here. This repository contains pre-exported model files optimized for Qualcomm® devices. You can use the Qualcomm® AI Hub Models library to export with custom configurations. More details on model performance across various devices, can be found here.
Qualcomm AI Hub Models uses Qualcomm AI Hub Workbench to compile, profile, and evaluate this model. Sign up to run these models on a hosted Qualcomm® device.
Getting Started
There are two ways to deploy this model on your device:
Option 1: Download Pre-Exported Models
Below are pre-exported model assets ready for deployment.
| Runtime | Precision | Chipset | SDK Versions | Download |
|---|---|---|---|---|
| ONNX | float | Universal | QAIRT 2.45, ONNX Runtime 1.25.0 | Download |
| QNN_DLC | float | Universal | QAIRT 2.45 | Download |
| TFLITE | float | Universal | QAIRT 2.45 | Download |
For more device-specific assets and performance metrics, visit TrOCR on Qualcomm® AI Hub.
Option 2: Export with Custom Configurations
Use the Qualcomm® AI Hub Models Python library to compile and export the model with your own:
- Custom weights (e.g., fine-tuned checkpoints)
- Custom input shapes
- Target device and runtime configurations
This option is ideal if you need to customize the model beyond the default configuration provided here.
See our repository for TrOCR on GitHub for usage instructions.
Model Details
Model Type: Model_use_case.image_to_text
Model Stats:
- Model checkpoint: trocr-small-stage1
- Input resolution: 320x320
- Number of parameters (decoder): 38.3M
- Model size (decoder) (float): 146 MB
- Number of parameters (encoder): 23.0M
- Model size (encoder) (float): 87.8 MB
Performance Summary
| Model | Runtime | Precision | Chipset | Inference Time (ms) | Peak Memory Range (MB) | Primary Compute Unit |
|---|---|---|---|---|---|---|
| decoder | ONNX | float | Snapdragon® X2 Elite | 1.259 ms | 7 - 7 MB | NPU |
| decoder | ONNX | float | Snapdragon® X Elite | 2.1 ms | 68 - 68 MB | NPU |
| decoder | ONNX | float | Snapdragon® 8 Gen 3 Mobile | 1.449 ms | 0 - 282 MB | NPU |
| decoder | ONNX | float | Snapdragon® 8 Gen 1 Mobile | 2.735 ms | 1 - 218 MB | NPU |
| decoder | ONNX | float | Qualcomm® Dragonwing™ QCS8550 (Proxy) | 2.112 ms | 1 - 3 MB | NPU |
| decoder | ONNX | float | Qualcomm® QCS8450 | 2.735 ms | 1 - 218 MB | NPU |
| decoder | ONNX | float | Qualcomm® Dragonwing™ IQ-9075 | 2.74 ms | 7 - 16 MB | NPU |
| decoder | ONNX | float | Snapdragon® 8 Elite Gen 5 Mobile | 1.182 ms | 2 - 179 MB | NPU |
| decoder | ONNX | float | Snapdragon® 8 Elite Mobile | 1.3 ms | 0 - 189 MB | NPU |
| decoder | ONNX | float | Qualcomm® Dragonwing™ Q-8750 | 1.3 ms | 0 - 189 MB | NPU |
| decoder | ONNX | float | Qualcomm® Dragonwing™ IQ-X7181 | 2.1 ms | 68 - 68 MB | NPU |
| decoder | QNN_DLC | float | Snapdragon® X2 Elite | 1.556 ms | 7 - 7 MB | NPU |
| decoder | QNN_DLC | float | Snapdragon® X Elite | 2.208 ms | 7 - 7 MB | NPU |
| decoder | QNN_DLC | float | Snapdragon® 8 Gen 3 Mobile | 1.424 ms | 0 - 278 MB | NPU |
| decoder | QNN_DLC | float | Snapdragon® 8 Gen 1 Mobile | 2.672 ms | 2 - 216 MB | NPU |
| decoder | QNN_DLC | float | Qualcomm® QCS8275 | 4.137 ms | 5 - 106 MB | NPU |
| decoder | QNN_DLC | float | Qualcomm® Dragonwing™ QCS8550 (Proxy) | 2.012 ms | 1 - 2 MB | NPU |
| decoder | QNN_DLC | float | Qualcomm® SA8775P | 2.861 ms | 5 - 107 MB | NPU |
| decoder | QNN_DLC | float | Qualcomm® SA8650P | 2.861 ms | 5 - 107 MB | NPU |
| decoder | QNN_DLC | float | Qualcomm® SA8255P | 2.861 ms | 5 - 107 MB | NPU |
| decoder | QNN_DLC | float | Qualcomm® QCS8450 | 2.672 ms | 2 - 216 MB | NPU |
| decoder | QNN_DLC | float | Qualcomm® Dragonwing™ IQ-9075 | 2.859 ms | 7 - 16 MB | NPU |
| decoder | QNN_DLC | float | Snapdragon® 8 Elite Gen 5 Mobile | 1.158 ms | 1 - 172 MB | NPU |
| decoder | QNN_DLC | float | Qualcomm® SA7255P | 4.137 ms | 5 - 106 MB | NPU |
| decoder | QNN_DLC | float | Snapdragon® 8 Elite Mobile | 1.247 ms | 0 - 187 MB | NPU |
| decoder | QNN_DLC | float | Qualcomm® SA8295P | 2.558 ms | 0 - 42 MB | NPU |
| decoder | QNN_DLC | float | Qualcomm® Dragonwing™ Q-8750 | 1.247 ms | 0 - 187 MB | NPU |
| decoder | QNN_DLC | float | Qualcomm® Dragonwing™ IQ-X7181 | 2.208 ms | 7 - 7 MB | NPU |
| decoder | TFLITE | float | Snapdragon® 8 Gen 3 Mobile | 1.381 ms | 0 - 280 MB | NPU |
| decoder | TFLITE | float | Snapdragon® 8 Gen 1 Mobile | 2.456 ms | 0 - 217 MB | NPU |
| decoder | TFLITE | float | Qualcomm® QCS8275 | 12.741 ms | 7 - 22 MB | GPU |
| decoder | TFLITE | float | Qualcomm® Dragonwing™ QCS8550 (Proxy) | 1.95 ms | 0 - 2 MB | NPU |
| decoder | TFLITE | float | Qualcomm® SA8775P | 2.847 ms | 0 - 103 MB | NPU |
| decoder | TFLITE | float | Qualcomm® SA8650P | 2.847 ms | 0 - 103 MB | NPU |
| decoder | TFLITE | float | Qualcomm® SA8255P | 2.847 ms | 0 - 103 MB | NPU |
| decoder | TFLITE | float | Qualcomm® QCS8450 | 2.456 ms | 0 - 217 MB | NPU |
| decoder | TFLITE | float | Qualcomm® Dragonwing™ IQ-9075 | 2.779 ms | 0 - 83 MB | NPU |
| decoder | TFLITE | float | Snapdragon® 8 Elite Gen 5 Mobile | 1.136 ms | 0 - 171 MB | NPU |
| decoder | TFLITE | float | Qualcomm® SA7255P | 12.741 ms | 7 - 22 MB | GPU |
| decoder | TFLITE | float | Snapdragon® 8 Elite Mobile | 1.266 ms | 0 - 190 MB | NPU |
| decoder | TFLITE | float | Qualcomm® SA8295P | 2.597 ms | 0 - 44 MB | NPU |
| decoder | TFLITE | float | Qualcomm® Dragonwing™ Q-8750 | 1.266 ms | 0 - 190 MB | NPU |
| encoder | ONNX | float | Snapdragon® X2 Elite | 4.557 ms | 16 - 16 MB | NPU |
| encoder | ONNX | float | Snapdragon® X Elite | 11.3 ms | 48 - 48 MB | NPU |
| encoder | ONNX | float | Snapdragon® 8 Gen 3 Mobile | 7.834 ms | 0 - 199 MB | NPU |
| encoder | ONNX | float | Snapdragon® 8 Gen 1 Mobile | 19.787 ms | 0 - 315 MB | NPU |
| encoder | ONNX | float | Qualcomm® Dragonwing™ QCS8550 (Proxy) | 10.93 ms | 0 - 269 MB | NPU |
| encoder | ONNX | float | Qualcomm® QCS8450 | 19.787 ms | 0 - 315 MB | NPU |
| encoder | ONNX | float | Qualcomm® Dragonwing™ IQ-9075 | 13.736 ms | 15 - 19 MB | NPU |
| encoder | ONNX | float | Snapdragon® 8 Elite Gen 5 Mobile | 4.149 ms | 0 - 124 MB | NPU |
| encoder | ONNX | float | Snapdragon® 8 Elite Mobile | 5.304 ms | 16 - 139 MB | NPU |
| encoder | ONNX | float | Qualcomm® Dragonwing™ Q-8750 | 5.304 ms | 16 - 139 MB | NPU |
| encoder | ONNX | float | Qualcomm® Dragonwing™ IQ-X7181 | 11.3 ms | 48 - 48 MB | NPU |
| encoder | QNN_DLC | float | Snapdragon® X2 Elite | 5.137 ms | 2 - 2 MB | NPU |
| encoder | QNN_DLC | float | Snapdragon® X Elite | 12.101 ms | 2 - 2 MB | NPU |
| encoder | QNN_DLC | float | Snapdragon® 8 Gen 3 Mobile | 8.005 ms | 2 - 192 MB | NPU |
| encoder | QNN_DLC | float | Snapdragon® 8 Gen 1 Mobile | 19.346 ms | 2 - 309 MB | NPU |
| encoder | QNN_DLC | float | Qualcomm® QCS8275 | 37.051 ms | 2 - 107 MB | NPU |
| encoder | QNN_DLC | float | Qualcomm® Dragonwing™ QCS8550 (Proxy) | 11.262 ms | 2 - 4 MB | NPU |
| encoder | QNN_DLC | float | Qualcomm® SA8775P | 14.018 ms | 2 - 109 MB | NPU |
| encoder | QNN_DLC | float | Qualcomm® SA8650P | 14.018 ms | 2 - 109 MB | NPU |
| encoder | QNN_DLC | float | Qualcomm® SA8255P | 14.018 ms | 2 - 109 MB | NPU |
| encoder | QNN_DLC | float | Qualcomm® QCS8450 | 19.346 ms | 2 - 309 MB | NPU |
| encoder | QNN_DLC | float | Qualcomm® Dragonwing™ IQ-9075 | 14.22 ms | 4 - 14 MB | NPU |
| encoder | QNN_DLC | float | Snapdragon® 8 Elite Gen 5 Mobile | 4.351 ms | 2 - 115 MB | NPU |
| encoder | QNN_DLC | float | Qualcomm® SA7255P | 37.051 ms | 2 - 107 MB | NPU |
| encoder | QNN_DLC | float | Snapdragon® 8 Elite Mobile | 5.44 ms | 2 - 116 MB | NPU |
| encoder | QNN_DLC | float | Qualcomm® SA8295P | 19.681 ms | 2 - 235 MB | NPU |
| encoder | QNN_DLC | float | Qualcomm® Dragonwing™ Q-8750 | 5.44 ms | 2 - 116 MB | NPU |
| encoder | QNN_DLC | float | Qualcomm® Dragonwing™ IQ-X7181 | 12.101 ms | 2 - 2 MB | NPU |
| encoder | TFLITE | float | Snapdragon® 8 Gen 3 Mobile | 7.705 ms | 3 - 195 MB | NPU |
| encoder | TFLITE | float | Snapdragon® 8 Gen 1 Mobile | 19.56 ms | 7 - 312 MB | NPU |
| encoder | TFLITE | float | Qualcomm® QCS8275 | 36.827 ms | 7 - 119 MB | NPU |
| encoder | TFLITE | float | Qualcomm® Dragonwing™ QCS8550 (Proxy) | 10.673 ms | 7 - 9 MB | NPU |
| encoder | TFLITE | float | Qualcomm® SA8775P | 13.49 ms | 7 - 111 MB | NPU |
| encoder | TFLITE | float | Qualcomm® SA8650P | 13.49 ms | 7 - 111 MB | NPU |
| encoder | TFLITE | float | Qualcomm® SA8255P | 13.49 ms | 7 - 111 MB | NPU |
| encoder | TFLITE | float | Qualcomm® QCS8450 | 19.56 ms | 7 - 312 MB | NPU |
| encoder | TFLITE | float | Qualcomm® Dragonwing™ IQ-9075 | 13.235 ms | 6 - 65 MB | NPU |
| encoder | TFLITE | float | Snapdragon® 8 Elite Gen 5 Mobile | 4.119 ms | 0 - 104 MB | NPU |
| encoder | TFLITE | float | Qualcomm® SA7255P | 36.827 ms | 7 - 119 MB | NPU |
| encoder | TFLITE | float | Snapdragon® 8 Elite Mobile | 5.202 ms | 6 - 119 MB | NPU |
| encoder | TFLITE | float | Qualcomm® SA8295P | 19.106 ms | 7 - 237 MB | NPU |
| encoder | TFLITE | float | Qualcomm® Dragonwing™ Q-8750 | 5.202 ms | 6 - 119 MB | NPU |
License
- The license for the original implementation of TrOCR can be found here.
References
- TrOCR: Transformer-based Optical Character Recognition with Pre-trained Models
- Source Model Implementation
Community
- Join our AI Hub Slack community to collaborate, post questions and learn more about on-device AI.
- For questions or feedback please reach out to us.
