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6 |
+
pipeline_tag: image-to-text
|
| 7 |
+
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+

|
| 11 |
+
|
| 12 |
+
# EasyOCR: Optimized for Mobile Deployment
|
| 13 |
+
## Ready-to-use OCR with 80+ supported languages and all popular writing scripts
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
EasyOCR is a machine learning model that can recognize text in images. It supports 80+ supported languages and all popular writing scripts.
|
| 17 |
+
|
| 18 |
+
This model is an implementation of EasyOCR found [here](https://github.com/JaidedAI/EasyOCR).
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
This repository provides scripts to run EasyOCR on Qualcomm® devices.
|
| 22 |
+
More details on model performance across various devices, can be found
|
| 23 |
+
[here](https://aihub.qualcomm.com/models/easyocr).
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
### Model Details
|
| 27 |
+
|
| 28 |
+
- **Model Type:** Image to text
|
| 29 |
+
- **Model Stats:**
|
| 30 |
+
- Model checkpoint: easyocr-small-stage1
|
| 31 |
+
- Input resolution: 384x384
|
| 32 |
+
- Number of parameters (EasyOCRDetector): 20.8M
|
| 33 |
+
- Model size (EasyOCRDetector): 79.2 MB
|
| 34 |
+
- Number of parameters (EasyOCRRecognizer): 3.84M
|
| 35 |
+
- Model size (EasyOCRRecognizer): 14.7 MB
|
| 36 |
+
|
| 37 |
+
| Model | Device | Chipset | Target Runtime | Inference Time (ms) | Peak Memory Range (MB) | Precision | Primary Compute Unit | Target Model
|
| 38 |
+
|---|---|---|---|---|---|---|---|---|
|
| 39 |
+
| EasyOCRDetector | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 | TFLITE | 41.189 ms | 0 - 136 MB | FP16 | NPU | [EasyOCR.tflite](https://huggingface.co/qualcomm/EasyOCR/blob/main/EasyOCRDetector.tflite) |
|
| 40 |
+
| EasyOCRDetector | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 | QNN | 39.017 ms | 6 - 9 MB | FP16 | NPU | [EasyOCR.so](https://huggingface.co/qualcomm/EasyOCR/blob/main/EasyOCRDetector.so) |
|
| 41 |
+
| EasyOCRDetector | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 | ONNX | 40.015 ms | 34 - 181 MB | FP16 | NPU | [EasyOCR.onnx](https://huggingface.co/qualcomm/EasyOCR/blob/main/EasyOCRDetector.onnx) |
|
| 42 |
+
| EasyOCRDetector | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 | TFLITE | 30.181 ms | 14 - 45 MB | FP16 | NPU | [EasyOCR.tflite](https://huggingface.co/qualcomm/EasyOCR/blob/main/EasyOCRDetector.tflite) |
|
| 43 |
+
| EasyOCRDetector | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 | QNN | 29.323 ms | 6 - 25 MB | FP16 | NPU | [EasyOCR.so](https://huggingface.co/qualcomm/EasyOCR/blob/main/EasyOCRDetector.so) |
|
| 44 |
+
| EasyOCRDetector | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 | ONNX | 29.584 ms | 38 - 75 MB | FP16 | NPU | [EasyOCR.onnx](https://huggingface.co/qualcomm/EasyOCR/blob/main/EasyOCRDetector.onnx) |
|
| 45 |
+
| EasyOCRDetector | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite | TFLITE | 28.753 ms | 15 - 45 MB | FP16 | NPU | [EasyOCR.tflite](https://huggingface.co/qualcomm/EasyOCR/blob/main/EasyOCRDetector.tflite) |
|
| 46 |
+
| EasyOCRDetector | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite | QNN | 24.26 ms | 6 - 36 MB | FP16 | NPU | Use Export Script |
|
| 47 |
+
| EasyOCRDetector | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite | ONNX | 28.097 ms | 43 - 78 MB | FP16 | NPU | [EasyOCR.onnx](https://huggingface.co/qualcomm/EasyOCR/blob/main/EasyOCRDetector.onnx) |
|
| 48 |
+
| EasyOCRDetector | SA7255P ADP | SA7255P | TFLITE | 2113.678 ms | 3 - 28 MB | FP16 | NPU | [EasyOCR.tflite](https://huggingface.co/qualcomm/EasyOCR/blob/main/EasyOCRDetector.tflite) |
|
| 49 |
+
| EasyOCRDetector | SA7255P ADP | SA7255P | QNN | 2111.684 ms | 0 - 8 MB | FP16 | NPU | Use Export Script |
|
| 50 |
+
| EasyOCRDetector | SA8255 (Proxy) | SA8255P Proxy | TFLITE | 41.731 ms | 0 - 97 MB | FP16 | NPU | [EasyOCR.tflite](https://huggingface.co/qualcomm/EasyOCR/blob/main/EasyOCRDetector.tflite) |
|
| 51 |
+
| EasyOCRDetector | SA8255 (Proxy) | SA8255P Proxy | QNN | 38.998 ms | 6 - 8 MB | FP16 | NPU | Use Export Script |
|
| 52 |
+
| EasyOCRDetector | SA8295P ADP | SA8295P | TFLITE | 78.45 ms | 16 - 42 MB | FP16 | NPU | [EasyOCR.tflite](https://huggingface.co/qualcomm/EasyOCR/blob/main/EasyOCRDetector.tflite) |
|
| 53 |
+
| EasyOCRDetector | SA8295P ADP | SA8295P | QNN | 76.549 ms | 0 - 11 MB | FP16 | NPU | Use Export Script |
|
| 54 |
+
| EasyOCRDetector | SA8650 (Proxy) | SA8650P Proxy | TFLITE | 42.824 ms | 0 - 145 MB | FP16 | NPU | [EasyOCR.tflite](https://huggingface.co/qualcomm/EasyOCR/blob/main/EasyOCRDetector.tflite) |
|
| 55 |
+
| EasyOCRDetector | SA8650 (Proxy) | SA8650P Proxy | QNN | 40.764 ms | 6 - 8 MB | FP16 | NPU | Use Export Script |
|
| 56 |
+
| EasyOCRDetector | SA8775P ADP | SA8775P | TFLITE | 88.536 ms | 16 - 41 MB | FP16 | NPU | [EasyOCR.tflite](https://huggingface.co/qualcomm/EasyOCR/blob/main/EasyOCRDetector.tflite) |
|
| 57 |
+
| EasyOCRDetector | SA8775P ADP | SA8775P | QNN | 86.522 ms | 1 - 9 MB | FP16 | NPU | Use Export Script |
|
| 58 |
+
| EasyOCRDetector | QCS8275 (Proxy) | QCS8275 Proxy | TFLITE | 2113.678 ms | 3 - 28 MB | FP16 | NPU | [EasyOCR.tflite](https://huggingface.co/qualcomm/EasyOCR/blob/main/EasyOCRDetector.tflite) |
|
| 59 |
+
| EasyOCRDetector | QCS8275 (Proxy) | QCS8275 Proxy | QNN | 2111.684 ms | 0 - 8 MB | FP16 | NPU | Use Export Script |
|
| 60 |
+
| EasyOCRDetector | QCS8550 (Proxy) | QCS8550 Proxy | TFLITE | 41.678 ms | 0 - 126 MB | FP16 | NPU | [EasyOCR.tflite](https://huggingface.co/qualcomm/EasyOCR/blob/main/EasyOCRDetector.tflite) |
|
| 61 |
+
| EasyOCRDetector | QCS8550 (Proxy) | QCS8550 Proxy | QNN | 39.278 ms | 6 - 8 MB | FP16 | NPU | Use Export Script |
|
| 62 |
+
| EasyOCRDetector | QCS9075 (Proxy) | QCS9075 Proxy | TFLITE | 88.536 ms | 16 - 41 MB | FP16 | NPU | [EasyOCR.tflite](https://huggingface.co/qualcomm/EasyOCR/blob/main/EasyOCRDetector.tflite) |
|
| 63 |
+
| EasyOCRDetector | QCS9075 (Proxy) | QCS9075 Proxy | QNN | 86.522 ms | 1 - 9 MB | FP16 | NPU | Use Export Script |
|
| 64 |
+
| EasyOCRDetector | QCS8450 (Proxy) | QCS8450 Proxy | TFLITE | 80.295 ms | 16 - 48 MB | FP16 | NPU | [EasyOCR.tflite](https://huggingface.co/qualcomm/EasyOCR/blob/main/EasyOCRDetector.tflite) |
|
| 65 |
+
| EasyOCRDetector | QCS8450 (Proxy) | QCS8450 Proxy | QNN | 69.9 ms | 6 - 37 MB | FP16 | NPU | Use Export Script |
|
| 66 |
+
| EasyOCRDetector | Snapdragon X Elite CRD | Snapdragon® X Elite | QNN | 39.87 ms | 6 - 6 MB | FP16 | NPU | Use Export Script |
|
| 67 |
+
| EasyOCRDetector | Snapdragon X Elite CRD | Snapdragon® X Elite | ONNX | 41.319 ms | 66 - 66 MB | FP16 | NPU | [EasyOCR.onnx](https://huggingface.co/qualcomm/EasyOCR/blob/main/EasyOCRDetector.onnx) |
|
| 68 |
+
| EasyOCRRecognizer | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 | TFLITE | 109.812 ms | 6 - 8 MB | FP32 | CPU | [EasyOCR.tflite](https://huggingface.co/qualcomm/EasyOCR/blob/main/EasyOCRRecognizer.tflite) |
|
| 69 |
+
| EasyOCRRecognizer | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 | QNN | 20.483 ms | 0 - 3 MB | FP16 | NPU | [EasyOCR.so](https://huggingface.co/qualcomm/EasyOCR/blob/main/EasyOCRRecognizer.so) |
|
| 70 |
+
| EasyOCRRecognizer | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 | ONNX | 21.731 ms | 0 - 24 MB | FP16 | NPU | [EasyOCR.onnx](https://huggingface.co/qualcomm/EasyOCR/blob/main/EasyOCRRecognizer.onnx) |
|
| 71 |
+
| EasyOCRRecognizer | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 | TFLITE | 108.852 ms | 2 - 20 MB | FP32 | CPU | [EasyOCR.tflite](https://huggingface.co/qualcomm/EasyOCR/blob/main/EasyOCRRecognizer.tflite) |
|
| 72 |
+
| EasyOCRRecognizer | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 | QNN | 14.237 ms | 0 - 16 MB | FP16 | NPU | [EasyOCR.so](https://huggingface.co/qualcomm/EasyOCR/blob/main/EasyOCRRecognizer.so) |
|
| 73 |
+
| EasyOCRRecognizer | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 | ONNX | 16.212 ms | 1 - 24 MB | FP16 | NPU | [EasyOCR.onnx](https://huggingface.co/qualcomm/EasyOCR/blob/main/EasyOCRRecognizer.onnx) |
|
| 74 |
+
| EasyOCRRecognizer | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite | TFLITE | 107.149 ms | 14 - 30 MB | FP32 | CPU | [EasyOCR.tflite](https://huggingface.co/qualcomm/EasyOCR/blob/main/EasyOCRRecognizer.tflite) |
|
| 75 |
+
| EasyOCRRecognizer | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite | QNN | 20.63 ms | 0 - 346 MB | FP16 | NPU | Use Export Script |
|
| 76 |
+
| EasyOCRRecognizer | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite | ONNX | 17.677 ms | 0 - 18 MB | FP16 | NPU | [EasyOCR.onnx](https://huggingface.co/qualcomm/EasyOCR/blob/main/EasyOCRRecognizer.onnx) |
|
| 77 |
+
| EasyOCRRecognizer | SA7255P ADP | SA7255P | TFLITE | 565.404 ms | 9 - 17 MB | FP32 | CPU | [EasyOCR.tflite](https://huggingface.co/qualcomm/EasyOCR/blob/main/EasyOCRRecognizer.tflite) |
|
| 78 |
+
| EasyOCRRecognizer | SA7255P ADP | SA7255P | QNN | 285.155 ms | 0 - 8 MB | FP16 | NPU | Use Export Script |
|
| 79 |
+
| EasyOCRRecognizer | SA8255 (Proxy) | SA8255P Proxy | TFLITE | 124.344 ms | 9 - 11 MB | FP32 | CPU | [EasyOCR.tflite](https://huggingface.co/qualcomm/EasyOCR/blob/main/EasyOCRRecognizer.tflite) |
|
| 80 |
+
| EasyOCRRecognizer | SA8255 (Proxy) | SA8255P Proxy | QNN | 20.321 ms | 0 - 3 MB | FP16 | NPU | Use Export Script |
|
| 81 |
+
| EasyOCRRecognizer | SA8295P ADP | SA8295P | TFLITE | 214.709 ms | 8 - 18 MB | FP32 | CPU | [EasyOCR.tflite](https://huggingface.co/qualcomm/EasyOCR/blob/main/EasyOCRRecognizer.tflite) |
|
| 82 |
+
| EasyOCRRecognizer | SA8295P ADP | SA8295P | QNN | 30.834 ms | 0 - 12 MB | FP16 | NPU | Use Export Script |
|
| 83 |
+
| EasyOCRRecognizer | SA8650 (Proxy) | SA8650P Proxy | TFLITE | 101.784 ms | 7 - 11 MB | FP32 | CPU | [EasyOCR.tflite](https://huggingface.co/qualcomm/EasyOCR/blob/main/EasyOCRRecognizer.tflite) |
|
| 84 |
+
| EasyOCRRecognizer | SA8650 (Proxy) | SA8650P Proxy | QNN | 20.407 ms | 0 - 3 MB | FP16 | NPU | Use Export Script |
|
| 85 |
+
| EasyOCRRecognizer | SA8775P ADP | SA8775P | TFLITE | 415.153 ms | 6 - 14 MB | FP32 | CPU | [EasyOCR.tflite](https://huggingface.co/qualcomm/EasyOCR/blob/main/EasyOCRRecognizer.tflite) |
|
| 86 |
+
| EasyOCRRecognizer | SA8775P ADP | SA8775P | QNN | 29.021 ms | 0 - 7 MB | FP16 | NPU | Use Export Script |
|
| 87 |
+
| EasyOCRRecognizer | QCS8275 (Proxy) | QCS8275 Proxy | TFLITE | 565.404 ms | 9 - 17 MB | FP32 | CPU | [EasyOCR.tflite](https://huggingface.co/qualcomm/EasyOCR/blob/main/EasyOCRRecognizer.tflite) |
|
| 88 |
+
| EasyOCRRecognizer | QCS8275 (Proxy) | QCS8275 Proxy | QNN | 285.155 ms | 0 - 8 MB | FP16 | NPU | Use Export Script |
|
| 89 |
+
| EasyOCRRecognizer | QCS8550 (Proxy) | QCS8550 Proxy | TFLITE | 108.193 ms | 7 - 10 MB | FP32 | CPU | [EasyOCR.tflite](https://huggingface.co/qualcomm/EasyOCR/blob/main/EasyOCRRecognizer.tflite) |
|
| 90 |
+
| EasyOCRRecognizer | QCS8550 (Proxy) | QCS8550 Proxy | QNN | 20.315 ms | 0 - 3 MB | FP16 | NPU | Use Export Script |
|
| 91 |
+
| EasyOCRRecognizer | QCS9075 (Proxy) | QCS9075 Proxy | TFLITE | 415.153 ms | 6 - 14 MB | FP32 | CPU | [EasyOCR.tflite](https://huggingface.co/qualcomm/EasyOCR/blob/main/EasyOCRRecognizer.tflite) |
|
| 92 |
+
| EasyOCRRecognizer | QCS9075 (Proxy) | QCS9075 Proxy | QNN | 29.021 ms | 0 - 7 MB | FP16 | NPU | Use Export Script |
|
| 93 |
+
| EasyOCRRecognizer | QCS8450 (Proxy) | QCS8450 Proxy | TFLITE | 210.333 ms | 9 - 25 MB | FP32 | CPU | [EasyOCR.tflite](https://huggingface.co/qualcomm/EasyOCR/blob/main/EasyOCRRecognizer.tflite) |
|
| 94 |
+
| EasyOCRRecognizer | QCS8450 (Proxy) | QCS8450 Proxy | QNN | 34.309 ms | 0 - 151 MB | FP16 | NPU | Use Export Script |
|
| 95 |
+
| EasyOCRRecognizer | Snapdragon X Elite CRD | Snapdragon® X Elite | QNN | 21.364 ms | 0 - 0 MB | FP16 | NPU | Use Export Script |
|
| 96 |
+
| EasyOCRRecognizer | Snapdragon X Elite CRD | Snapdragon® X Elite | ONNX | 19.37 ms | 0 - 0 MB | FP16 | NPU | [EasyOCR.onnx](https://huggingface.co/qualcomm/EasyOCR/blob/main/EasyOCRRecognizer.onnx) |
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
## Installation
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
Install the package via pip:
|
| 105 |
+
```bash
|
| 106 |
+
pip install "qai-hub-models[easyocr]"
|
| 107 |
+
```
|
| 108 |
+
|
| 109 |
+
|
| 110 |
+
## Configure Qualcomm® AI Hub to run this model on a cloud-hosted device
|
| 111 |
+
|
| 112 |
+
Sign-in to [Qualcomm® AI Hub](https://app.aihub.qualcomm.com/) with your
|
| 113 |
+
Qualcomm® ID. Once signed in navigate to `Account -> Settings -> API Token`.
|
| 114 |
+
|
| 115 |
+
With this API token, you can configure your client to run models on the cloud
|
| 116 |
+
hosted devices.
|
| 117 |
+
```bash
|
| 118 |
+
qai-hub configure --api_token API_TOKEN
|
| 119 |
+
```
|
| 120 |
+
Navigate to [docs](https://app.aihub.qualcomm.com/docs/) for more information.
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
## Demo off target
|
| 125 |
+
|
| 126 |
+
The package contains a simple end-to-end demo that downloads pre-trained
|
| 127 |
+
weights and runs this model on a sample input.
|
| 128 |
+
|
| 129 |
+
```bash
|
| 130 |
+
python -m qai_hub_models.models.easyocr.demo
|
| 131 |
+
```
|
| 132 |
+
|
| 133 |
+
The above demo runs a reference implementation of pre-processing, model
|
| 134 |
+
inference, and post processing.
|
| 135 |
+
|
| 136 |
+
**NOTE**: If you want running in a Jupyter Notebook or Google Colab like
|
| 137 |
+
environment, please add the following to your cell (instead of the above).
|
| 138 |
+
```
|
| 139 |
+
%run -m qai_hub_models.models.easyocr.demo
|
| 140 |
+
```
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
### Run model on a cloud-hosted device
|
| 144 |
+
|
| 145 |
+
In addition to the demo, you can also run the model on a cloud-hosted Qualcomm®
|
| 146 |
+
device. This script does the following:
|
| 147 |
+
* Performance check on-device on a cloud-hosted device
|
| 148 |
+
* Downloads compiled assets that can be deployed on-device for Android.
|
| 149 |
+
* Accuracy check between PyTorch and on-device outputs.
|
| 150 |
+
|
| 151 |
+
```bash
|
| 152 |
+
python -m qai_hub_models.models.easyocr.export
|
| 153 |
+
```
|
| 154 |
+
```
|
| 155 |
+
Profiling Results
|
| 156 |
+
------------------------------------------------------------
|
| 157 |
+
EasyOCRDetector
|
| 158 |
+
Device : Samsung Galaxy S23 (13)
|
| 159 |
+
Runtime : TFLITE
|
| 160 |
+
Estimated inference time (ms) : 41.2
|
| 161 |
+
Estimated peak memory usage (MB): [0, 136]
|
| 162 |
+
Total # Ops : 42
|
| 163 |
+
Compute Unit(s) : NPU (42 ops)
|
| 164 |
+
|
| 165 |
+
------------------------------------------------------------
|
| 166 |
+
EasyOCRRecognizer
|
| 167 |
+
Device : Samsung Galaxy S23 (13)
|
| 168 |
+
Runtime : TFLITE
|
| 169 |
+
Estimated inference time (ms) : 109.8
|
| 170 |
+
Estimated peak memory usage (MB): [6, 8]
|
| 171 |
+
Total # Ops : 136
|
| 172 |
+
Compute Unit(s) : CPU (136 ops)
|
| 173 |
+
```
|
| 174 |
+
|
| 175 |
+
|
| 176 |
+
## How does this work?
|
| 177 |
+
|
| 178 |
+
This [export script](https://aihub.qualcomm.com/models/easyocr/qai_hub_models/models/EasyOCR/export.py)
|
| 179 |
+
leverages [Qualcomm® AI Hub](https://aihub.qualcomm.com/) to optimize, validate, and deploy this model
|
| 180 |
+
on-device. Lets go through each step below in detail:
|
| 181 |
+
|
| 182 |
+
Step 1: **Compile model for on-device deployment**
|
| 183 |
+
|
| 184 |
+
To compile a PyTorch model for on-device deployment, we first trace the model
|
| 185 |
+
in memory using the `jit.trace` and then call the `submit_compile_job` API.
|
| 186 |
+
|
| 187 |
+
```python
|
| 188 |
+
import torch
|
| 189 |
+
|
| 190 |
+
import qai_hub as hub
|
| 191 |
+
from qai_hub_models.models.easyocr import Model
|
| 192 |
+
|
| 193 |
+
# Load the model
|
| 194 |
+
model = Model.from_pretrained()
|
| 195 |
+
detector_model = model.detector
|
| 196 |
+
recognizer_model = model.recognizer
|
| 197 |
+
|
| 198 |
+
# Device
|
| 199 |
+
device = hub.Device("Samsung Galaxy S23")
|
| 200 |
+
|
| 201 |
+
# Trace model
|
| 202 |
+
detector_input_shape = detector_model.get_input_spec()
|
| 203 |
+
detector_sample_inputs = detector_model.sample_inputs()
|
| 204 |
+
|
| 205 |
+
traced_detector_model = torch.jit.trace(detector_model, [torch.tensor(data[0]) for _, data in detector_sample_inputs.items()])
|
| 206 |
+
|
| 207 |
+
# Compile model on a specific device
|
| 208 |
+
detector_compile_job = hub.submit_compile_job(
|
| 209 |
+
model=traced_detector_model ,
|
| 210 |
+
device=device,
|
| 211 |
+
input_specs=detector_model.get_input_spec(),
|
| 212 |
+
)
|
| 213 |
+
|
| 214 |
+
# Get target model to run on-device
|
| 215 |
+
detector_target_model = detector_compile_job.get_target_model()
|
| 216 |
+
# Trace model
|
| 217 |
+
recognizer_input_shape = recognizer_model.get_input_spec()
|
| 218 |
+
recognizer_sample_inputs = recognizer_model.sample_inputs()
|
| 219 |
+
|
| 220 |
+
traced_recognizer_model = torch.jit.trace(recognizer_model, [torch.tensor(data[0]) for _, data in recognizer_sample_inputs.items()])
|
| 221 |
+
|
| 222 |
+
# Compile model on a specific device
|
| 223 |
+
recognizer_compile_job = hub.submit_compile_job(
|
| 224 |
+
model=traced_recognizer_model ,
|
| 225 |
+
device=device,
|
| 226 |
+
input_specs=recognizer_model.get_input_spec(),
|
| 227 |
+
)
|
| 228 |
+
|
| 229 |
+
# Get target model to run on-device
|
| 230 |
+
recognizer_target_model = recognizer_compile_job.get_target_model()
|
| 231 |
+
|
| 232 |
+
```
|
| 233 |
+
|
| 234 |
+
|
| 235 |
+
Step 2: **Performance profiling on cloud-hosted device**
|
| 236 |
+
|
| 237 |
+
After compiling models from step 1. Models can be profiled model on-device using the
|
| 238 |
+
`target_model`. Note that this scripts runs the model on a device automatically
|
| 239 |
+
provisioned in the cloud. Once the job is submitted, you can navigate to a
|
| 240 |
+
provided job URL to view a variety of on-device performance metrics.
|
| 241 |
+
```python
|
| 242 |
+
detector_profile_job = hub.submit_profile_job(
|
| 243 |
+
model=detector_target_model,
|
| 244 |
+
device=device,
|
| 245 |
+
)
|
| 246 |
+
recognizer_profile_job = hub.submit_profile_job(
|
| 247 |
+
model=recognizer_target_model,
|
| 248 |
+
device=device,
|
| 249 |
+
)
|
| 250 |
+
|
| 251 |
+
```
|
| 252 |
+
|
| 253 |
+
Step 3: **Verify on-device accuracy**
|
| 254 |
+
|
| 255 |
+
To verify the accuracy of the model on-device, you can run on-device inference
|
| 256 |
+
on sample input data on the same cloud hosted device.
|
| 257 |
+
```python
|
| 258 |
+
detector_input_data = detector_model.sample_inputs()
|
| 259 |
+
detector_inference_job = hub.submit_inference_job(
|
| 260 |
+
model=detector_target_model,
|
| 261 |
+
device=device,
|
| 262 |
+
inputs=detector_input_data,
|
| 263 |
+
)
|
| 264 |
+
detector_inference_job.download_output_data()
|
| 265 |
+
recognizer_input_data = recognizer_model.sample_inputs()
|
| 266 |
+
recognizer_inference_job = hub.submit_inference_job(
|
| 267 |
+
model=recognizer_target_model,
|
| 268 |
+
device=device,
|
| 269 |
+
inputs=recognizer_input_data,
|
| 270 |
+
)
|
| 271 |
+
recognizer_inference_job.download_output_data()
|
| 272 |
+
|
| 273 |
+
```
|
| 274 |
+
With the output of the model, you can compute like PSNR, relative errors or
|
| 275 |
+
spot check the output with expected output.
|
| 276 |
+
|
| 277 |
+
**Note**: This on-device profiling and inference requires access to Qualcomm®
|
| 278 |
+
AI Hub. [Sign up for access](https://myaccount.qualcomm.com/signup).
|
| 279 |
+
|
| 280 |
+
|
| 281 |
+
|
| 282 |
+
|
| 283 |
+
## Deploying compiled model to Android
|
| 284 |
+
|
| 285 |
+
|
| 286 |
+
The models can be deployed using multiple runtimes:
|
| 287 |
+
- TensorFlow Lite (`.tflite` export): [This
|
| 288 |
+
tutorial](https://www.tensorflow.org/lite/android/quickstart) provides a
|
| 289 |
+
guide to deploy the .tflite model in an Android application.
|
| 290 |
+
|
| 291 |
+
|
| 292 |
+
- QNN (`.so` export ): This [sample
|
| 293 |
+
app](https://docs.qualcomm.com/bundle/publicresource/topics/80-63442-50/sample_app.html)
|
| 294 |
+
provides instructions on how to use the `.so` shared library in an Android application.
|
| 295 |
+
|
| 296 |
+
|
| 297 |
+
## View on Qualcomm® AI Hub
|
| 298 |
+
Get more details on EasyOCR's performance across various devices [here](https://aihub.qualcomm.com/models/easyocr).
|
| 299 |
+
Explore all available models on [Qualcomm® AI Hub](https://aihub.qualcomm.com/)
|
| 300 |
+
|
| 301 |
+
|
| 302 |
+
## License
|
| 303 |
+
* The license for the original implementation of EasyOCR can be found
|
| 304 |
+
[here](https://github.com/JaidedAI/EasyOCR/blob/master/LICENSE).
|
| 305 |
+
* The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf)
|
| 306 |
+
|
| 307 |
+
|
| 308 |
+
|
| 309 |
+
## References
|
| 310 |
+
* [None](None)
|
| 311 |
+
* [Source Model Implementation](https://github.com/JaidedAI/EasyOCR)
|
| 312 |
+
|
| 313 |
+
|
| 314 |
+
|
| 315 |
+
## Community
|
| 316 |
+
* Join [our AI Hub Slack community](https://aihub.qualcomm.com/community/slack) to collaborate, post questions and learn more about on-device AI.
|
| 317 |
+
* For questions or feedback please [reach out to us](mailto:[email protected]).
|
| 318 |
+
|
| 319 |
+
|