Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -36,64 +36,64 @@ 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 |
-
|
|
| 89 |
-
|
|
| 90 |
-
|
|
| 91 |
-
|
|
| 92 |
-
|
|
| 93 |
-
|
|
| 94 |
-
|
|
| 95 |
-
|
|
| 96 |
-
|
|
| 97 |
|
| 98 |
|
| 99 |
|
|
@@ -154,7 +154,7 @@ python -m qai_hub_models.models.mediapipe_hand.export
|
|
| 154 |
```
|
| 155 |
Profiling Results
|
| 156 |
------------------------------------------------------------
|
| 157 |
-
|
| 158 |
Device : Samsung Galaxy S23 (13)
|
| 159 |
Runtime : TFLITE
|
| 160 |
Estimated inference time (ms) : 0.7
|
|
@@ -163,11 +163,11 @@ Total # Ops : 149
|
|
| 163 |
Compute Unit(s) : NPU (149 ops)
|
| 164 |
|
| 165 |
------------------------------------------------------------
|
| 166 |
-
|
| 167 |
Device : Samsung Galaxy S23 (13)
|
| 168 |
Runtime : TFLITE
|
| 169 |
Estimated inference time (ms) : 1.0
|
| 170 |
-
Estimated peak memory usage (MB): [0,
|
| 171 |
Total # Ops : 158
|
| 172 |
Compute Unit(s) : NPU (158 ops)
|
| 173 |
```
|
|
@@ -191,43 +191,26 @@ import qai_hub as hub
|
|
| 191 |
from qai_hub_models.models.mediapipe_hand import Model
|
| 192 |
|
| 193 |
# Load the model
|
| 194 |
-
|
| 195 |
-
hand_detector_model = model.hand_detector
|
| 196 |
-
hand_landmark_detector_model = model.hand_landmark_detector
|
| 197 |
|
| 198 |
# Device
|
| 199 |
-
device = hub.Device("Samsung Galaxy
|
| 200 |
|
| 201 |
# Trace model
|
| 202 |
-
|
| 203 |
-
|
| 204 |
|
| 205 |
-
|
| 206 |
|
| 207 |
# Compile model on a specific device
|
| 208 |
-
|
| 209 |
-
model=
|
| 210 |
device=device,
|
| 211 |
-
input_specs=
|
| 212 |
)
|
| 213 |
|
| 214 |
# Get target model to run on-device
|
| 215 |
-
|
| 216 |
-
# Trace model
|
| 217 |
-
hand_landmark_detector_input_shape = hand_landmark_detector_model.get_input_spec()
|
| 218 |
-
hand_landmark_detector_sample_inputs = hand_landmark_detector_model.sample_inputs()
|
| 219 |
-
|
| 220 |
-
traced_hand_landmark_detector_model = torch.jit.trace(hand_landmark_detector_model, [torch.tensor(data[0]) for _, data in hand_landmark_detector_sample_inputs.items()])
|
| 221 |
-
|
| 222 |
-
# Compile model on a specific device
|
| 223 |
-
hand_landmark_detector_compile_job = hub.submit_compile_job(
|
| 224 |
-
model=traced_hand_landmark_detector_model ,
|
| 225 |
-
device=device,
|
| 226 |
-
input_specs=hand_landmark_detector_model.get_input_spec(),
|
| 227 |
-
)
|
| 228 |
-
|
| 229 |
-
# Get target model to run on-device
|
| 230 |
-
hand_landmark_detector_target_model = hand_landmark_detector_compile_job.get_target_model()
|
| 231 |
|
| 232 |
```
|
| 233 |
|
|
@@ -239,15 +222,11 @@ After compiling models from step 1. Models can be profiled model on-device using
|
|
| 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 |
-
|
| 243 |
-
model=
|
| 244 |
-
device=device,
|
| 245 |
-
)
|
| 246 |
-
hand_landmark_detector_profile_job = hub.submit_profile_job(
|
| 247 |
-
model=hand_landmark_detector_target_model,
|
| 248 |
device=device,
|
| 249 |
)
|
| 250 |
-
|
| 251 |
```
|
| 252 |
|
| 253 |
Step 3: **Verify on-device accuracy**
|
|
@@ -255,20 +234,13 @@ Step 3: **Verify on-device accuracy**
|
|
| 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 |
-
|
| 259 |
-
|
| 260 |
-
model=
|
| 261 |
-
device=device,
|
| 262 |
-
inputs=hand_detector_input_data,
|
| 263 |
-
)
|
| 264 |
-
hand_detector_inference_job.download_output_data()
|
| 265 |
-
hand_landmark_detector_input_data = hand_landmark_detector_model.sample_inputs()
|
| 266 |
-
hand_landmark_detector_inference_job = hub.submit_inference_job(
|
| 267 |
-
model=hand_landmark_detector_target_model,
|
| 268 |
device=device,
|
| 269 |
-
inputs=
|
| 270 |
)
|
| 271 |
-
|
| 272 |
|
| 273 |
```
|
| 274 |
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 |
+
| HandDetector | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 | TFLITE | 0.734 ms | 0 - 31 MB | FP16 | NPU | [MediaPipe-Hand-Detection.tflite](https://huggingface.co/qualcomm/MediaPipe-Hand-Detection/blob/main/HandDetector.tflite) |
|
| 40 |
+
| HandDetector | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 | QNN | 0.718 ms | 0 - 2 MB | FP16 | NPU | [MediaPipe-Hand-Detection.so](https://huggingface.co/qualcomm/MediaPipe-Hand-Detection/blob/main/HandDetector.so) |
|
| 41 |
+
| HandDetector | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 | ONNX | 1.003 ms | 0 - 18 MB | FP16 | NPU | [MediaPipe-Hand-Detection.onnx](https://huggingface.co/qualcomm/MediaPipe-Hand-Detection/blob/main/HandDetector.onnx) |
|
| 42 |
+
| HandDetector | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 | TFLITE | 0.54 ms | 0 - 32 MB | FP16 | NPU | [MediaPipe-Hand-Detection.tflite](https://huggingface.co/qualcomm/MediaPipe-Hand-Detection/blob/main/HandDetector.tflite) |
|
| 43 |
+
| HandDetector | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 | QNN | 0.519 ms | 0 - 19 MB | FP16 | NPU | [MediaPipe-Hand-Detection.so](https://huggingface.co/qualcomm/MediaPipe-Hand-Detection/blob/main/HandDetector.so) |
|
| 44 |
+
| HandDetector | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 | ONNX | 0.685 ms | 0 - 39 MB | FP16 | NPU | [MediaPipe-Hand-Detection.onnx](https://huggingface.co/qualcomm/MediaPipe-Hand-Detection/blob/main/HandDetector.onnx) |
|
| 45 |
+
| HandDetector | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite | TFLITE | 0.445 ms | 0 - 22 MB | FP16 | NPU | [MediaPipe-Hand-Detection.tflite](https://huggingface.co/qualcomm/MediaPipe-Hand-Detection/blob/main/HandDetector.tflite) |
|
| 46 |
+
| HandDetector | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite | QNN | 0.538 ms | 1 - 20 MB | FP16 | NPU | Use Export Script |
|
| 47 |
+
| HandDetector | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite | ONNX | 0.728 ms | 1 - 25 MB | FP16 | NPU | [MediaPipe-Hand-Detection.onnx](https://huggingface.co/qualcomm/MediaPipe-Hand-Detection/blob/main/HandDetector.onnx) |
|
| 48 |
+
| HandDetector | SA7255P ADP | SA7255P | TFLITE | 24.662 ms | 0 - 22 MB | FP16 | NPU | [MediaPipe-Hand-Detection.tflite](https://huggingface.co/qualcomm/MediaPipe-Hand-Detection/blob/main/HandDetector.tflite) |
|
| 49 |
+
| HandDetector | SA7255P ADP | SA7255P | QNN | 24.595 ms | 1 - 10 MB | FP16 | NPU | Use Export Script |
|
| 50 |
+
| HandDetector | SA8255 (Proxy) | SA8255P Proxy | TFLITE | 0.744 ms | 0 - 30 MB | FP16 | NPU | [MediaPipe-Hand-Detection.tflite](https://huggingface.co/qualcomm/MediaPipe-Hand-Detection/blob/main/HandDetector.tflite) |
|
| 51 |
+
| HandDetector | SA8255 (Proxy) | SA8255P Proxy | QNN | 0.712 ms | 1 - 3 MB | FP16 | NPU | Use Export Script |
|
| 52 |
+
| HandDetector | SA8295P ADP | SA8295P | TFLITE | 1.741 ms | 0 - 22 MB | FP16 | NPU | [MediaPipe-Hand-Detection.tflite](https://huggingface.co/qualcomm/MediaPipe-Hand-Detection/blob/main/HandDetector.tflite) |
|
| 53 |
+
| HandDetector | SA8295P ADP | SA8295P | QNN | 1.677 ms | 0 - 18 MB | FP16 | NPU | Use Export Script |
|
| 54 |
+
| HandDetector | SA8650 (Proxy) | SA8650P Proxy | TFLITE | 0.738 ms | 0 - 29 MB | FP16 | NPU | [MediaPipe-Hand-Detection.tflite](https://huggingface.co/qualcomm/MediaPipe-Hand-Detection/blob/main/HandDetector.tflite) |
|
| 55 |
+
| HandDetector | SA8650 (Proxy) | SA8650P Proxy | QNN | 0.71 ms | 1 - 4 MB | FP16 | NPU | Use Export Script |
|
| 56 |
+
| HandDetector | SA8775P ADP | SA8775P | TFLITE | 1.575 ms | 0 - 22 MB | FP16 | NPU | [MediaPipe-Hand-Detection.tflite](https://huggingface.co/qualcomm/MediaPipe-Hand-Detection/blob/main/HandDetector.tflite) |
|
| 57 |
+
| HandDetector | SA8775P ADP | SA8775P | QNN | 1.504 ms | 1 - 11 MB | FP16 | NPU | Use Export Script |
|
| 58 |
+
| HandDetector | QCS8275 (Proxy) | QCS8275 Proxy | TFLITE | 24.662 ms | 0 - 22 MB | FP16 | NPU | [MediaPipe-Hand-Detection.tflite](https://huggingface.co/qualcomm/MediaPipe-Hand-Detection/blob/main/HandDetector.tflite) |
|
| 59 |
+
| HandDetector | QCS8275 (Proxy) | QCS8275 Proxy | QNN | 24.595 ms | 1 - 10 MB | FP16 | NPU | Use Export Script |
|
| 60 |
+
| HandDetector | QCS8550 (Proxy) | QCS8550 Proxy | TFLITE | 0.736 ms | 0 - 31 MB | FP16 | NPU | [MediaPipe-Hand-Detection.tflite](https://huggingface.co/qualcomm/MediaPipe-Hand-Detection/blob/main/HandDetector.tflite) |
|
| 61 |
+
| HandDetector | QCS8550 (Proxy) | QCS8550 Proxy | QNN | 0.705 ms | 1 - 4 MB | FP16 | NPU | Use Export Script |
|
| 62 |
+
| HandDetector | QCS9075 (Proxy) | QCS9075 Proxy | TFLITE | 1.575 ms | 0 - 22 MB | FP16 | NPU | [MediaPipe-Hand-Detection.tflite](https://huggingface.co/qualcomm/MediaPipe-Hand-Detection/blob/main/HandDetector.tflite) |
|
| 63 |
+
| HandDetector | QCS9075 (Proxy) | QCS9075 Proxy | QNN | 1.504 ms | 1 - 11 MB | FP16 | NPU | Use Export Script |
|
| 64 |
+
| HandDetector | QCS8450 (Proxy) | QCS8450 Proxy | TFLITE | 1.429 ms | 0 - 26 MB | FP16 | NPU | [MediaPipe-Hand-Detection.tflite](https://huggingface.co/qualcomm/MediaPipe-Hand-Detection/blob/main/HandDetector.tflite) |
|
| 65 |
+
| HandDetector | QCS8450 (Proxy) | QCS8450 Proxy | QNN | 1.41 ms | 1 - 25 MB | FP16 | NPU | Use Export Script |
|
| 66 |
+
| HandDetector | Snapdragon X Elite CRD | Snapdragon® X Elite | QNN | 0.869 ms | 1 - 1 MB | FP16 | NPU | Use Export Script |
|
| 67 |
+
| HandDetector | Snapdragon X Elite CRD | Snapdragon® X Elite | ONNX | 0.987 ms | 4 - 4 MB | FP16 | NPU | [MediaPipe-Hand-Detection.onnx](https://huggingface.co/qualcomm/MediaPipe-Hand-Detection/blob/main/HandDetector.onnx) |
|
| 68 |
+
| HandLandmarkDetector | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 | TFLITE | 1.009 ms | 0 - 64 MB | FP16 | NPU | [MediaPipe-Hand-Detection.tflite](https://huggingface.co/qualcomm/MediaPipe-Hand-Detection/blob/main/HandLandmarkDetector.tflite) |
|
| 69 |
+
| HandLandmarkDetector | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 | QNN | 1.006 ms | 1 - 3 MB | FP16 | NPU | [MediaPipe-Hand-Detection.so](https://huggingface.co/qualcomm/MediaPipe-Hand-Detection/blob/main/HandLandmarkDetector.so) |
|
| 70 |
+
| HandLandmarkDetector | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 | ONNX | 1.339 ms | 0 - 38 MB | FP16 | NPU | [MediaPipe-Hand-Detection.onnx](https://huggingface.co/qualcomm/MediaPipe-Hand-Detection/blob/main/HandLandmarkDetector.onnx) |
|
| 71 |
+
| HandLandmarkDetector | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 | TFLITE | 0.757 ms | 0 - 37 MB | FP16 | NPU | [MediaPipe-Hand-Detection.tflite](https://huggingface.co/qualcomm/MediaPipe-Hand-Detection/blob/main/HandLandmarkDetector.tflite) |
|
| 72 |
+
| HandLandmarkDetector | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 | QNN | 0.752 ms | 1 - 20 MB | FP16 | NPU | [MediaPipe-Hand-Detection.so](https://huggingface.co/qualcomm/MediaPipe-Hand-Detection/blob/main/HandLandmarkDetector.so) |
|
| 73 |
+
| HandLandmarkDetector | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 | ONNX | 0.941 ms | 0 - 33 MB | FP16 | NPU | [MediaPipe-Hand-Detection.onnx](https://huggingface.co/qualcomm/MediaPipe-Hand-Detection/blob/main/HandLandmarkDetector.onnx) |
|
| 74 |
+
| HandLandmarkDetector | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite | TFLITE | 0.764 ms | 0 - 27 MB | FP16 | NPU | [MediaPipe-Hand-Detection.tflite](https://huggingface.co/qualcomm/MediaPipe-Hand-Detection/blob/main/HandLandmarkDetector.tflite) |
|
| 75 |
+
| HandLandmarkDetector | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite | QNN | 0.706 ms | 1 - 19 MB | FP16 | NPU | Use Export Script |
|
| 76 |
+
| HandLandmarkDetector | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite | ONNX | 0.795 ms | 1 - 28 MB | FP16 | NPU | [MediaPipe-Hand-Detection.onnx](https://huggingface.co/qualcomm/MediaPipe-Hand-Detection/blob/main/HandLandmarkDetector.onnx) |
|
| 77 |
+
| HandLandmarkDetector | SA7255P ADP | SA7255P | TFLITE | 35.432 ms | 0 - 22 MB | FP16 | NPU | [MediaPipe-Hand-Detection.tflite](https://huggingface.co/qualcomm/MediaPipe-Hand-Detection/blob/main/HandLandmarkDetector.tflite) |
|
| 78 |
+
| HandLandmarkDetector | SA7255P ADP | SA7255P | QNN | 35.402 ms | 1 - 10 MB | FP16 | NPU | Use Export Script |
|
| 79 |
+
| HandLandmarkDetector | SA8255 (Proxy) | SA8255P Proxy | TFLITE | 1.015 ms | 0 - 63 MB | FP16 | NPU | [MediaPipe-Hand-Detection.tflite](https://huggingface.co/qualcomm/MediaPipe-Hand-Detection/blob/main/HandLandmarkDetector.tflite) |
|
| 80 |
+
| HandLandmarkDetector | SA8255 (Proxy) | SA8255P Proxy | QNN | 1.004 ms | 1 - 3 MB | FP16 | NPU | Use Export Script |
|
| 81 |
+
| HandLandmarkDetector | SA8295P ADP | SA8295P | TFLITE | 2.291 ms | 0 - 23 MB | FP16 | NPU | [MediaPipe-Hand-Detection.tflite](https://huggingface.co/qualcomm/MediaPipe-Hand-Detection/blob/main/HandLandmarkDetector.tflite) |
|
| 82 |
+
| HandLandmarkDetector | SA8295P ADP | SA8295P | QNN | 2.212 ms | 0 - 18 MB | FP16 | NPU | Use Export Script |
|
| 83 |
+
| HandLandmarkDetector | SA8650 (Proxy) | SA8650P Proxy | TFLITE | 0.998 ms | 0 - 64 MB | FP16 | NPU | [MediaPipe-Hand-Detection.tflite](https://huggingface.co/qualcomm/MediaPipe-Hand-Detection/blob/main/HandLandmarkDetector.tflite) |
|
| 84 |
+
| HandLandmarkDetector | SA8650 (Proxy) | SA8650P Proxy | QNN | 1.037 ms | 1 - 3 MB | FP16 | NPU | Use Export Script |
|
| 85 |
+
| HandLandmarkDetector | SA8775P ADP | SA8775P | TFLITE | 2.237 ms | 0 - 22 MB | FP16 | NPU | [MediaPipe-Hand-Detection.tflite](https://huggingface.co/qualcomm/MediaPipe-Hand-Detection/blob/main/HandLandmarkDetector.tflite) |
|
| 86 |
+
| HandLandmarkDetector | SA8775P ADP | SA8775P | QNN | 2.164 ms | 1 - 11 MB | FP16 | NPU | Use Export Script |
|
| 87 |
+
| HandLandmarkDetector | QCS8275 (Proxy) | QCS8275 Proxy | TFLITE | 35.432 ms | 0 - 22 MB | FP16 | NPU | [MediaPipe-Hand-Detection.tflite](https://huggingface.co/qualcomm/MediaPipe-Hand-Detection/blob/main/HandLandmarkDetector.tflite) |
|
| 88 |
+
| HandLandmarkDetector | QCS8275 (Proxy) | QCS8275 Proxy | QNN | 35.402 ms | 1 - 10 MB | FP16 | NPU | Use Export Script |
|
| 89 |
+
| HandLandmarkDetector | QCS8550 (Proxy) | QCS8550 Proxy | TFLITE | 1.008 ms | 0 - 63 MB | FP16 | NPU | [MediaPipe-Hand-Detection.tflite](https://huggingface.co/qualcomm/MediaPipe-Hand-Detection/blob/main/HandLandmarkDetector.tflite) |
|
| 90 |
+
| HandLandmarkDetector | QCS8550 (Proxy) | QCS8550 Proxy | QNN | 1.003 ms | 1 - 4 MB | FP16 | NPU | Use Export Script |
|
| 91 |
+
| HandLandmarkDetector | QCS9075 (Proxy) | QCS9075 Proxy | TFLITE | 2.237 ms | 0 - 22 MB | FP16 | NPU | [MediaPipe-Hand-Detection.tflite](https://huggingface.co/qualcomm/MediaPipe-Hand-Detection/blob/main/HandLandmarkDetector.tflite) |
|
| 92 |
+
| HandLandmarkDetector | QCS9075 (Proxy) | QCS9075 Proxy | QNN | 2.164 ms | 1 - 11 MB | FP16 | NPU | Use Export Script |
|
| 93 |
+
| HandLandmarkDetector | QCS8450 (Proxy) | QCS8450 Proxy | TFLITE | 1.902 ms | 0 - 36 MB | FP16 | NPU | [MediaPipe-Hand-Detection.tflite](https://huggingface.co/qualcomm/MediaPipe-Hand-Detection/blob/main/HandLandmarkDetector.tflite) |
|
| 94 |
+
| HandLandmarkDetector | QCS8450 (Proxy) | QCS8450 Proxy | QNN | 1.908 ms | 1 - 30 MB | FP16 | NPU | Use Export Script |
|
| 95 |
+
| HandLandmarkDetector | Snapdragon X Elite CRD | Snapdragon® X Elite | QNN | 1.237 ms | 1 - 1 MB | FP16 | NPU | Use Export Script |
|
| 96 |
+
| HandLandmarkDetector | Snapdragon X Elite CRD | Snapdragon® X Elite | ONNX | 1.36 ms | 6 - 6 MB | FP16 | NPU | [MediaPipe-Hand-Detection.onnx](https://huggingface.co/qualcomm/MediaPipe-Hand-Detection/blob/main/HandLandmarkDetector.onnx) |
|
| 97 |
|
| 98 |
|
| 99 |
|
|
|
|
| 154 |
```
|
| 155 |
Profiling Results
|
| 156 |
------------------------------------------------------------
|
| 157 |
+
HandDetector
|
| 158 |
Device : Samsung Galaxy S23 (13)
|
| 159 |
Runtime : TFLITE
|
| 160 |
Estimated inference time (ms) : 0.7
|
|
|
|
| 163 |
Compute Unit(s) : NPU (149 ops)
|
| 164 |
|
| 165 |
------------------------------------------------------------
|
| 166 |
+
HandLandmarkDetector
|
| 167 |
Device : Samsung Galaxy S23 (13)
|
| 168 |
Runtime : TFLITE
|
| 169 |
Estimated inference time (ms) : 1.0
|
| 170 |
+
Estimated peak memory usage (MB): [0, 64]
|
| 171 |
Total # Ops : 158
|
| 172 |
Compute Unit(s) : NPU (158 ops)
|
| 173 |
```
|
|
|
|
| 191 |
from qai_hub_models.models.mediapipe_hand import Model
|
| 192 |
|
| 193 |
# Load the model
|
| 194 |
+
torch_model = Model.from_pretrained()
|
|
|
|
|
|
|
| 195 |
|
| 196 |
# Device
|
| 197 |
+
device = hub.Device("Samsung Galaxy S24")
|
| 198 |
|
| 199 |
# Trace model
|
| 200 |
+
input_shape = torch_model.get_input_spec()
|
| 201 |
+
sample_inputs = torch_model.sample_inputs()
|
| 202 |
|
| 203 |
+
pt_model = torch.jit.trace(torch_model, [torch.tensor(data[0]) for _, data in sample_inputs.items()])
|
| 204 |
|
| 205 |
# Compile model on a specific device
|
| 206 |
+
compile_job = hub.submit_compile_job(
|
| 207 |
+
model=pt_model,
|
| 208 |
device=device,
|
| 209 |
+
input_specs=torch_model.get_input_spec(),
|
| 210 |
)
|
| 211 |
|
| 212 |
# Get target model to run on-device
|
| 213 |
+
target_model = compile_job.get_target_model()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 214 |
|
| 215 |
```
|
| 216 |
|
|
|
|
| 222 |
provisioned in the cloud. Once the job is submitted, you can navigate to a
|
| 223 |
provided job URL to view a variety of on-device performance metrics.
|
| 224 |
```python
|
| 225 |
+
profile_job = hub.submit_profile_job(
|
| 226 |
+
model=target_model,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 227 |
device=device,
|
| 228 |
)
|
| 229 |
+
|
| 230 |
```
|
| 231 |
|
| 232 |
Step 3: **Verify on-device accuracy**
|
|
|
|
| 234 |
To verify the accuracy of the model on-device, you can run on-device inference
|
| 235 |
on sample input data on the same cloud hosted device.
|
| 236 |
```python
|
| 237 |
+
input_data = torch_model.sample_inputs()
|
| 238 |
+
inference_job = hub.submit_inference_job(
|
| 239 |
+
model=target_model,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 240 |
device=device,
|
| 241 |
+
inputs=input_data,
|
| 242 |
)
|
| 243 |
+
on_device_output = inference_job.download_output_data()
|
| 244 |
|
| 245 |
```
|
| 246 |
With the output of the model, you can compute like PSNR, relative errors or
|