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,20 +154,20 @@ python -m qai_hub_models.models.mediapipe_pose.export
|
|
154 |
```
|
155 |
Profiling Results
|
156 |
------------------------------------------------------------
|
157 |
-
|
158 |
Device : Samsung Galaxy S23 (13)
|
159 |
Runtime : TFLITE
|
160 |
Estimated inference time (ms) : 0.8
|
161 |
-
Estimated peak memory usage (MB): [0,
|
162 |
Total # Ops : 106
|
163 |
Compute Unit(s) : NPU (106 ops)
|
164 |
|
165 |
------------------------------------------------------------
|
166 |
-
|
167 |
Device : Samsung Galaxy S23 (13)
|
168 |
Runtime : TFLITE
|
169 |
Estimated inference time (ms) : 0.8
|
170 |
-
Estimated peak memory usage (MB): [0,
|
171 |
Total # Ops : 219
|
172 |
Compute Unit(s) : NPU (219 ops)
|
173 |
```
|
@@ -191,43 +191,26 @@ import qai_hub as hub
|
|
191 |
from qai_hub_models.models.mediapipe_pose import Model
|
192 |
|
193 |
# Load the model
|
194 |
-
|
195 |
-
pose_detector_model = model.pose_detector
|
196 |
-
pose_landmark_detector_model = model.pose_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 |
-
pose_landmark_detector_input_shape = pose_landmark_detector_model.get_input_spec()
|
218 |
-
pose_landmark_detector_sample_inputs = pose_landmark_detector_model.sample_inputs()
|
219 |
-
|
220 |
-
traced_pose_landmark_detector_model = torch.jit.trace(pose_landmark_detector_model, [torch.tensor(data[0]) for _, data in pose_landmark_detector_sample_inputs.items()])
|
221 |
-
|
222 |
-
# Compile model on a specific device
|
223 |
-
pose_landmark_detector_compile_job = hub.submit_compile_job(
|
224 |
-
model=traced_pose_landmark_detector_model ,
|
225 |
-
device=device,
|
226 |
-
input_specs=pose_landmark_detector_model.get_input_spec(),
|
227 |
-
)
|
228 |
-
|
229 |
-
# Get target model to run on-device
|
230 |
-
pose_landmark_detector_target_model = pose_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 |
-
pose_landmark_detector_profile_job = hub.submit_profile_job(
|
247 |
-
model=pose_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=pose_detector_input_data,
|
263 |
-
)
|
264 |
-
pose_detector_inference_job.download_output_data()
|
265 |
-
pose_landmark_detector_input_data = pose_landmark_detector_model.sample_inputs()
|
266 |
-
pose_landmark_detector_inference_job = hub.submit_inference_job(
|
267 |
-
model=pose_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 |
+
| PoseDetector | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 | TFLITE | 0.786 ms | 0 - 28 MB | FP16 | NPU | [MediaPipe-Pose-Estimation.tflite](https://huggingface.co/qualcomm/MediaPipe-Pose-Estimation/blob/main/PoseDetector.tflite) |
|
40 |
+
| PoseDetector | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 | QNN | 0.761 ms | 0 - 2 MB | FP16 | NPU | [MediaPipe-Pose-Estimation.so](https://huggingface.co/qualcomm/MediaPipe-Pose-Estimation/blob/main/PoseDetector.so) |
|
41 |
+
| PoseDetector | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 | ONNX | 0.907 ms | 0 - 12 MB | FP16 | NPU | [MediaPipe-Pose-Estimation.onnx](https://huggingface.co/qualcomm/MediaPipe-Pose-Estimation/blob/main/PoseDetector.onnx) |
|
42 |
+
| PoseDetector | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 | TFLITE | 0.573 ms | 0 - 28 MB | FP16 | NPU | [MediaPipe-Pose-Estimation.tflite](https://huggingface.co/qualcomm/MediaPipe-Pose-Estimation/blob/main/PoseDetector.tflite) |
|
43 |
+
| PoseDetector | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 | QNN | 0.567 ms | 0 - 18 MB | FP16 | NPU | [MediaPipe-Pose-Estimation.so](https://huggingface.co/qualcomm/MediaPipe-Pose-Estimation/blob/main/PoseDetector.so) |
|
44 |
+
| PoseDetector | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 | ONNX | 0.648 ms | 0 - 28 MB | FP16 | NPU | [MediaPipe-Pose-Estimation.onnx](https://huggingface.co/qualcomm/MediaPipe-Pose-Estimation/blob/main/PoseDetector.onnx) |
|
45 |
+
| PoseDetector | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite | TFLITE | 0.565 ms | 0 - 24 MB | FP16 | NPU | [MediaPipe-Pose-Estimation.tflite](https://huggingface.co/qualcomm/MediaPipe-Pose-Estimation/blob/main/PoseDetector.tflite) |
|
46 |
+
| PoseDetector | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite | QNN | 0.454 ms | 0 - 15 MB | FP16 | NPU | Use Export Script |
|
47 |
+
| PoseDetector | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite | ONNX | 0.689 ms | 0 - 19 MB | FP16 | NPU | [MediaPipe-Pose-Estimation.onnx](https://huggingface.co/qualcomm/MediaPipe-Pose-Estimation/blob/main/PoseDetector.onnx) |
|
48 |
+
| PoseDetector | SA7255P ADP | SA7255P | TFLITE | 37.857 ms | 0 - 15 MB | FP16 | NPU | [MediaPipe-Pose-Estimation.tflite](https://huggingface.co/qualcomm/MediaPipe-Pose-Estimation/blob/main/PoseDetector.tflite) |
|
49 |
+
| PoseDetector | SA7255P ADP | SA7255P | QNN | 37.821 ms | 0 - 10 MB | FP16 | NPU | Use Export Script |
|
50 |
+
| PoseDetector | SA8255 (Proxy) | SA8255P Proxy | TFLITE | 0.777 ms | 0 - 27 MB | FP16 | NPU | [MediaPipe-Pose-Estimation.tflite](https://huggingface.co/qualcomm/MediaPipe-Pose-Estimation/blob/main/PoseDetector.tflite) |
|
51 |
+
| PoseDetector | SA8255 (Proxy) | SA8255P Proxy | QNN | 0.755 ms | 0 - 2 MB | FP16 | NPU | Use Export Script |
|
52 |
+
| PoseDetector | SA8295P ADP | SA8295P | TFLITE | 2.336 ms | 0 - 19 MB | FP16 | NPU | [MediaPipe-Pose-Estimation.tflite](https://huggingface.co/qualcomm/MediaPipe-Pose-Estimation/blob/main/PoseDetector.tflite) |
|
53 |
+
| PoseDetector | SA8295P ADP | SA8295P | QNN | 2.349 ms | 0 - 18 MB | FP16 | NPU | Use Export Script |
|
54 |
+
| PoseDetector | SA8650 (Proxy) | SA8650P Proxy | TFLITE | 0.78 ms | 0 - 27 MB | FP16 | NPU | [MediaPipe-Pose-Estimation.tflite](https://huggingface.co/qualcomm/MediaPipe-Pose-Estimation/blob/main/PoseDetector.tflite) |
|
55 |
+
| PoseDetector | SA8650 (Proxy) | SA8650P Proxy | QNN | 0.756 ms | 0 - 2 MB | FP16 | NPU | Use Export Script |
|
56 |
+
| PoseDetector | SA8775P ADP | SA8775P | TFLITE | 1.782 ms | 0 - 15 MB | FP16 | NPU | [MediaPipe-Pose-Estimation.tflite](https://huggingface.co/qualcomm/MediaPipe-Pose-Estimation/blob/main/PoseDetector.tflite) |
|
57 |
+
| PoseDetector | SA8775P ADP | SA8775P | QNN | 1.736 ms | 0 - 10 MB | FP16 | NPU | Use Export Script |
|
58 |
+
| PoseDetector | QCS8275 (Proxy) | QCS8275 Proxy | TFLITE | 37.857 ms | 0 - 15 MB | FP16 | NPU | [MediaPipe-Pose-Estimation.tflite](https://huggingface.co/qualcomm/MediaPipe-Pose-Estimation/blob/main/PoseDetector.tflite) |
|
59 |
+
| PoseDetector | QCS8275 (Proxy) | QCS8275 Proxy | QNN | 37.821 ms | 0 - 10 MB | FP16 | NPU | Use Export Script |
|
60 |
+
| PoseDetector | QCS8550 (Proxy) | QCS8550 Proxy | TFLITE | 0.788 ms | 0 - 27 MB | FP16 | NPU | [MediaPipe-Pose-Estimation.tflite](https://huggingface.co/qualcomm/MediaPipe-Pose-Estimation/blob/main/PoseDetector.tflite) |
|
61 |
+
| PoseDetector | QCS8550 (Proxy) | QCS8550 Proxy | QNN | 0.753 ms | 0 - 3 MB | FP16 | NPU | Use Export Script |
|
62 |
+
| PoseDetector | QCS9075 (Proxy) | QCS9075 Proxy | TFLITE | 1.782 ms | 0 - 15 MB | FP16 | NPU | [MediaPipe-Pose-Estimation.tflite](https://huggingface.co/qualcomm/MediaPipe-Pose-Estimation/blob/main/PoseDetector.tflite) |
|
63 |
+
| PoseDetector | QCS9075 (Proxy) | QCS9075 Proxy | QNN | 1.736 ms | 0 - 10 MB | FP16 | NPU | Use Export Script |
|
64 |
+
| PoseDetector | QCS8450 (Proxy) | QCS8450 Proxy | TFLITE | 1.972 ms | 0 - 30 MB | FP16 | NPU | [MediaPipe-Pose-Estimation.tflite](https://huggingface.co/qualcomm/MediaPipe-Pose-Estimation/blob/main/PoseDetector.tflite) |
|
65 |
+
| PoseDetector | QCS8450 (Proxy) | QCS8450 Proxy | QNN | 1.969 ms | 0 - 28 MB | FP16 | NPU | Use Export Script |
|
66 |
+
| PoseDetector | Snapdragon X Elite CRD | Snapdragon® X Elite | QNN | 0.88 ms | 0 - 0 MB | FP16 | NPU | Use Export Script |
|
67 |
+
| PoseDetector | Snapdragon X Elite CRD | Snapdragon® X Elite | ONNX | 0.938 ms | 2 - 2 MB | FP16 | NPU | [MediaPipe-Pose-Estimation.onnx](https://huggingface.co/qualcomm/MediaPipe-Pose-Estimation/blob/main/PoseDetector.onnx) |
|
68 |
+
| PoseLandmarkDetector | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 | TFLITE | 0.816 ms | 0 - 68 MB | FP16 | NPU | [MediaPipe-Pose-Estimation.tflite](https://huggingface.co/qualcomm/MediaPipe-Pose-Estimation/blob/main/PoseLandmarkDetector.tflite) |
|
69 |
+
| PoseLandmarkDetector | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 | QNN | 0.82 ms | 1 - 3 MB | FP16 | NPU | [MediaPipe-Pose-Estimation.so](https://huggingface.co/qualcomm/MediaPipe-Pose-Estimation/blob/main/PoseLandmarkDetector.so) |
|
70 |
+
| PoseLandmarkDetector | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 | ONNX | 1.114 ms | 0 - 34 MB | FP16 | NPU | [MediaPipe-Pose-Estimation.onnx](https://huggingface.co/qualcomm/MediaPipe-Pose-Estimation/blob/main/PoseLandmarkDetector.onnx) |
|
71 |
+
| PoseLandmarkDetector | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 | TFLITE | 0.572 ms | 0 - 49 MB | FP16 | NPU | [MediaPipe-Pose-Estimation.tflite](https://huggingface.co/qualcomm/MediaPipe-Pose-Estimation/blob/main/PoseLandmarkDetector.tflite) |
|
72 |
+
| PoseLandmarkDetector | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 | QNN | 0.601 ms | 1 - 20 MB | FP16 | NPU | [MediaPipe-Pose-Estimation.so](https://huggingface.co/qualcomm/MediaPipe-Pose-Estimation/blob/main/PoseLandmarkDetector.so) |
|
73 |
+
| PoseLandmarkDetector | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 | ONNX | 0.766 ms | 0 - 49 MB | FP16 | NPU | [MediaPipe-Pose-Estimation.onnx](https://huggingface.co/qualcomm/MediaPipe-Pose-Estimation/blob/main/PoseLandmarkDetector.onnx) |
|
74 |
+
| PoseLandmarkDetector | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite | TFLITE | 0.555 ms | 0 - 30 MB | FP16 | NPU | [MediaPipe-Pose-Estimation.tflite](https://huggingface.co/qualcomm/MediaPipe-Pose-Estimation/blob/main/PoseLandmarkDetector.tflite) |
|
75 |
+
| PoseLandmarkDetector | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite | QNN | 0.56 ms | 1 - 24 MB | FP16 | NPU | Use Export Script |
|
76 |
+
| PoseLandmarkDetector | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite | ONNX | 0.651 ms | 1 - 30 MB | FP16 | NPU | [MediaPipe-Pose-Estimation.onnx](https://huggingface.co/qualcomm/MediaPipe-Pose-Estimation/blob/main/PoseLandmarkDetector.onnx) |
|
77 |
+
| PoseLandmarkDetector | SA7255P ADP | SA7255P | TFLITE | 17.205 ms | 0 - 27 MB | FP16 | NPU | [MediaPipe-Pose-Estimation.tflite](https://huggingface.co/qualcomm/MediaPipe-Pose-Estimation/blob/main/PoseLandmarkDetector.tflite) |
|
78 |
+
| PoseLandmarkDetector | SA7255P ADP | SA7255P | QNN | 17.082 ms | 1 - 10 MB | FP16 | NPU | Use Export Script |
|
79 |
+
| PoseLandmarkDetector | SA8255 (Proxy) | SA8255P Proxy | TFLITE | 0.818 ms | 0 - 69 MB | FP16 | NPU | [MediaPipe-Pose-Estimation.tflite](https://huggingface.co/qualcomm/MediaPipe-Pose-Estimation/blob/main/PoseLandmarkDetector.tflite) |
|
80 |
+
| PoseLandmarkDetector | SA8255 (Proxy) | SA8255P Proxy | QNN | 0.832 ms | 1 - 4 MB | FP16 | NPU | Use Export Script |
|
81 |
+
| PoseLandmarkDetector | SA8295P ADP | SA8295P | TFLITE | 1.439 ms | 0 - 27 MB | FP16 | NPU | [MediaPipe-Pose-Estimation.tflite](https://huggingface.co/qualcomm/MediaPipe-Pose-Estimation/blob/main/PoseLandmarkDetector.tflite) |
|
82 |
+
| PoseLandmarkDetector | SA8295P ADP | SA8295P | QNN | 1.383 ms | 0 - 18 MB | FP16 | NPU | Use Export Script |
|
83 |
+
| PoseLandmarkDetector | SA8650 (Proxy) | SA8650P Proxy | TFLITE | 0.822 ms | 0 - 71 MB | FP16 | NPU | [MediaPipe-Pose-Estimation.tflite](https://huggingface.co/qualcomm/MediaPipe-Pose-Estimation/blob/main/PoseLandmarkDetector.tflite) |
|
84 |
+
| PoseLandmarkDetector | SA8650 (Proxy) | SA8650P Proxy | QNN | 0.794 ms | 1 - 3 MB | FP16 | NPU | Use Export Script |
|
85 |
+
| PoseLandmarkDetector | SA8775P ADP | SA8775P | TFLITE | 1.673 ms | 0 - 27 MB | FP16 | NPU | [MediaPipe-Pose-Estimation.tflite](https://huggingface.co/qualcomm/MediaPipe-Pose-Estimation/blob/main/PoseLandmarkDetector.tflite) |
|
86 |
+
| PoseLandmarkDetector | SA8775P ADP | SA8775P | QNN | 1.601 ms | 1 - 11 MB | FP16 | NPU | Use Export Script |
|
87 |
+
| PoseLandmarkDetector | QCS8275 (Proxy) | QCS8275 Proxy | TFLITE | 17.205 ms | 0 - 27 MB | FP16 | NPU | [MediaPipe-Pose-Estimation.tflite](https://huggingface.co/qualcomm/MediaPipe-Pose-Estimation/blob/main/PoseLandmarkDetector.tflite) |
|
88 |
+
| PoseLandmarkDetector | QCS8275 (Proxy) | QCS8275 Proxy | QNN | 17.082 ms | 1 - 10 MB | FP16 | NPU | Use Export Script |
|
89 |
+
| PoseLandmarkDetector | QCS8550 (Proxy) | QCS8550 Proxy | TFLITE | 0.818 ms | 0 - 69 MB | FP16 | NPU | [MediaPipe-Pose-Estimation.tflite](https://huggingface.co/qualcomm/MediaPipe-Pose-Estimation/blob/main/PoseLandmarkDetector.tflite) |
|
90 |
+
| PoseLandmarkDetector | QCS8550 (Proxy) | QCS8550 Proxy | QNN | 0.797 ms | 1 - 4 MB | FP16 | NPU | Use Export Script |
|
91 |
+
| PoseLandmarkDetector | QCS9075 (Proxy) | QCS9075 Proxy | TFLITE | 1.673 ms | 0 - 27 MB | FP16 | NPU | [MediaPipe-Pose-Estimation.tflite](https://huggingface.co/qualcomm/MediaPipe-Pose-Estimation/blob/main/PoseLandmarkDetector.tflite) |
|
92 |
+
| PoseLandmarkDetector | QCS9075 (Proxy) | QCS9075 Proxy | QNN | 1.601 ms | 1 - 11 MB | FP16 | NPU | Use Export Script |
|
93 |
+
| PoseLandmarkDetector | QCS8450 (Proxy) | QCS8450 Proxy | TFLITE | 1.146 ms | 0 - 46 MB | FP16 | NPU | [MediaPipe-Pose-Estimation.tflite](https://huggingface.co/qualcomm/MediaPipe-Pose-Estimation/blob/main/PoseLandmarkDetector.tflite) |
|
94 |
+
| PoseLandmarkDetector | QCS8450 (Proxy) | QCS8450 Proxy | QNN | 1.141 ms | 1 - 39 MB | FP16 | NPU | Use Export Script |
|
95 |
+
| PoseLandmarkDetector | Snapdragon X Elite CRD | Snapdragon® X Elite | QNN | 1.013 ms | 1 - 1 MB | FP16 | NPU | Use Export Script |
|
96 |
+
| PoseLandmarkDetector | Snapdragon X Elite CRD | Snapdragon® X Elite | ONNX | 1.133 ms | 7 - 7 MB | FP16 | NPU | [MediaPipe-Pose-Estimation.onnx](https://huggingface.co/qualcomm/MediaPipe-Pose-Estimation/blob/main/PoseLandmarkDetector.onnx) |
|
97 |
|
98 |
|
99 |
|
|
|
154 |
```
|
155 |
Profiling Results
|
156 |
------------------------------------------------------------
|
157 |
+
PoseDetector
|
158 |
Device : Samsung Galaxy S23 (13)
|
159 |
Runtime : TFLITE
|
160 |
Estimated inference time (ms) : 0.8
|
161 |
+
Estimated peak memory usage (MB): [0, 28]
|
162 |
Total # Ops : 106
|
163 |
Compute Unit(s) : NPU (106 ops)
|
164 |
|
165 |
------------------------------------------------------------
|
166 |
+
PoseLandmarkDetector
|
167 |
Device : Samsung Galaxy S23 (13)
|
168 |
Runtime : TFLITE
|
169 |
Estimated inference time (ms) : 0.8
|
170 |
+
Estimated peak memory usage (MB): [0, 68]
|
171 |
Total # Ops : 219
|
172 |
Compute Unit(s) : NPU (219 ops)
|
173 |
```
|
|
|
191 |
from qai_hub_models.models.mediapipe_pose 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
|