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-clause
|
6 |
+
pipeline_tag: object-detection
|
7 |
+
tags:
|
8 |
+
- real_time
|
9 |
+
- android
|
10 |
+
|
11 |
+
---
|
12 |
+
|
13 |
+
![](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/foot_track_net/web-assets/model_demo.png)
|
14 |
+
|
15 |
+
# Person-Foot-Detection: Optimized for Mobile Deployment
|
16 |
+
## Multi-task Human detector
|
17 |
+
|
18 |
+
FootTrackNet can detect person and face bounding boxes, head and feet landmark locations and feet visibility.
|
19 |
+
|
20 |
+
This model is an implementation of Person-Foot-Detection found [here]({source_repo}).
|
21 |
+
This repository provides scripts to run Person-Foot-Detection on Qualcomm® devices.
|
22 |
+
More details on model performance across various devices, can be found
|
23 |
+
[here](https://aihub.qualcomm.com/models/foot_track_net).
|
24 |
+
|
25 |
+
|
26 |
+
### Model Details
|
27 |
+
|
28 |
+
- **Model Type:** Object detection
|
29 |
+
- **Model Stats:**
|
30 |
+
- Inference latency: RealTime
|
31 |
+
- Input resolution: 640x480
|
32 |
+
- Number of output classes: 2
|
33 |
+
- Number of parameters: 2.53M
|
34 |
+
- Model size: 9.69 MB
|
35 |
+
|
36 |
+
| Model | Device | Chipset | Target Runtime | Inference Time (ms) | Peak Memory Range (MB) | Precision | Primary Compute Unit | Target Model
|
37 |
+
|---|---|---|---|---|---|---|---|---|
|
38 |
+
| Person-Foot-Detection | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 | TFLITE | 3.484 ms | 0 - 25 MB | FP16 | NPU | [Person-Foot-Detection.tflite](https://huggingface.co/qualcomm/Person-Foot-Detection/blob/main/Person-Foot-Detection.tflite) |
|
39 |
+
| Person-Foot-Detection | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 | QNN | 3.592 ms | 4 - 12 MB | FP16 | NPU | [Person-Foot-Detection.so](https://huggingface.co/qualcomm/Person-Foot-Detection/blob/main/Person-Foot-Detection.so) |
|
40 |
+
| Person-Foot-Detection | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 | ONNX | 5.293 ms | 15 - 18 MB | FP16 | NPU | [Person-Foot-Detection.onnx](https://huggingface.co/qualcomm/Person-Foot-Detection/blob/main/Person-Foot-Detection.onnx) |
|
41 |
+
| Person-Foot-Detection | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 | TFLITE | 2.884 ms | 0 - 55 MB | FP16 | NPU | [Person-Foot-Detection.tflite](https://huggingface.co/qualcomm/Person-Foot-Detection/blob/main/Person-Foot-Detection.tflite) |
|
42 |
+
| Person-Foot-Detection | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 | QNN | 3.046 ms | 4 - 21 MB | FP16 | NPU | [Person-Foot-Detection.so](https://huggingface.co/qualcomm/Person-Foot-Detection/blob/main/Person-Foot-Detection.so) |
|
43 |
+
| Person-Foot-Detection | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 | ONNX | 4.623 ms | 0 - 66 MB | FP16 | NPU | [Person-Foot-Detection.onnx](https://huggingface.co/qualcomm/Person-Foot-Detection/blob/main/Person-Foot-Detection.onnx) |
|
44 |
+
| Person-Foot-Detection | QCS8550 (Proxy) | QCS8550 Proxy | TFLITE | 3.339 ms | 0 - 2 MB | FP16 | NPU | [Person-Foot-Detection.tflite](https://huggingface.co/qualcomm/Person-Foot-Detection/blob/main/Person-Foot-Detection.tflite) |
|
45 |
+
| Person-Foot-Detection | QCS8550 (Proxy) | QCS8550 Proxy | QNN | 3.293 ms | 2 - 3 MB | FP16 | NPU | Use Export Script |
|
46 |
+
| Person-Foot-Detection | SA8255 (Proxy) | SA8255P Proxy | TFLITE | 3.382 ms | 0 - 109 MB | FP16 | NPU | [Person-Foot-Detection.tflite](https://huggingface.co/qualcomm/Person-Foot-Detection/blob/main/Person-Foot-Detection.tflite) |
|
47 |
+
| Person-Foot-Detection | SA8255 (Proxy) | SA8255P Proxy | QNN | 3.365 ms | 3 - 4 MB | FP16 | NPU | Use Export Script |
|
48 |
+
| Person-Foot-Detection | SA8775 (Proxy) | SA8775P Proxy | TFLITE | 3.443 ms | 0 - 41 MB | FP16 | NPU | [Person-Foot-Detection.tflite](https://huggingface.co/qualcomm/Person-Foot-Detection/blob/main/Person-Foot-Detection.tflite) |
|
49 |
+
| Person-Foot-Detection | SA8775 (Proxy) | SA8775P Proxy | QNN | 3.387 ms | 2 - 3 MB | FP16 | NPU | Use Export Script |
|
50 |
+
| Person-Foot-Detection | SA8650 (Proxy) | SA8650P Proxy | TFLITE | 3.504 ms | 0 - 4 MB | FP16 | NPU | [Person-Foot-Detection.tflite](https://huggingface.co/qualcomm/Person-Foot-Detection/blob/main/Person-Foot-Detection.tflite) |
|
51 |
+
| Person-Foot-Detection | SA8650 (Proxy) | SA8650P Proxy | QNN | 3.384 ms | 4 - 5 MB | FP16 | NPU | Use Export Script |
|
52 |
+
| Person-Foot-Detection | QCS8450 (Proxy) | QCS8450 Proxy | TFLITE | 5.66 ms | 5 - 58 MB | FP16 | NPU | [Person-Foot-Detection.tflite](https://huggingface.co/qualcomm/Person-Foot-Detection/blob/main/Person-Foot-Detection.tflite) |
|
53 |
+
| Person-Foot-Detection | QCS8450 (Proxy) | QCS8450 Proxy | QNN | 5.772 ms | 4 - 25 MB | FP16 | NPU | Use Export Script |
|
54 |
+
| Person-Foot-Detection | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite | TFLITE | 2.376 ms | 0 - 29 MB | FP16 | NPU | [Person-Foot-Detection.tflite](https://huggingface.co/qualcomm/Person-Foot-Detection/blob/main/Person-Foot-Detection.tflite) |
|
55 |
+
| Person-Foot-Detection | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite | QNN | 2.491 ms | 0 - 17 MB | FP16 | NPU | Use Export Script |
|
56 |
+
| Person-Foot-Detection | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite | ONNX | 3.68 ms | 17 - 51 MB | FP16 | NPU | [Person-Foot-Detection.onnx](https://huggingface.co/qualcomm/Person-Foot-Detection/blob/main/Person-Foot-Detection.onnx) |
|
57 |
+
| Person-Foot-Detection | Snapdragon X Elite CRD | Snapdragon® X Elite | QNN | 3.669 ms | 4 - 4 MB | FP16 | NPU | Use Export Script |
|
58 |
+
| Person-Foot-Detection | Snapdragon X Elite CRD | Snapdragon® X Elite | ONNX | 5.762 ms | 17 - 17 MB | FP16 | NPU | [Person-Foot-Detection.onnx](https://huggingface.co/qualcomm/Person-Foot-Detection/blob/main/Person-Foot-Detection.onnx) |
|
59 |
+
|
60 |
+
|
61 |
+
|
62 |
+
|
63 |
+
## Installation
|
64 |
+
|
65 |
+
This model can be installed as a Python package via pip.
|
66 |
+
|
67 |
+
```bash
|
68 |
+
pip install qai-hub-models
|
69 |
+
```
|
70 |
+
|
71 |
+
|
72 |
+
## Configure Qualcomm® AI Hub to run this model on a cloud-hosted device
|
73 |
+
|
74 |
+
Sign-in to [Qualcomm® AI Hub](https://app.aihub.qualcomm.com/) with your
|
75 |
+
Qualcomm® ID. Once signed in navigate to `Account -> Settings -> API Token`.
|
76 |
+
|
77 |
+
With this API token, you can configure your client to run models on the cloud
|
78 |
+
hosted devices.
|
79 |
+
```bash
|
80 |
+
qai-hub configure --api_token API_TOKEN
|
81 |
+
```
|
82 |
+
Navigate to [docs](https://app.aihub.qualcomm.com/docs/) for more information.
|
83 |
+
|
84 |
+
|
85 |
+
|
86 |
+
## Demo off target
|
87 |
+
|
88 |
+
The package contains a simple end-to-end demo that downloads pre-trained
|
89 |
+
weights and runs this model on a sample input.
|
90 |
+
|
91 |
+
```bash
|
92 |
+
python -m qai_hub_models.models.foot_track_net.demo
|
93 |
+
```
|
94 |
+
|
95 |
+
The above demo runs a reference implementation of pre-processing, model
|
96 |
+
inference, and post processing.
|
97 |
+
|
98 |
+
**NOTE**: If you want running in a Jupyter Notebook or Google Colab like
|
99 |
+
environment, please add the following to your cell (instead of the above).
|
100 |
+
```
|
101 |
+
%run -m qai_hub_models.models.foot_track_net.demo
|
102 |
+
```
|
103 |
+
|
104 |
+
|
105 |
+
### Run model on a cloud-hosted device
|
106 |
+
|
107 |
+
In addition to the demo, you can also run the model on a cloud-hosted Qualcomm®
|
108 |
+
device. This script does the following:
|
109 |
+
* Performance check on-device on a cloud-hosted device
|
110 |
+
* Downloads compiled assets that can be deployed on-device for Android.
|
111 |
+
* Accuracy check between PyTorch and on-device outputs.
|
112 |
+
|
113 |
+
```bash
|
114 |
+
python -m qai_hub_models.models.foot_track_net.export
|
115 |
+
```
|
116 |
+
```
|
117 |
+
Profiling Results
|
118 |
+
------------------------------------------------------------
|
119 |
+
Person-Foot-Detection
|
120 |
+
Device : Samsung Galaxy S23 (13)
|
121 |
+
Runtime : TFLITE
|
122 |
+
Estimated inference time (ms) : 3.5
|
123 |
+
Estimated peak memory usage (MB): [0, 25]
|
124 |
+
Total # Ops : 134
|
125 |
+
Compute Unit(s) : NPU (134 ops)
|
126 |
+
```
|
127 |
+
|
128 |
+
|
129 |
+
## How does this work?
|
130 |
+
|
131 |
+
This [export script](https://aihub.qualcomm.com/models/foot_track_net/qai_hub_models/models/Person-Foot-Detection/export.py)
|
132 |
+
leverages [Qualcomm® AI Hub](https://aihub.qualcomm.com/) to optimize, validate, and deploy this model
|
133 |
+
on-device. Lets go through each step below in detail:
|
134 |
+
|
135 |
+
Step 1: **Compile model for on-device deployment**
|
136 |
+
|
137 |
+
To compile a PyTorch model for on-device deployment, we first trace the model
|
138 |
+
in memory using the `jit.trace` and then call the `submit_compile_job` API.
|
139 |
+
|
140 |
+
```python
|
141 |
+
import torch
|
142 |
+
|
143 |
+
import qai_hub as hub
|
144 |
+
from qai_hub_models.models.foot_track_net import
|
145 |
+
|
146 |
+
# Load the model
|
147 |
+
|
148 |
+
# Device
|
149 |
+
device = hub.Device("Samsung Galaxy S23")
|
150 |
+
|
151 |
+
|
152 |
+
```
|
153 |
+
|
154 |
+
|
155 |
+
Step 2: **Performance profiling on cloud-hosted device**
|
156 |
+
|
157 |
+
After compiling models from step 1. Models can be profiled model on-device using the
|
158 |
+
`target_model`. Note that this scripts runs the model on a device automatically
|
159 |
+
provisioned in the cloud. Once the job is submitted, you can navigate to a
|
160 |
+
provided job URL to view a variety of on-device performance metrics.
|
161 |
+
```python
|
162 |
+
profile_job = hub.submit_profile_job(
|
163 |
+
model=target_model,
|
164 |
+
device=device,
|
165 |
+
)
|
166 |
+
|
167 |
+
```
|
168 |
+
|
169 |
+
Step 3: **Verify on-device accuracy**
|
170 |
+
|
171 |
+
To verify the accuracy of the model on-device, you can run on-device inference
|
172 |
+
on sample input data on the same cloud hosted device.
|
173 |
+
```python
|
174 |
+
input_data = torch_model.sample_inputs()
|
175 |
+
inference_job = hub.submit_inference_job(
|
176 |
+
model=target_model,
|
177 |
+
device=device,
|
178 |
+
inputs=input_data,
|
179 |
+
)
|
180 |
+
on_device_output = inference_job.download_output_data()
|
181 |
+
|
182 |
+
```
|
183 |
+
With the output of the model, you can compute like PSNR, relative errors or
|
184 |
+
spot check the output with expected output.
|
185 |
+
|
186 |
+
**Note**: This on-device profiling and inference requires access to Qualcomm®
|
187 |
+
AI Hub. [Sign up for access](https://myaccount.qualcomm.com/signup).
|
188 |
+
|
189 |
+
|
190 |
+
|
191 |
+
|
192 |
+
## Deploying compiled model to Android
|
193 |
+
|
194 |
+
|
195 |
+
The models can be deployed using multiple runtimes:
|
196 |
+
- TensorFlow Lite (`.tflite` export): [This
|
197 |
+
tutorial](https://www.tensorflow.org/lite/android/quickstart) provides a
|
198 |
+
guide to deploy the .tflite model in an Android application.
|
199 |
+
|
200 |
+
|
201 |
+
- QNN (`.so` export ): This [sample
|
202 |
+
app](https://docs.qualcomm.com/bundle/publicresource/topics/80-63442-50/sample_app.html)
|
203 |
+
provides instructions on how to use the `.so` shared library in an Android application.
|
204 |
+
|
205 |
+
|
206 |
+
## View on Qualcomm® AI Hub
|
207 |
+
Get more details on Person-Foot-Detection's performance across various devices [here](https://aihub.qualcomm.com/models/foot_track_net).
|
208 |
+
Explore all available models on [Qualcomm® AI Hub](https://aihub.qualcomm.com/)
|
209 |
+
|
210 |
+
|
211 |
+
## License
|
212 |
+
* The license for the original implementation of Person-Foot-Detection can be found [here](https://github.com/qcom-ai-hub/ai-hub-models-internal/blob/main/LICENSE).
|
213 |
+
* 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)
|
214 |
+
|
215 |
+
|
216 |
+
|
217 |
+
## References
|
218 |
+
* [None](None)
|
219 |
+
* [Source Model Implementation](https://github.com/quic/ai-hub-models/blob/main/qai_hub_models/models/foot_track_net/model.py)
|
220 |
+
|
221 |
+
|
222 |
+
|
223 |
+
## Community
|
224 |
+
* Join [our AI Hub Slack community](https://aihub.qualcomm.com/community/slack) to collaborate, post questions and learn more about on-device AI.
|
225 |
+
* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com).
|
226 |
+
|
227 |
+
|