Image-to-Text
PyTorch
android

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.27.1 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.258 ms 7 - 7 MB NPU
decoder ONNX float Snapdragon® X Elite 2.061 ms 68 - 68 MB NPU
decoder ONNX float Snapdragon® 8 Gen 3 Mobile 1.452 ms 0 - 283 MB NPU
decoder ONNX float Snapdragon® 8 Gen 1 Mobile 2.746 ms 1 - 218 MB NPU
decoder ONNX float Qualcomm® Dragonwing™ QCS8550 (Proxy) 2.12 ms 3 - 238 MB NPU
decoder ONNX float Qualcomm® QCS8450 2.746 ms 1 - 218 MB NPU
decoder ONNX float Qualcomm® Dragonwing™ IQ-9075 2.759 ms 7 - 16 MB NPU
decoder ONNX float Qualcomm® Dragonwing™ IQ-X7181 2.061 ms 68 - 68 MB NPU
decoder ONNX float Qualcomm® Dragonwing™ Q-8750 1.288 ms 0 - 191 MB NPU
decoder ONNX float Snapdragon® 8 Elite Mobile 1.288 ms 0 - 191 MB NPU
decoder ONNX float Snapdragon® 8 Elite Gen 5 Mobile 1.172 ms 1 - 177 MB NPU
decoder QNN_DLC float Snapdragon® X2 Elite 1.57 ms 7 - 7 MB NPU
decoder QNN_DLC float Snapdragon® X Elite 2.228 ms 7 - 7 MB NPU
decoder QNN_DLC float Snapdragon® 8 Gen 3 Mobile 1.368 ms 0 - 275 MB NPU
decoder QNN_DLC float Snapdragon® 8 Gen 1 Mobile 2.698 ms 2 - 217 MB NPU
decoder QNN_DLC float Qualcomm® Dragonwing™ QCS8275 4.177 ms 5 - 105 MB NPU
decoder QNN_DLC float Qualcomm® Dragonwing™ QCS8550 (Proxy) 2.003 ms 4 - 6 MB NPU
decoder QNN_DLC float Qualcomm® SA8775P 2.853 ms 5 - 106 MB NPU
decoder QNN_DLC float Qualcomm® SA8650P 2.853 ms 5 - 106 MB NPU
decoder QNN_DLC float Qualcomm® SA8255P 2.853 ms 5 - 106 MB NPU
decoder QNN_DLC float Qualcomm® QCS8450 2.698 ms 2 - 217 MB NPU
decoder QNN_DLC float Qualcomm® Dragonwing™ IQ-9075 2.629 ms 7 - 15 MB NPU
decoder QNN_DLC float Qualcomm® Dragonwing™ IQ-X7181 2.228 ms 7 - 7 MB NPU
decoder QNN_DLC float Qualcomm® Dragonwing™ Q-8750 1.223 ms 0 - 186 MB NPU
decoder QNN_DLC float Qualcomm® SA7255P 4.177 ms 5 - 105 MB NPU
decoder QNN_DLC float Qualcomm® SA8295P 2.602 ms 7 - 49 MB NPU
decoder QNN_DLC float Snapdragon® 8 Elite Mobile 1.223 ms 0 - 186 MB NPU
decoder QNN_DLC float Snapdragon® 8 Elite Gen 5 Mobile 1.151 ms 1 - 175 MB NPU
decoder TFLITE float Snapdragon® 8 Gen 3 Mobile 1.395 ms 0 - 280 MB NPU
decoder TFLITE float Snapdragon® 8 Gen 1 Mobile 2.442 ms 0 - 218 MB NPU
decoder TFLITE float Qualcomm® Dragonwing™ QCS8275 4.237 ms 0 - 103 MB NPU
decoder TFLITE float Qualcomm® Dragonwing™ QCS8550 (Proxy) 1.96 ms 0 - 3 MB NPU
decoder TFLITE float Qualcomm® SA8775P 2.865 ms 0 - 103 MB NPU
decoder TFLITE float Qualcomm® SA8650P 2.865 ms 0 - 103 MB NPU
decoder TFLITE float Qualcomm® SA8255P 2.865 ms 0 - 103 MB NPU
decoder TFLITE float Qualcomm® QCS8450 2.442 ms 0 - 218 MB NPU
decoder TFLITE float Qualcomm® Dragonwing™ IQ-9075 2.585 ms 0 - 83 MB NPU
decoder TFLITE float Qualcomm® Dragonwing™ Q-8750 1.243 ms 0 - 192 MB NPU
decoder TFLITE float Qualcomm® SA7255P 4.237 ms 0 - 103 MB NPU
decoder TFLITE float Qualcomm® SA8295P 2.647 ms 0 - 42 MB NPU
decoder TFLITE float Snapdragon® 8 Elite Mobile 1.243 ms 0 - 192 MB NPU
decoder TFLITE float Snapdragon® 8 Elite Gen 5 Mobile 1.127 ms 0 - 172 MB NPU
encoder ONNX float Snapdragon® X2 Elite 4.546 ms 16 - 16 MB NPU
encoder ONNX float Snapdragon® X Elite 11.355 ms 48 - 48 MB NPU
encoder ONNX float Snapdragon® 8 Gen 3 Mobile 7.819 ms 0 - 198 MB NPU
encoder ONNX float Snapdragon® 8 Gen 1 Mobile 19.911 ms 0 - 315 MB NPU
encoder ONNX float Qualcomm® Dragonwing™ QCS8550 (Proxy) 10.914 ms 0 - 57 MB NPU
encoder ONNX float Qualcomm® QCS8450 19.911 ms 0 - 315 MB NPU
encoder ONNX float Qualcomm® Dragonwing™ IQ-9075 13.326 ms 15 - 19 MB NPU
encoder ONNX float Qualcomm® Dragonwing™ IQ-X7181 11.355 ms 48 - 48 MB NPU
encoder ONNX float Qualcomm® Dragonwing™ Q-8750 5.303 ms 16 - 140 MB NPU
encoder ONNX float Snapdragon® 8 Elite Mobile 5.303 ms 16 - 140 MB NPU
encoder ONNX float Snapdragon® 8 Elite Gen 5 Mobile 4.146 ms 0 - 124 MB NPU
encoder QNN_DLC float Snapdragon® X2 Elite 5.17 ms 2 - 2 MB NPU
encoder QNN_DLC float Snapdragon® X Elite 12.208 ms 2 - 2 MB NPU
encoder QNN_DLC float Snapdragon® 8 Gen 3 Mobile 8.013 ms 0 - 188 MB NPU
encoder QNN_DLC float Snapdragon® 8 Gen 1 Mobile 19.533 ms 0 - 307 MB NPU
encoder QNN_DLC float Qualcomm® Dragonwing™ QCS8275 37.065 ms 2 - 107 MB NPU
encoder QNN_DLC float Qualcomm® Dragonwing™ QCS8550 (Proxy) 11.299 ms 2 - 176 MB NPU
encoder QNN_DLC float Qualcomm® SA8775P 14.043 ms 2 - 109 MB NPU
encoder QNN_DLC float Qualcomm® SA8650P 14.043 ms 2 - 109 MB NPU
encoder QNN_DLC float Qualcomm® SA8255P 14.043 ms 2 - 109 MB NPU
encoder QNN_DLC float Qualcomm® QCS8450 19.533 ms 0 - 307 MB NPU
encoder QNN_DLC float Qualcomm® Dragonwing™ IQ-9075 14.564 ms 2 - 12 MB NPU
encoder QNN_DLC float Qualcomm® Dragonwing™ IQ-X7181 12.208 ms 2 - 2 MB NPU
encoder QNN_DLC float Qualcomm® Dragonwing™ Q-8750 5.444 ms 2 - 114 MB NPU
encoder QNN_DLC float Qualcomm® SA7255P 37.065 ms 2 - 107 MB NPU
encoder QNN_DLC float Qualcomm® SA8295P 19.696 ms 2 - 235 MB NPU
encoder QNN_DLC float Snapdragon® 8 Elite Mobile 5.444 ms 2 - 114 MB NPU
encoder QNN_DLC float Snapdragon® 8 Elite Gen 5 Mobile 4.345 ms 2 - 115 MB NPU
encoder TFLITE float Snapdragon® 8 Gen 3 Mobile 7.708 ms 5 - 194 MB NPU
encoder TFLITE float Snapdragon® 8 Gen 1 Mobile 19.583 ms 7 - 312 MB NPU
encoder TFLITE float Qualcomm® Dragonwing™ QCS8275 36.81 ms 7 - 119 MB NPU
encoder TFLITE float Qualcomm® Dragonwing™ QCS8550 (Proxy) 10.695 ms 7 - 9 MB NPU
encoder TFLITE float Qualcomm® SA8775P 13.5 ms 7 - 110 MB NPU
encoder TFLITE float Qualcomm® SA8650P 13.5 ms 7 - 110 MB NPU
encoder TFLITE float Qualcomm® SA8255P 13.5 ms 7 - 110 MB NPU
encoder TFLITE float Qualcomm® QCS8450 19.583 ms 7 - 312 MB NPU
encoder TFLITE float Qualcomm® Dragonwing™ IQ-9075 13.517 ms 6 - 66 MB NPU
encoder TFLITE float Qualcomm® Dragonwing™ Q-8750 5.177 ms 7 - 119 MB NPU
encoder TFLITE float Qualcomm® SA7255P 36.81 ms 7 - 119 MB NPU
encoder TFLITE float Qualcomm® SA8295P 19.131 ms 7 - 237 MB NPU
encoder TFLITE float Snapdragon® 8 Elite Mobile 5.177 ms 7 - 119 MB NPU
encoder TFLITE float Snapdragon® 8 Elite Gen 5 Mobile 4.115 ms 0 - 106 MB NPU

License

  • The license for the original implementation of TrOCR can be found here.

References

Community

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Space using qualcomm/TrOCR 1

Paper for qualcomm/TrOCR