Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -36,10 +36,10 @@ More details on model performance across various devices, can be found
|
|
| 36 |
|
| 37 |
| Device | Chipset | Target Runtime | Inference Time (ms) | Peak Memory Range (MB) | Precision | Primary Compute Unit | Target Model
|
| 38 |
| ---|---|---|---|---|---|---|---|
|
| 39 |
-
| Samsung Galaxy S23 Ultra (Android 13) | Snapdragon® 8 Gen 2 | TFLite |
|
| 40 |
-
| Samsung Galaxy S23 Ultra (Android 13) | Snapdragon® 8 Gen 2 | TFLite | 1.
|
| 41 |
-
| Samsung Galaxy S23 Ultra (Android 13) | Snapdragon® 8 Gen 2 | QNN Model Library |
|
| 42 |
-
| Samsung Galaxy S23 Ultra (Android 13) | Snapdragon® 8 Gen 2 | QNN Model Library | 1.
|
| 43 |
|
| 44 |
|
| 45 |
|
|
@@ -100,17 +100,17 @@ python -m qai_hub_models.models.mediapipe_hand.export
|
|
| 100 |
```
|
| 101 |
Profile Job summary of MediaPipeHandDetector
|
| 102 |
--------------------------------------------------
|
| 103 |
-
Device:
|
| 104 |
-
Estimated Inference Time:
|
| 105 |
-
Estimated Peak Memory Range: 0.
|
| 106 |
-
Compute Units: NPU (
|
| 107 |
|
| 108 |
Profile Job summary of MediaPipeHandLandmarkDetector
|
| 109 |
--------------------------------------------------
|
| 110 |
-
Device:
|
| 111 |
-
Estimated Inference Time: 1.
|
| 112 |
-
Estimated Peak Memory Range: 0.
|
| 113 |
-
Compute Units: NPU (
|
| 114 |
|
| 115 |
|
| 116 |
```
|
|
@@ -131,29 +131,49 @@ in memory using the `jit.trace` and then call the `submit_compile_job` API.
|
|
| 131 |
import torch
|
| 132 |
|
| 133 |
import qai_hub as hub
|
| 134 |
-
from qai_hub_models.models.mediapipe_hand import
|
| 135 |
|
| 136 |
# Load the model
|
| 137 |
-
|
|
|
|
|
|
|
|
|
|
| 138 |
|
| 139 |
# Device
|
| 140 |
device = hub.Device("Samsung Galaxy S23")
|
| 141 |
|
|
|
|
| 142 |
# Trace model
|
| 143 |
-
|
| 144 |
-
|
| 145 |
|
| 146 |
-
|
| 147 |
|
| 148 |
# Compile model on a specific device
|
| 149 |
-
|
| 150 |
-
model=
|
| 151 |
device=device,
|
| 152 |
-
input_specs=
|
| 153 |
)
|
| 154 |
|
| 155 |
# Get target model to run on-device
|
| 156 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 157 |
|
| 158 |
```
|
| 159 |
|
|
@@ -165,10 +185,16 @@ After compiling models from step 1. Models can be profiled model on-device using
|
|
| 165 |
provisioned in the cloud. Once the job is submitted, you can navigate to a
|
| 166 |
provided job URL to view a variety of on-device performance metrics.
|
| 167 |
```python
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 172 |
|
| 173 |
```
|
| 174 |
|
|
@@ -177,14 +203,20 @@ Step 3: **Verify on-device accuracy**
|
|
| 177 |
To verify the accuracy of the model on-device, you can run on-device inference
|
| 178 |
on sample input data on the same cloud hosted device.
|
| 179 |
```python
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
)
|
| 186 |
-
|
| 187 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 188 |
|
| 189 |
```
|
| 190 |
With the output of the model, you can compute like PSNR, relative errors or
|
|
|
|
| 36 |
|
| 37 |
| Device | Chipset | Target Runtime | Inference Time (ms) | Peak Memory Range (MB) | Precision | Primary Compute Unit | Target Model
|
| 38 |
| ---|---|---|---|---|---|---|---|
|
| 39 |
+
| Samsung Galaxy S23 Ultra (Android 13) | Snapdragon® 8 Gen 2 | TFLite | 0.753 ms | 0 - 118 MB | FP16 | NPU | [MediaPipeHandDetector.tflite](https://huggingface.co/qualcomm/MediaPipe-Hand-Detection/blob/main/MediaPipeHandDetector.tflite)
|
| 40 |
+
| Samsung Galaxy S23 Ultra (Android 13) | Snapdragon® 8 Gen 2 | TFLite | 1.01 ms | 0 - 2 MB | FP16 | NPU | [MediaPipeHandLandmarkDetector.tflite](https://huggingface.co/qualcomm/MediaPipe-Hand-Detection/blob/main/MediaPipeHandLandmarkDetector.tflite)
|
| 41 |
+
| Samsung Galaxy S23 Ultra (Android 13) | Snapdragon® 8 Gen 2 | QNN Model Library | 0.791 ms | 0 - 20 MB | FP16 | NPU | [MediaPipeHandDetector.so](https://huggingface.co/qualcomm/MediaPipe-Hand-Detection/blob/main/MediaPipeHandDetector.so)
|
| 42 |
+
| Samsung Galaxy S23 Ultra (Android 13) | Snapdragon® 8 Gen 2 | QNN Model Library | 1.099 ms | 1 - 50 MB | FP16 | NPU | [MediaPipeHandLandmarkDetector.so](https://huggingface.co/qualcomm/MediaPipe-Hand-Detection/blob/main/MediaPipeHandLandmarkDetector.so)
|
| 43 |
|
| 44 |
|
| 45 |
|
|
|
|
| 100 |
```
|
| 101 |
Profile Job summary of MediaPipeHandDetector
|
| 102 |
--------------------------------------------------
|
| 103 |
+
Device: Snapdragon X Elite CRD (11)
|
| 104 |
+
Estimated Inference Time: 0.96 ms
|
| 105 |
+
Estimated Peak Memory Range: 0.75-0.75 MB
|
| 106 |
+
Compute Units: NPU (195) | Total (195)
|
| 107 |
|
| 108 |
Profile Job summary of MediaPipeHandLandmarkDetector
|
| 109 |
--------------------------------------------------
|
| 110 |
+
Device: Snapdragon X Elite CRD (11)
|
| 111 |
+
Estimated Inference Time: 1.30 ms
|
| 112 |
+
Estimated Peak Memory Range: 0.75-0.75 MB
|
| 113 |
+
Compute Units: NPU (208) | Total (208)
|
| 114 |
|
| 115 |
|
| 116 |
```
|
|
|
|
| 131 |
import torch
|
| 132 |
|
| 133 |
import qai_hub as hub
|
| 134 |
+
from qai_hub_models.models.mediapipe_hand import MediaPipeHandDetector,MediaPipeHandLandmarkDetector
|
| 135 |
|
| 136 |
# Load the model
|
| 137 |
+
hand_detector_model = MediaPipeHandDetector.from_pretrained()
|
| 138 |
+
|
| 139 |
+
hand_landmark_detector_model = MediaPipeHandLandmarkDetector.from_pretrained()
|
| 140 |
+
|
| 141 |
|
| 142 |
# Device
|
| 143 |
device = hub.Device("Samsung Galaxy S23")
|
| 144 |
|
| 145 |
+
|
| 146 |
# Trace model
|
| 147 |
+
hand_detector_input_shape = hand_detector_model.get_input_spec()
|
| 148 |
+
hand_detector_sample_inputs = hand_detector_model.sample_inputs()
|
| 149 |
|
| 150 |
+
traced_hand_detector_model = torch.jit.trace(hand_detector_model, [torch.tensor(data[0]) for _, data in hand_detector_sample_inputs.items()])
|
| 151 |
|
| 152 |
# Compile model on a specific device
|
| 153 |
+
hand_detector_compile_job = hub.submit_compile_job(
|
| 154 |
+
model=traced_hand_detector_model ,
|
| 155 |
device=device,
|
| 156 |
+
input_specs=hand_detector_model.get_input_spec(),
|
| 157 |
)
|
| 158 |
|
| 159 |
# Get target model to run on-device
|
| 160 |
+
hand_detector_target_model = hand_detector_compile_job.get_target_model()
|
| 161 |
+
|
| 162 |
+
# Trace model
|
| 163 |
+
hand_landmark_detector_input_shape = hand_landmark_detector_model.get_input_spec()
|
| 164 |
+
hand_landmark_detector_sample_inputs = hand_landmark_detector_model.sample_inputs()
|
| 165 |
+
|
| 166 |
+
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()])
|
| 167 |
+
|
| 168 |
+
# Compile model on a specific device
|
| 169 |
+
hand_landmark_detector_compile_job = hub.submit_compile_job(
|
| 170 |
+
model=traced_hand_landmark_detector_model ,
|
| 171 |
+
device=device,
|
| 172 |
+
input_specs=hand_landmark_detector_model.get_input_spec(),
|
| 173 |
+
)
|
| 174 |
+
|
| 175 |
+
# Get target model to run on-device
|
| 176 |
+
hand_landmark_detector_target_model = hand_landmark_detector_compile_job.get_target_model()
|
| 177 |
|
| 178 |
```
|
| 179 |
|
|
|
|
| 185 |
provisioned in the cloud. Once the job is submitted, you can navigate to a
|
| 186 |
provided job URL to view a variety of on-device performance metrics.
|
| 187 |
```python
|
| 188 |
+
|
| 189 |
+
hand_detector_profile_job = hub.submit_profile_job(
|
| 190 |
+
model=hand_detector_target_model,
|
| 191 |
+
device=device,
|
| 192 |
+
)
|
| 193 |
+
|
| 194 |
+
hand_landmark_detector_profile_job = hub.submit_profile_job(
|
| 195 |
+
model=hand_landmark_detector_target_model,
|
| 196 |
+
device=device,
|
| 197 |
+
)
|
| 198 |
|
| 199 |
```
|
| 200 |
|
|
|
|
| 203 |
To verify the accuracy of the model on-device, you can run on-device inference
|
| 204 |
on sample input data on the same cloud hosted device.
|
| 205 |
```python
|
| 206 |
+
hand_detector_input_data = hand_detector_model.sample_inputs()
|
| 207 |
+
hand_detector_inference_job = hub.submit_inference_job(
|
| 208 |
+
model=hand_detector_target_model,
|
| 209 |
+
device=device,
|
| 210 |
+
inputs=hand_detector_input_data,
|
| 211 |
+
)
|
| 212 |
+
hand_detector_inference_job.download_output_data()
|
| 213 |
+
hand_landmark_detector_input_data = hand_landmark_detector_model.sample_inputs()
|
| 214 |
+
hand_landmark_detector_inference_job = hub.submit_inference_job(
|
| 215 |
+
model=hand_landmark_detector_target_model,
|
| 216 |
+
device=device,
|
| 217 |
+
inputs=hand_landmark_detector_input_data,
|
| 218 |
+
)
|
| 219 |
+
hand_landmark_detector_inference_job.download_output_data()
|
| 220 |
|
| 221 |
```
|
| 222 |
With the output of the model, you can compute like PSNR, relative errors or
|