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.37, ONNX Runtime 1.23.0 | Download |
| QNN_DLC | float | Universal | QAIRT 2.42 | Download |
| TFLITE | float | Universal | QAIRT 2.42, TFLite 2.17.0 | 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 (TrOCRDecoder): 38.3M
- Model size (TrOCRDecoder) (float): 146 MB
- Number of parameters (TrOCREncoder): 23.0M
- Model size (TrOCREncoder) (float): 87.8 MB
Performance Summary
| Model | Runtime | Precision | Chipset | Inference Time (ms) | Peak Memory Range (MB) | Primary Compute Unit |
|---|---|---|---|---|---|---|
| TrOCRDecoder | ONNX | float | Snapdragon® X Elite | 2.358 ms | 67 - 67 MB | NPU |
| TrOCRDecoder | ONNX | float | Snapdragon® 8 Gen 3 Mobile | 1.842 ms | 0 - 287 MB | NPU |
| TrOCRDecoder | ONNX | float | Qualcomm® QCS8550 (Proxy) | 2.51 ms | 0 - 350 MB | NPU |
| TrOCRDecoder | ONNX | float | Qualcomm® QCS9075 | 2.962 ms | 7 - 17 MB | NPU |
| TrOCRDecoder | ONNX | float | Snapdragon® 8 Elite For Galaxy Mobile | 1.587 ms | 0 - 271 MB | NPU |
| TrOCRDecoder | ONNX | float | Snapdragon® 8 Elite Gen 5 Mobile | 1.424 ms | 0 - 258 MB | NPU |
| TrOCRDecoder | QNN_DLC | float | Snapdragon® X Elite | 2.172 ms | 7 - 7 MB | NPU |
| TrOCRDecoder | QNN_DLC | float | Snapdragon® 8 Gen 3 Mobile | 1.388 ms | 0 - 243 MB | NPU |
| TrOCRDecoder | QNN_DLC | float | Qualcomm® QCS8275 (Proxy) | 4.138 ms | 7 - 148 MB | NPU |
| TrOCRDecoder | QNN_DLC | float | Qualcomm® QCS8550 (Proxy) | 1.932 ms | 3 - 5 MB | NPU |
| TrOCRDecoder | QNN_DLC | float | Qualcomm® SA8775P | 2.764 ms | 7 - 148 MB | NPU |
| TrOCRDecoder | QNN_DLC | float | Qualcomm® QCS9075 | 2.54 ms | 7 - 15 MB | NPU |
| TrOCRDecoder | QNN_DLC | float | Qualcomm® QCS8450 (Proxy) | 2.835 ms | 2 - 216 MB | NPU |
| TrOCRDecoder | QNN_DLC | float | Qualcomm® SA7255P | 4.138 ms | 7 - 148 MB | NPU |
| TrOCRDecoder | QNN_DLC | float | Qualcomm® SA8295P | 2.802 ms | 7 - 130 MB | NPU |
| TrOCRDecoder | QNN_DLC | float | Snapdragon® 8 Elite For Galaxy Mobile | 1.208 ms | 0 - 227 MB | NPU |
| TrOCRDecoder | QNN_DLC | float | Snapdragon® 8 Elite Gen 5 Mobile | 1.093 ms | 1 - 213 MB | NPU |
| TrOCRDecoder | TFLITE | float | Snapdragon® 8 Gen 3 Mobile | 1.404 ms | 0 - 258 MB | NPU |
| TrOCRDecoder | TFLITE | float | Qualcomm® QCS8275 (Proxy) | 4.162 ms | 0 - 160 MB | NPU |
| TrOCRDecoder | TFLITE | float | Qualcomm® QCS8550 (Proxy) | 2.009 ms | 0 - 8 MB | NPU |
| TrOCRDecoder | TFLITE | float | Qualcomm® SA8775P | 8.646 ms | 0 - 161 MB | NPU |
| TrOCRDecoder | TFLITE | float | Qualcomm® QCS9075 | 2.547 ms | 0 - 83 MB | NPU |
| TrOCRDecoder | TFLITE | float | Qualcomm® QCS8450 (Proxy) | 2.815 ms | 0 - 224 MB | NPU |
| TrOCRDecoder | TFLITE | float | Qualcomm® SA7255P | 4.162 ms | 0 - 160 MB | NPU |
| TrOCRDecoder | TFLITE | float | Qualcomm® SA8295P | 2.8 ms | 0 - 142 MB | NPU |
| TrOCRDecoder | TFLITE | float | Snapdragon® 8 Elite For Galaxy Mobile | 1.166 ms | 0 - 235 MB | NPU |
| TrOCRDecoder | TFLITE | float | Snapdragon® 8 Elite Gen 5 Mobile | 1.105 ms | 0 - 215 MB | NPU |
| TrOCREncoder | ONNX | float | Snapdragon® X Elite | 18.045 ms | 48 - 48 MB | NPU |
| TrOCREncoder | ONNX | float | Snapdragon® 8 Gen 3 Mobile | 11.593 ms | 14 - 389 MB | NPU |
| TrOCREncoder | ONNX | float | Qualcomm® QCS8550 (Proxy) | 17.6 ms | 0 - 57 MB | NPU |
| TrOCREncoder | ONNX | float | Qualcomm® QCS9075 | 21.826 ms | 15 - 19 MB | NPU |
| TrOCREncoder | ONNX | float | Snapdragon® 8 Elite For Galaxy Mobile | 10.097 ms | 14 - 280 MB | NPU |
| TrOCREncoder | ONNX | float | Snapdragon® 8 Elite Gen 5 Mobile | 7.252 ms | 1 - 245 MB | NPU |
| TrOCREncoder | QNN_DLC | float | Snapdragon® X Elite | 18.938 ms | 2 - 2 MB | NPU |
| TrOCREncoder | QNN_DLC | float | Snapdragon® 8 Gen 3 Mobile | 12.557 ms | 0 - 381 MB | NPU |
| TrOCREncoder | QNN_DLC | float | Qualcomm® QCS8275 (Proxy) | 47.203 ms | 2 - 291 MB | NPU |
| TrOCREncoder | QNN_DLC | float | Qualcomm® QCS8550 (Proxy) | 18.324 ms | 2 - 4 MB | NPU |
| TrOCREncoder | QNN_DLC | float | Qualcomm® SA8775P | 20.83 ms | 2 - 292 MB | NPU |
| TrOCREncoder | QNN_DLC | float | Qualcomm® QCS9075 | 22.183 ms | 2 - 12 MB | NPU |
| TrOCREncoder | QNN_DLC | float | Qualcomm® QCS8450 (Proxy) | 28.527 ms | 0 - 360 MB | NPU |
| TrOCREncoder | QNN_DLC | float | Qualcomm® SA7255P | 47.203 ms | 2 - 291 MB | NPU |
| TrOCREncoder | QNN_DLC | float | Qualcomm® SA8295P | 26.372 ms | 2 - 291 MB | NPU |
| TrOCREncoder | QNN_DLC | float | Snapdragon® 8 Elite For Galaxy Mobile | 8.827 ms | 2 - 312 MB | NPU |
| TrOCREncoder | QNN_DLC | float | Snapdragon® 8 Elite Gen 5 Mobile | 7.254 ms | 2 - 303 MB | NPU |
| TrOCREncoder | TFLITE | float | Snapdragon® 8 Gen 3 Mobile | 8.625 ms | 5 - 233 MB | NPU |
| TrOCREncoder | TFLITE | float | Qualcomm® QCS8275 (Proxy) | 38.239 ms | 7 - 149 MB | NPU |
| TrOCREncoder | TFLITE | float | Qualcomm® QCS8550 (Proxy) | 12.241 ms | 0 - 2 MB | NPU |
| TrOCREncoder | TFLITE | float | Qualcomm® SA8775P | 14.713 ms | 7 - 161 MB | NPU |
| TrOCREncoder | TFLITE | float | Qualcomm® QCS9075 | 15.775 ms | 6 - 66 MB | NPU |
| TrOCREncoder | TFLITE | float | Qualcomm® QCS8450 (Proxy) | 22.075 ms | 7 - 348 MB | NPU |
| TrOCREncoder | TFLITE | float | Qualcomm® SA7255P | 38.239 ms | 7 - 149 MB | NPU |
| TrOCREncoder | TFLITE | float | Qualcomm® SA8295P | 20.792 ms | 7 - 286 MB | NPU |
| TrOCREncoder | TFLITE | float | Snapdragon® 8 Elite For Galaxy Mobile | 5.851 ms | 6 - 151 MB | NPU |
| TrOCREncoder | TFLITE | float | Snapdragon® 8 Elite Gen 5 Mobile | 4.58 ms | 6 - 212 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.
