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.42, ONNX Runtime 1.24.3 | 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® 8 Elite Gen 5 Mobile | 1.155 ms | 0 - 225 MB | NPU |
| decoder | ONNX | float | Snapdragon® X2 Elite | 1.176 ms | 68 - 68 MB | NPU |
| decoder | ONNX | float | Snapdragon® X Elite | 2.299 ms | 67 - 67 MB | NPU |
| decoder | ONNX | float | Snapdragon® 8 Gen 3 Mobile | 1.457 ms | 0 - 249 MB | NPU |
| decoder | ONNX | float | Qualcomm® QCS8550 (Proxy) | 2.127 ms | 0 - 76 MB | NPU |
| decoder | ONNX | float | Qualcomm® QCS9075 | 2.702 ms | 7 - 16 MB | NPU |
| decoder | ONNX | float | Snapdragon® 8 Elite For Galaxy Mobile | 1.242 ms | 0 - 252 MB | NPU |
| decoder | QNN_DLC | float | Snapdragon® 8 Elite Gen 5 Mobile | 1.142 ms | 1 - 174 MB | NPU |
| decoder | QNN_DLC | float | Snapdragon® X2 Elite | 1.53 ms | 7 - 7 MB | NPU |
| decoder | QNN_DLC | float | Snapdragon® X Elite | 2.17 ms | 7 - 7 MB | NPU |
| decoder | QNN_DLC | float | Snapdragon® 8 Gen 3 Mobile | 1.421 ms | 0 - 281 MB | NPU |
| decoder | QNN_DLC | float | Qualcomm® QCS8275 (Proxy) | 4.184 ms | 1 - 102 MB | NPU |
| decoder | QNN_DLC | float | Qualcomm® QCS8550 (Proxy) | 2.047 ms | 1 - 3 MB | NPU |
| decoder | QNN_DLC | float | Qualcomm® SA8775P | 2.895 ms | 0 - 102 MB | NPU |
| decoder | QNN_DLC | float | Qualcomm® QCS9075 | 2.57 ms | 7 - 15 MB | NPU |
| decoder | QNN_DLC | float | Qualcomm® QCS8450 (Proxy) | 2.635 ms | 2 - 216 MB | NPU |
| decoder | QNN_DLC | float | Qualcomm® SA7255P | 4.184 ms | 1 - 102 MB | NPU |
| decoder | QNN_DLC | float | Qualcomm® SA8295P | 2.704 ms | 7 - 49 MB | NPU |
| decoder | QNN_DLC | float | Snapdragon® 8 Elite For Galaxy Mobile | 1.279 ms | 0 - 188 MB | NPU |
| decoder | TFLITE | float | Snapdragon® 8 Elite Gen 5 Mobile | 1.118 ms | 0 - 175 MB | NPU |
| decoder | TFLITE | float | Snapdragon® 8 Gen 3 Mobile | 1.632 ms | 0 - 281 MB | NPU |
| decoder | TFLITE | float | Qualcomm® QCS8275 (Proxy) | 4.232 ms | 0 - 103 MB | NPU |
| decoder | TFLITE | float | Qualcomm® QCS8550 (Proxy) | 1.986 ms | 0 - 2 MB | NPU |
| decoder | TFLITE | float | Qualcomm® SA8775P | 2.864 ms | 0 - 102 MB | NPU |
| decoder | TFLITE | float | Qualcomm® QCS9075 | 2.537 ms | 0 - 83 MB | NPU |
| decoder | TFLITE | float | Qualcomm® QCS8450 (Proxy) | 2.444 ms | 0 - 215 MB | NPU |
| decoder | TFLITE | float | Qualcomm® SA7255P | 4.232 ms | 0 - 103 MB | NPU |
| decoder | TFLITE | float | Qualcomm® SA8295P | 2.664 ms | 0 - 43 MB | NPU |
| decoder | TFLITE | float | Snapdragon® 8 Elite For Galaxy Mobile | 1.229 ms | 0 - 192 MB | NPU |
| encoder | ONNX | float | Snapdragon® 8 Elite Gen 5 Mobile | 7.262 ms | 16 - 326 MB | NPU |
| encoder | ONNX | float | Snapdragon® X2 Elite | 7.526 ms | 48 - 48 MB | NPU |
| encoder | ONNX | float | Snapdragon® X Elite | 18.696 ms | 48 - 48 MB | NPU |
| encoder | ONNX | float | Snapdragon® 8 Gen 3 Mobile | 12.569 ms | 16 - 404 MB | NPU |
| encoder | ONNX | float | Qualcomm® QCS8550 (Proxy) | 18.211 ms | 0 - 61 MB | NPU |
| encoder | ONNX | float | Qualcomm® QCS9075 | 22.075 ms | 15 - 19 MB | NPU |
| encoder | ONNX | float | Snapdragon® 8 Elite For Galaxy Mobile | 9.014 ms | 16 - 333 MB | NPU |
| encoder | QNN_DLC | float | Snapdragon® 8 Elite Gen 5 Mobile | 7.232 ms | 2 - 295 MB | NPU |
| encoder | QNN_DLC | float | Snapdragon® X2 Elite | 7.863 ms | 2 - 2 MB | NPU |
| encoder | QNN_DLC | float | Snapdragon® X Elite | 19.138 ms | 2 - 2 MB | NPU |
| encoder | QNN_DLC | float | Snapdragon® 8 Gen 3 Mobile | 12.783 ms | 2 - 349 MB | NPU |
| encoder | QNN_DLC | float | Qualcomm® QCS8275 (Proxy) | 47.835 ms | 2 - 264 MB | NPU |
| encoder | QNN_DLC | float | Qualcomm® QCS8550 (Proxy) | 18.529 ms | 2 - 3 MB | NPU |
| encoder | QNN_DLC | float | Qualcomm® SA8775P | 20.574 ms | 2 - 264 MB | NPU |
| encoder | QNN_DLC | float | Qualcomm® QCS9075 | 22.215 ms | 2 - 12 MB | NPU |
| encoder | QNN_DLC | float | Qualcomm® QCS8450 (Proxy) | 28.134 ms | 0 - 331 MB | NPU |
| encoder | QNN_DLC | float | Qualcomm® SA7255P | 47.835 ms | 2 - 264 MB | NPU |
| encoder | QNN_DLC | float | Qualcomm® SA8295P | 25.875 ms | 2 - 266 MB | NPU |
| encoder | QNN_DLC | float | Snapdragon® 8 Elite For Galaxy Mobile | 8.987 ms | 2 - 304 MB | NPU |
| encoder | TFLITE | float | Snapdragon® 8 Elite Gen 5 Mobile | 4.428 ms | 6 - 152 MB | NPU |
| encoder | TFLITE | float | Snapdragon® 8 Gen 3 Mobile | 8.411 ms | 6 - 228 MB | NPU |
| encoder | TFLITE | float | Qualcomm® QCS8275 (Proxy) | 38.056 ms | 7 - 172 MB | NPU |
| encoder | TFLITE | float | Qualcomm® QCS8550 (Proxy) | 12.005 ms | 7 - 9 MB | NPU |
| encoder | TFLITE | float | Qualcomm® SA8775P | 14.566 ms | 7 - 175 MB | NPU |
| encoder | TFLITE | float | Qualcomm® QCS9075 | 15.148 ms | 6 - 66 MB | NPU |
| encoder | TFLITE | float | Qualcomm® QCS8450 (Proxy) | 21.069 ms | 7 - 341 MB | NPU |
| encoder | TFLITE | float | Qualcomm® SA7255P | 38.056 ms | 7 - 172 MB | NPU |
| encoder | TFLITE | float | Qualcomm® SA8295P | 20.649 ms | 7 - 288 MB | NPU |
| encoder | TFLITE | float | Snapdragon® 8 Elite For Galaxy Mobile | 5.657 ms | 5 - 154 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.
