Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
@@ -36,56 +36,55 @@ More details on model performance across various devices, can be found
|
|
36 |
|
37 |
| Model | Device | Chipset | Target Runtime | Inference Time (ms) | Peak Memory Range (MB) | Precision | Primary Compute Unit | Target Model
|
38 |
|---|---|---|---|---|---|---|---|---|
|
39 |
-
|
|
40 |
-
|
|
41 |
-
|
|
42 |
-
|
|
43 |
-
|
|
44 |
-
|
|
45 |
-
|
|
46 |
-
|
|
47 |
-
|
|
48 |
-
|
|
49 |
-
|
|
50 |
-
|
|
51 |
-
|
|
52 |
-
|
|
53 |
-
|
|
54 |
-
|
|
55 |
-
|
|
56 |
-
|
|
57 |
-
|
|
58 |
-
|
|
59 |
-
|
|
60 |
-
|
|
61 |
-
|
|
62 |
-
|
|
63 |
-
|
|
64 |
-
|
|
65 |
-
|
|
66 |
-
|
|
67 |
-
|
|
68 |
-
|
|
69 |
-
|
|
70 |
-
|
|
71 |
-
|
|
72 |
-
|
|
73 |
-
|
|
74 |
-
|
|
75 |
-
|
|
76 |
-
|
|
77 |
-
|
|
78 |
-
|
|
79 |
-
|
|
80 |
-
|
|
81 |
-
|
|
82 |
-
|
|
83 |
-
|
|
84 |
-
|
|
85 |
-
|
|
86 |
-
|
|
87 |
-
|
|
88 |
-
| TrOCRDecoder | Snapdragon X Elite CRD | Snapdragon® X Elite | ONNX | 2.74 ms | 68 - 68 MB | FP16 | NPU | [TrOCR.onnx](https://huggingface.co/qualcomm/TrOCR/blob/main/TrOCRDecoder.onnx) |
|
89 |
|
90 |
|
91 |
|
@@ -146,23 +145,23 @@ python -m qai_hub_models.models.trocr.export
|
|
146 |
```
|
147 |
```
|
148 |
Profiling Results
|
149 |
-
------------------------------------------------------------
|
150 |
-
TrOCREncoder
|
151 |
-
Device : Samsung Galaxy S23 (13)
|
152 |
-
Runtime : TFLITE
|
153 |
-
Estimated inference time (ms) : 50.1
|
154 |
-
Estimated peak memory usage (MB): [7, 31]
|
155 |
-
Total # Ops : 591
|
156 |
-
Compute Unit(s) : NPU (591 ops)
|
157 |
-
|
158 |
------------------------------------------------------------
|
159 |
TrOCRDecoder
|
160 |
Device : Samsung Galaxy S23 (13)
|
161 |
Runtime : TFLITE
|
162 |
Estimated inference time (ms) : 2.2
|
163 |
-
Estimated peak memory usage (MB): [0,
|
164 |
Total # Ops : 399
|
165 |
Compute Unit(s) : NPU (399 ops)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
```
|
167 |
|
168 |
|
@@ -185,42 +184,42 @@ from qai_hub_models.models.trocr import Model
|
|
185 |
|
186 |
# Load the model
|
187 |
model = Model.from_pretrained()
|
188 |
-
encoder_model = model.encoder
|
189 |
decoder_model = model.decoder
|
|
|
190 |
|
191 |
# Device
|
192 |
device = hub.Device("Samsung Galaxy S23")
|
193 |
|
194 |
# Trace model
|
195 |
-
|
196 |
-
|
197 |
|
198 |
-
|
199 |
|
200 |
# Compile model on a specific device
|
201 |
-
|
202 |
-
model=
|
203 |
device=device,
|
204 |
-
input_specs=
|
205 |
)
|
206 |
|
207 |
# Get target model to run on-device
|
208 |
-
|
209 |
# Trace model
|
210 |
-
|
211 |
-
|
212 |
|
213 |
-
|
214 |
|
215 |
# Compile model on a specific device
|
216 |
-
|
217 |
-
model=
|
218 |
device=device,
|
219 |
-
input_specs=
|
220 |
)
|
221 |
|
222 |
# Get target model to run on-device
|
223 |
-
|
224 |
|
225 |
```
|
226 |
|
@@ -232,14 +231,14 @@ After compiling models from step 1. Models can be profiled model on-device using
|
|
232 |
provisioned in the cloud. Once the job is submitted, you can navigate to a
|
233 |
provided job URL to view a variety of on-device performance metrics.
|
234 |
```python
|
235 |
-
encoder_profile_job = hub.submit_profile_job(
|
236 |
-
model=encoder_target_model,
|
237 |
-
device=device,
|
238 |
-
)
|
239 |
decoder_profile_job = hub.submit_profile_job(
|
240 |
model=decoder_target_model,
|
241 |
device=device,
|
242 |
)
|
|
|
|
|
|
|
|
|
243 |
|
244 |
```
|
245 |
|
@@ -248,13 +247,6 @@ Step 3: **Verify on-device accuracy**
|
|
248 |
To verify the accuracy of the model on-device, you can run on-device inference
|
249 |
on sample input data on the same cloud hosted device.
|
250 |
```python
|
251 |
-
encoder_input_data = encoder_model.sample_inputs()
|
252 |
-
encoder_inference_job = hub.submit_inference_job(
|
253 |
-
model=encoder_target_model,
|
254 |
-
device=device,
|
255 |
-
inputs=encoder_input_data,
|
256 |
-
)
|
257 |
-
encoder_inference_job.download_output_data()
|
258 |
decoder_input_data = decoder_model.sample_inputs()
|
259 |
decoder_inference_job = hub.submit_inference_job(
|
260 |
model=decoder_target_model,
|
@@ -262,6 +254,13 @@ decoder_inference_job = hub.submit_inference_job(
|
|
262 |
inputs=decoder_input_data,
|
263 |
)
|
264 |
decoder_inference_job.download_output_data()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
265 |
|
266 |
```
|
267 |
With the output of the model, you can compute like PSNR, relative errors or
|
|
|
36 |
|
37 |
| Model | Device | Chipset | Target Runtime | Inference Time (ms) | Peak Memory Range (MB) | Precision | Primary Compute Unit | Target Model
|
38 |
|---|---|---|---|---|---|---|---|---|
|
39 |
+
| TrOCRDecoder | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 | TFLITE | 2.203 ms | 0 - 143 MB | FP16 | NPU | [TrOCR.tflite](https://huggingface.co/qualcomm/TrOCR/blob/main/TrOCRDecoder.tflite) |
|
40 |
+
| TrOCRDecoder | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 | QNN | 2.367 ms | 2 - 355 MB | FP16 | NPU | [TrOCR.so](https://huggingface.co/qualcomm/TrOCR/blob/main/TrOCRDecoder.so) |
|
41 |
+
| TrOCRDecoder | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 | ONNX | 2.762 ms | 1 - 3 MB | FP16 | NPU | [TrOCR.onnx](https://huggingface.co/qualcomm/TrOCR/blob/main/TrOCRDecoder.onnx) |
|
42 |
+
| TrOCRDecoder | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 | TFLITE | 1.561 ms | 0 - 48 MB | FP16 | NPU | [TrOCR.tflite](https://huggingface.co/qualcomm/TrOCR/blob/main/TrOCRDecoder.tflite) |
|
43 |
+
| TrOCRDecoder | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 | QNN | 1.729 ms | 0 - 51 MB | FP16 | NPU | [TrOCR.so](https://huggingface.co/qualcomm/TrOCR/blob/main/TrOCRDecoder.so) |
|
44 |
+
| TrOCRDecoder | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 | ONNX | 2.1 ms | 0 - 174 MB | FP16 | NPU | [TrOCR.onnx](https://huggingface.co/qualcomm/TrOCR/blob/main/TrOCRDecoder.onnx) |
|
45 |
+
| TrOCRDecoder | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite | TFLITE | 1.451 ms | 0 - 46 MB | FP16 | NPU | [TrOCR.tflite](https://huggingface.co/qualcomm/TrOCR/blob/main/TrOCRDecoder.tflite) |
|
46 |
+
| TrOCRDecoder | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite | QNN | 1.545 ms | 0 - 46 MB | FP16 | NPU | Use Export Script |
|
47 |
+
| TrOCRDecoder | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite | ONNX | 1.88 ms | 0 - 132 MB | FP16 | NPU | [TrOCR.onnx](https://huggingface.co/qualcomm/TrOCR/blob/main/TrOCRDecoder.onnx) |
|
48 |
+
| TrOCRDecoder | QCS8550 (Proxy) | QCS8550 Proxy | TFLITE | 2.205 ms | 0 - 364 MB | FP16 | NPU | [TrOCR.tflite](https://huggingface.co/qualcomm/TrOCR/blob/main/TrOCRDecoder.tflite) |
|
49 |
+
| TrOCRDecoder | QCS8550 (Proxy) | QCS8550 Proxy | QNN | 2.25 ms | 0 - 1 MB | FP16 | NPU | Use Export Script |
|
50 |
+
| TrOCRDecoder | SA7255P ADP | SA7255P | TFLITE | 12.302 ms | 0 - 44 MB | FP16 | NPU | [TrOCR.tflite](https://huggingface.co/qualcomm/TrOCR/blob/main/TrOCRDecoder.tflite) |
|
51 |
+
| TrOCRDecoder | SA7255P ADP | SA7255P | QNN | 12.414 ms | 7 - 17 MB | FP16 | NPU | Use Export Script |
|
52 |
+
| TrOCRDecoder | SA8255 (Proxy) | SA8255P Proxy | TFLITE | 2.21 ms | 0 - 87 MB | FP16 | NPU | [TrOCR.tflite](https://huggingface.co/qualcomm/TrOCR/blob/main/TrOCRDecoder.tflite) |
|
53 |
+
| TrOCRDecoder | SA8255 (Proxy) | SA8255P Proxy | QNN | 2.316 ms | 1 - 2 MB | FP16 | NPU | Use Export Script |
|
54 |
+
| TrOCRDecoder | SA8295P ADP | SA8295P | TFLITE | 3.067 ms | 0 - 42 MB | FP16 | NPU | [TrOCR.tflite](https://huggingface.co/qualcomm/TrOCR/blob/main/TrOCRDecoder.tflite) |
|
55 |
+
| TrOCRDecoder | SA8295P ADP | SA8295P | QNN | 3.74 ms | 7 - 13 MB | FP16 | NPU | Use Export Script |
|
56 |
+
| TrOCRDecoder | SA8650 (Proxy) | SA8650P Proxy | TFLITE | 2.27 ms | 0 - 346 MB | FP16 | NPU | [TrOCR.tflite](https://huggingface.co/qualcomm/TrOCR/blob/main/TrOCRDecoder.tflite) |
|
57 |
+
| TrOCRDecoder | SA8650 (Proxy) | SA8650P Proxy | QNN | 2.35 ms | 2 - 4 MB | FP16 | NPU | Use Export Script |
|
58 |
+
| TrOCRDecoder | SA8775P ADP | SA8775P | TFLITE | 3.341 ms | 0 - 45 MB | FP16 | NPU | [TrOCR.tflite](https://huggingface.co/qualcomm/TrOCR/blob/main/TrOCRDecoder.tflite) |
|
59 |
+
| TrOCRDecoder | SA8775P ADP | SA8775P | QNN | 3.578 ms | 7 - 13 MB | FP16 | NPU | Use Export Script |
|
60 |
+
| TrOCRDecoder | QCS8450 (Proxy) | QCS8450 Proxy | TFLITE | 2.671 ms | 0 - 48 MB | FP16 | NPU | [TrOCR.tflite](https://huggingface.co/qualcomm/TrOCR/blob/main/TrOCRDecoder.tflite) |
|
61 |
+
| TrOCRDecoder | QCS8450 (Proxy) | QCS8450 Proxy | QNN | 2.74 ms | 4 - 56 MB | FP16 | NPU | Use Export Script |
|
62 |
+
| TrOCRDecoder | Snapdragon X Elite CRD | Snapdragon® X Elite | QNN | 2.444 ms | 7 - 7 MB | FP16 | NPU | Use Export Script |
|
63 |
+
| TrOCRDecoder | Snapdragon X Elite CRD | Snapdragon® X Elite | ONNX | 2.741 ms | 69 - 69 MB | FP16 | NPU | [TrOCR.onnx](https://huggingface.co/qualcomm/TrOCR/blob/main/TrOCRDecoder.onnx) |
|
64 |
+
| TrOCREncoder | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 | TFLITE | 50.015 ms | 7 - 34 MB | FP16 | NPU | [TrOCR.tflite](https://huggingface.co/qualcomm/TrOCR/blob/main/TrOCREncoder.tflite) |
|
65 |
+
| TrOCREncoder | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 | QNN | 53.281 ms | 2 - 22 MB | FP16 | NPU | [TrOCR.so](https://huggingface.co/qualcomm/TrOCR/blob/main/TrOCREncoder.so) |
|
66 |
+
| TrOCREncoder | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 | ONNX | 38.056 ms | 0 - 57 MB | FP16 | NPU | [TrOCR.onnx](https://huggingface.co/qualcomm/TrOCR/blob/main/TrOCREncoder.onnx) |
|
67 |
+
| TrOCREncoder | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 | TFLITE | 39.322 ms | 5 - 67 MB | FP16 | NPU | [TrOCR.tflite](https://huggingface.co/qualcomm/TrOCR/blob/main/TrOCREncoder.tflite) |
|
68 |
+
| TrOCREncoder | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 | QNN | 41.406 ms | 2 - 61 MB | FP16 | NPU | [TrOCR.so](https://huggingface.co/qualcomm/TrOCR/blob/main/TrOCREncoder.so) |
|
69 |
+
| TrOCREncoder | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 | ONNX | 31.095 ms | 0 - 259 MB | FP16 | NPU | [TrOCR.onnx](https://huggingface.co/qualcomm/TrOCR/blob/main/TrOCREncoder.onnx) |
|
70 |
+
| TrOCREncoder | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite | TFLITE | 36.222 ms | 5 - 68 MB | FP16 | NPU | [TrOCR.tflite](https://huggingface.co/qualcomm/TrOCR/blob/main/TrOCREncoder.tflite) |
|
71 |
+
| TrOCREncoder | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite | QNN | 33.821 ms | 2 - 66 MB | FP16 | NPU | Use Export Script |
|
72 |
+
| TrOCREncoder | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite | ONNX | 24.497 ms | 16 - 138 MB | FP16 | NPU | [TrOCR.onnx](https://huggingface.co/qualcomm/TrOCR/blob/main/TrOCREncoder.onnx) |
|
73 |
+
| TrOCREncoder | QCS8550 (Proxy) | QCS8550 Proxy | TFLITE | 49.833 ms | 7 - 32 MB | FP16 | NPU | [TrOCR.tflite](https://huggingface.co/qualcomm/TrOCR/blob/main/TrOCREncoder.tflite) |
|
74 |
+
| TrOCREncoder | QCS8550 (Proxy) | QCS8550 Proxy | QNN | 36.818 ms | 2 - 8 MB | FP16 | NPU | Use Export Script |
|
75 |
+
| TrOCREncoder | SA7255P ADP | SA7255P | TFLITE | 266.53 ms | 7 - 69 MB | FP16 | NPU | [TrOCR.tflite](https://huggingface.co/qualcomm/TrOCR/blob/main/TrOCREncoder.tflite) |
|
76 |
+
| TrOCREncoder | SA7255P ADP | SA7255P | QNN | 247.644 ms | 2 - 12 MB | FP16 | NPU | Use Export Script |
|
77 |
+
| TrOCREncoder | SA8255 (Proxy) | SA8255P Proxy | TFLITE | 50.253 ms | 7 - 30 MB | FP16 | NPU | [TrOCR.tflite](https://huggingface.co/qualcomm/TrOCR/blob/main/TrOCREncoder.tflite) |
|
78 |
+
| TrOCREncoder | SA8255 (Proxy) | SA8255P Proxy | QNN | 37.723 ms | 2 - 4 MB | FP16 | NPU | Use Export Script |
|
79 |
+
| TrOCREncoder | SA8295P ADP | SA8295P | QNN | 50.866 ms | 4 - 10 MB | FP16 | NPU | Use Export Script |
|
80 |
+
| TrOCREncoder | SA8650 (Proxy) | SA8650P Proxy | TFLITE | 50.307 ms | 7 - 34 MB | FP16 | NPU | [TrOCR.tflite](https://huggingface.co/qualcomm/TrOCR/blob/main/TrOCREncoder.tflite) |
|
81 |
+
| TrOCREncoder | SA8650 (Proxy) | SA8650P Proxy | QNN | 37.01 ms | 2 - 3 MB | FP16 | NPU | Use Export Script |
|
82 |
+
| TrOCREncoder | SA8775P ADP | SA8775P | TFLITE | 59.803 ms | 7 - 69 MB | FP16 | NPU | [TrOCR.tflite](https://huggingface.co/qualcomm/TrOCR/blob/main/TrOCREncoder.tflite) |
|
83 |
+
| TrOCREncoder | SA8775P ADP | SA8775P | QNN | 42.412 ms | 2 - 8 MB | FP16 | NPU | Use Export Script |
|
84 |
+
| TrOCREncoder | QCS8450 (Proxy) | QCS8450 Proxy | TFLITE | 60.304 ms | 7 - 69 MB | FP16 | NPU | [TrOCR.tflite](https://huggingface.co/qualcomm/TrOCR/blob/main/TrOCREncoder.tflite) |
|
85 |
+
| TrOCREncoder | QCS8450 (Proxy) | QCS8450 Proxy | QNN | 63.0 ms | 0 - 64 MB | FP16 | NPU | Use Export Script |
|
86 |
+
| TrOCREncoder | Snapdragon X Elite CRD | Snapdragon® X Elite | QNN | 34.029 ms | 2 - 2 MB | FP16 | NPU | Use Export Script |
|
87 |
+
| TrOCREncoder | Snapdragon X Elite CRD | Snapdragon® X Elite | ONNX | 36.913 ms | 49 - 49 MB | FP16 | NPU | [TrOCR.onnx](https://huggingface.co/qualcomm/TrOCR/blob/main/TrOCREncoder.onnx) |
|
|
|
88 |
|
89 |
|
90 |
|
|
|
145 |
```
|
146 |
```
|
147 |
Profiling Results
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
------------------------------------------------------------
|
149 |
TrOCRDecoder
|
150 |
Device : Samsung Galaxy S23 (13)
|
151 |
Runtime : TFLITE
|
152 |
Estimated inference time (ms) : 2.2
|
153 |
+
Estimated peak memory usage (MB): [0, 143]
|
154 |
Total # Ops : 399
|
155 |
Compute Unit(s) : NPU (399 ops)
|
156 |
+
|
157 |
+
------------------------------------------------------------
|
158 |
+
TrOCREncoder
|
159 |
+
Device : Samsung Galaxy S23 (13)
|
160 |
+
Runtime : TFLITE
|
161 |
+
Estimated inference time (ms) : 50.0
|
162 |
+
Estimated peak memory usage (MB): [7, 34]
|
163 |
+
Total # Ops : 591
|
164 |
+
Compute Unit(s) : NPU (591 ops)
|
165 |
```
|
166 |
|
167 |
|
|
|
184 |
|
185 |
# Load the model
|
186 |
model = Model.from_pretrained()
|
|
|
187 |
decoder_model = model.decoder
|
188 |
+
encoder_model = model.encoder
|
189 |
|
190 |
# Device
|
191 |
device = hub.Device("Samsung Galaxy S23")
|
192 |
|
193 |
# Trace model
|
194 |
+
decoder_input_shape = decoder_model.get_input_spec()
|
195 |
+
decoder_sample_inputs = decoder_model.sample_inputs()
|
196 |
|
197 |
+
traced_decoder_model = torch.jit.trace(decoder_model, [torch.tensor(data[0]) for _, data in decoder_sample_inputs.items()])
|
198 |
|
199 |
# Compile model on a specific device
|
200 |
+
decoder_compile_job = hub.submit_compile_job(
|
201 |
+
model=traced_decoder_model ,
|
202 |
device=device,
|
203 |
+
input_specs=decoder_model.get_input_spec(),
|
204 |
)
|
205 |
|
206 |
# Get target model to run on-device
|
207 |
+
decoder_target_model = decoder_compile_job.get_target_model()
|
208 |
# Trace model
|
209 |
+
encoder_input_shape = encoder_model.get_input_spec()
|
210 |
+
encoder_sample_inputs = encoder_model.sample_inputs()
|
211 |
|
212 |
+
traced_encoder_model = torch.jit.trace(encoder_model, [torch.tensor(data[0]) for _, data in encoder_sample_inputs.items()])
|
213 |
|
214 |
# Compile model on a specific device
|
215 |
+
encoder_compile_job = hub.submit_compile_job(
|
216 |
+
model=traced_encoder_model ,
|
217 |
device=device,
|
218 |
+
input_specs=encoder_model.get_input_spec(),
|
219 |
)
|
220 |
|
221 |
# Get target model to run on-device
|
222 |
+
encoder_target_model = encoder_compile_job.get_target_model()
|
223 |
|
224 |
```
|
225 |
|
|
|
231 |
provisioned in the cloud. Once the job is submitted, you can navigate to a
|
232 |
provided job URL to view a variety of on-device performance metrics.
|
233 |
```python
|
|
|
|
|
|
|
|
|
234 |
decoder_profile_job = hub.submit_profile_job(
|
235 |
model=decoder_target_model,
|
236 |
device=device,
|
237 |
)
|
238 |
+
encoder_profile_job = hub.submit_profile_job(
|
239 |
+
model=encoder_target_model,
|
240 |
+
device=device,
|
241 |
+
)
|
242 |
|
243 |
```
|
244 |
|
|
|
247 |
To verify the accuracy of the model on-device, you can run on-device inference
|
248 |
on sample input data on the same cloud hosted device.
|
249 |
```python
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
250 |
decoder_input_data = decoder_model.sample_inputs()
|
251 |
decoder_inference_job = hub.submit_inference_job(
|
252 |
model=decoder_target_model,
|
|
|
254 |
inputs=decoder_input_data,
|
255 |
)
|
256 |
decoder_inference_job.download_output_data()
|
257 |
+
encoder_input_data = encoder_model.sample_inputs()
|
258 |
+
encoder_inference_job = hub.submit_inference_job(
|
259 |
+
model=encoder_target_model,
|
260 |
+
device=device,
|
261 |
+
inputs=encoder_input_data,
|
262 |
+
)
|
263 |
+
encoder_inference_job.download_output_data()
|
264 |
|
265 |
```
|
266 |
With the output of the model, you can compute like PSNR, relative errors or
|