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.50, ONNX Runtime 1.27.1 | Download |
| QNN_DLC | float | Universal | QAIRT 2.50 | Download |
| TFLITE | float | Universal | QAIRT 2.50 | 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:
- Input resolution: 320x320
- Model checkpoint: trocr-small-handwritten
- Model size (decoder) (float): 146 MB
- Model size (encoder) (float): 87.8 MB
- Number of parameters (decoder): 38.3M
- Number of parameters (encoder): 23.0M
Performance Summary
| Model | Runtime | Precision | Chipset | Inference Time (ms) | Peak Memory Range (MB) | Primary Compute Unit |
|---|---|---|---|---|---|---|
| decoder | ONNX | float | Snapdragon® 8 Elite Gen 5 For Galaxy Mobile | 1.304 ms | 2 - 184 MB | NPU |
| decoder | ONNX | float | Snapdragon® 8 Elite For Galaxy Mobile | 1.282 ms | 0 - 196 MB | NPU |
| decoder | ONNX | float | Snapdragon® X2 Elite | 1.267 ms | 7 - 7 MB | NPU |
| decoder | ONNX | float | Snapdragon® X Elite | 1.931 ms | 68 - 68 MB | NPU |
| decoder | ONNX | float | Snapdragon® 8 Gen 3 Mobile | 1.512 ms | 0 - 285 MB | NPU |
| decoder | ONNX | float | Snapdragon® 8 Gen 1 Mobile | 2.313 ms | 1 - 224 MB | NPU |
| decoder | ONNX | float | Qualcomm® Dragonwing™ IQ-8275 | 2.811 ms | 7 - 18 MB | NPU |
| decoder | ONNX | float | Qualcomm® Dragonwing™ QCS8550 (Proxy) | 2.106 ms | 1 - 4 MB | NPU |
| decoder | ONNX | float | Qualcomm® QCS8450 | 2.313 ms | 1 - 224 MB | NPU |
| decoder | ONNX | float | Qualcomm® Dragonwing™ IQ-9075 | 2.759 ms | 7 - 17 MB | NPU |
| decoder | ONNX | float | Qualcomm® Dragonwing™ IQ-X7181 | 1.931 ms | 68 - 68 MB | NPU |
| decoder | ONNX | float | Qualcomm® Dragonwing™ Q-8750 | 1.282 ms | 0 - 196 MB | NPU |
| decoder | QNN_DLC | float | Snapdragon® 8 Elite Gen 5 For Galaxy Mobile | 1.278 ms | 2 - 178 MB | NPU |
| decoder | QNN_DLC | float | Snapdragon® 8 Elite For Galaxy Mobile | 1.257 ms | 0 - 189 MB | NPU |
| decoder | QNN_DLC | float | Snapdragon® X2 Elite | 1.701 ms | 7 - 7 MB | NPU |
| decoder | QNN_DLC | float | Snapdragon® X Elite | 2.156 ms | 7 - 7 MB | NPU |
| decoder | QNN_DLC | float | Snapdragon® 8 Gen 3 Mobile | 1.449 ms | 0 - 278 MB | NPU |
| decoder | QNN_DLC | float | Snapdragon® 8 Gen 1 Mobile | 2.277 ms | 2 - 223 MB | NPU |
| decoder | QNN_DLC | float | Qualcomm® Dragonwing™ IQ-8275 | 2.661 ms | 7 - 17 MB | NPU |
| decoder | QNN_DLC | float | Qualcomm® Dragonwing™ QCS8550 (Proxy) | 2.015 ms | 1 - 3 MB | NPU |
| decoder | QNN_DLC | float | Qualcomm® SA8650P | 2.892 ms | 5 - 106 MB | NPU |
| decoder | QNN_DLC | float | Qualcomm® SA8255P | 2.892 ms | 5 - 106 MB | NPU |
| decoder | QNN_DLC | float | Qualcomm® QCS8450 | 2.277 ms | 2 - 223 MB | NPU |
| decoder | QNN_DLC | float | Qualcomm® Dragonwing™ IQ-9075 | 2.602 ms | 7 - 16 MB | NPU |
| decoder | QNN_DLC | float | Qualcomm® Dragonwing™ IQ-X7181 | 2.156 ms | 7 - 7 MB | NPU |
| decoder | QNN_DLC | float | Qualcomm® Dragonwing™ Q-8750 | 1.257 ms | 0 - 189 MB | NPU |
| decoder | QNN_DLC | float | Qualcomm® SA7255P | 4.13 ms | 7 - 110 MB | NPU |
| decoder | QNN_DLC | float | Qualcomm® SA8295P | 2.595 ms | 0 - 45 MB | NPU |
| decoder | TFLITE | float | Snapdragon® 8 Elite Gen 5 For Galaxy Mobile | 1.257 ms | 0 - 179 MB | NPU |
| decoder | TFLITE | float | Snapdragon® 8 Elite For Galaxy Mobile | 1.239 ms | 0 - 192 MB | NPU |
| decoder | TFLITE | float | Snapdragon® 8 Gen 3 Mobile | 1.42 ms | 18 - 301 MB | NPU |
| decoder | TFLITE | float | Snapdragon® 8 Gen 1 Mobile | 2.271 ms | 0 - 220 MB | NPU |
| decoder | TFLITE | float | Qualcomm® Dragonwing™ IQ-8275 | 2.665 ms | 0 - 84 MB | NPU |
| decoder | TFLITE | float | Qualcomm® Dragonwing™ QCS8550 (Proxy) | 1.98 ms | 0 - 3 MB | NPU |
| decoder | TFLITE | float | Qualcomm® SA8650P | 2.84 ms | 0 - 104 MB | NPU |
| decoder | TFLITE | float | Qualcomm® SA8255P | 2.84 ms | 0 - 104 MB | NPU |
| decoder | TFLITE | float | Qualcomm® QCS8450 | 2.271 ms | 0 - 220 MB | NPU |
| decoder | TFLITE | float | Qualcomm® Dragonwing™ IQ-9075 | 2.582 ms | 0 - 83 MB | NPU |
| decoder | TFLITE | float | Qualcomm® Dragonwing™ Q-8750 | 1.239 ms | 0 - 192 MB | NPU |
| decoder | TFLITE | float | Qualcomm® SA8295P | 2.558 ms | 0 - 43 MB | NPU |
| encoder | ONNX | float | Snapdragon® 8 Elite Gen 5 For Galaxy Mobile | 4.111 ms | 2 - 126 MB | NPU |
| encoder | ONNX | float | Snapdragon® 8 Elite For Galaxy Mobile | 5.119 ms | 16 - 141 MB | NPU |
| encoder | ONNX | float | Snapdragon® X2 Elite | 4.481 ms | 16 - 16 MB | NPU |
| encoder | ONNX | float | Snapdragon® X Elite | 10.799 ms | 48 - 48 MB | NPU |
| encoder | ONNX | float | Snapdragon® 8 Gen 3 Mobile | 7.491 ms | 0 - 203 MB | NPU |
| encoder | ONNX | float | Snapdragon® 8 Gen 1 Mobile | 17.43 ms | 0 - 313 MB | NPU |
| encoder | ONNX | float | Qualcomm® Dragonwing™ IQ-8275 | 13.562 ms | 15 - 20 MB | NPU |
| encoder | ONNX | float | Qualcomm® Dragonwing™ QCS8550 (Proxy) | 10.388 ms | 0 - 57 MB | NPU |
| encoder | ONNX | float | Qualcomm® QCS8450 | 17.43 ms | 0 - 313 MB | NPU |
| encoder | ONNX | float | Qualcomm® Dragonwing™ IQ-9075 | 12.92 ms | 15 - 20 MB | NPU |
| encoder | ONNX | float | Qualcomm® Dragonwing™ IQ-X7181 | 10.799 ms | 48 - 48 MB | NPU |
| encoder | ONNX | float | Qualcomm® Dragonwing™ Q-8750 | 5.119 ms | 16 - 141 MB | NPU |
| encoder | QNN_DLC | float | Snapdragon® 8 Elite Gen 5 For Galaxy Mobile | 4.269 ms | 2 - 116 MB | NPU |
| encoder | QNN_DLC | float | Snapdragon® 8 Elite For Galaxy Mobile | 5.263 ms | 1 - 112 MB | NPU |
| encoder | QNN_DLC | float | Snapdragon® X2 Elite | 5.041 ms | 2 - 2 MB | NPU |
| encoder | QNN_DLC | float | Snapdragon® X Elite | 11.705 ms | 2 - 2 MB | NPU |
| encoder | QNN_DLC | float | Snapdragon® 8 Gen 3 Mobile | 7.697 ms | 2 - 194 MB | NPU |
| encoder | QNN_DLC | float | Snapdragon® 8 Gen 1 Mobile | 17.931 ms | 0 - 303 MB | NPU |
| encoder | QNN_DLC | float | Qualcomm® Dragonwing™ IQ-8275 | 13.597 ms | 2 - 13 MB | NPU |
| encoder | QNN_DLC | float | Qualcomm® Dragonwing™ QCS8550 (Proxy) | 10.93 ms | 2 - 157 MB | NPU |
| encoder | QNN_DLC | float | Qualcomm® SA8650P | 14.024 ms | 2 - 108 MB | NPU |
| encoder | QNN_DLC | float | Qualcomm® SA8255P | 14.024 ms | 2 - 108 MB | NPU |
| encoder | QNN_DLC | float | Qualcomm® QCS8450 | 17.931 ms | 0 - 303 MB | NPU |
| encoder | QNN_DLC | float | Qualcomm® Dragonwing™ IQ-9075 | 13.328 ms | 2 - 12 MB | NPU |
| encoder | QNN_DLC | float | Qualcomm® Dragonwing™ IQ-X7181 | 11.705 ms | 2 - 2 MB | NPU |
| encoder | QNN_DLC | float | Qualcomm® Dragonwing™ Q-8750 | 5.263 ms | 1 - 112 MB | NPU |
| encoder | QNN_DLC | float | Qualcomm® SA7255P | 36.097 ms | 2 - 108 MB | NPU |
| encoder | QNN_DLC | float | Qualcomm® SA8295P | 18.992 ms | 2 - 221 MB | NPU |
| encoder | TFLITE | float | Snapdragon® 8 Elite Gen 5 For Galaxy Mobile | 4.067 ms | 0 - 105 MB | NPU |
| encoder | TFLITE | float | Snapdragon® 8 Elite For Galaxy Mobile | 5.007 ms | 5 - 115 MB | NPU |
| encoder | TFLITE | float | Snapdragon® 8 Gen 3 Mobile | 7.365 ms | 5 - 201 MB | NPU |
| encoder | TFLITE | float | Snapdragon® 8 Gen 1 Mobile | 17.221 ms | 5 - 303 MB | NPU |
| encoder | TFLITE | float | Qualcomm® Dragonwing™ IQ-8275 | 13.23 ms | 7 - 67 MB | NPU |
| encoder | TFLITE | float | Qualcomm® Dragonwing™ QCS8550 (Proxy) | 10.284 ms | 7 - 9 MB | NPU |
| encoder | TFLITE | float | Qualcomm® SA8650P | 13.479 ms | 7 - 111 MB | NPU |
| encoder | TFLITE | float | Qualcomm® SA8255P | 13.479 ms | 7 - 111 MB | NPU |
| encoder | TFLITE | float | Qualcomm® QCS8450 | 17.221 ms | 5 - 303 MB | NPU |
| encoder | TFLITE | float | Qualcomm® Dragonwing™ IQ-9075 | 12.79 ms | 6 - 66 MB | NPU |
| encoder | TFLITE | float | Qualcomm® Dragonwing™ Q-8750 | 5.007 ms | 5 - 115 MB | NPU |
| encoder | TFLITE | float | Qualcomm® SA8295P | 18.385 ms | 7 - 222 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.
