qaihm-bot commited on
Commit
84302b8
·
verified ·
1 Parent(s): 433dab3

See https://github.com/quic/ai-hub-models/releases/v0.42.0 for changelog.

.gitattributes CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ CavaFace_float.dlc filter=lfs diff=lfs merge=lfs -text
37
+ DEPLOYMENT_MODEL_LICENSE.pdf filter=lfs diff=lfs merge=lfs -text
CavaFace_float.dlc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ca058d84059c0870f29543632e2a505d806bbc8843d8c05e18ca59a609161949
3
+ size 262765940
CavaFace_float.onnx.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:be3dc08f679f8423762221fe5859408f46f9fe33db6ad9a071c81ed73db864cc
3
+ size 244248534
CavaFace_float.tflite ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0884f8d6d2874998c3c8f9c90c62b9d57fa952f42682737f42d13665053968e0
3
+ size 262099840
DEPLOYMENT_MODEL_LICENSE.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4409f93b0e82531303b3e10f52f1fdfb56467a25f05b7441c6bbd8bb8a64b42c
3
+ size 109629
LICENSE ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ The license of the original trained model can be found at https://github.com/cavalleria/cavaface/blob/master/LICENSE.
2
+ The license for the deployable model files (.tflite, .onnx, .dlc, .bin, etc.) can be found in DEPLOYMENT_MODEL_LICENSE.pdf.
README.md ADDED
@@ -0,0 +1,244 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: pytorch
3
+ license: other
4
+ tags:
5
+ - real_time
6
+ - android
7
+ pipeline_tag: object-detection
8
+
9
+ ---
10
+
11
+ ![](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/cavaface/web-assets/model_demo.png)
12
+
13
+ # CavaFace: Optimized for Mobile Deployment
14
+ ## Comprehensive facial analysis by extracting face features
15
+
16
+
17
+ A PyTorch-based framework for training face recognition models that generates facial embeddings for verification and identification tasks
18
+
19
+ This model is an implementation of CavaFace found [here](https://github.com/cavalleria/cavaface).
20
+
21
+
22
+ This repository provides scripts to run CavaFace on Qualcomm® devices.
23
+ More details on model performance across various devices, can be found
24
+ [here](https://aihub.qualcomm.com/models/cavaface).
25
+
26
+
27
+
28
+ ### Model Details
29
+
30
+ - **Model Type:** Model_use_case.object_detection
31
+ - **Model Stats:**
32
+ - Model checkpoint: IR_SE_100_Combined_Epoch_24.pt
33
+ - Input resolution: 112x112
34
+ - Number of parameters: 65.5M
35
+ - Model size (float): 249.96MB
36
+
37
+ | Model | Precision | Device | Chipset | Target Runtime | Inference Time (ms) | Peak Memory Range (MB) | Primary Compute Unit | Target Model
38
+ |---|---|---|---|---|---|---|---|---|
39
+ | CavaFace | float | QCS8275 (Proxy) | Qualcomm® QCS8275 (Proxy) | TFLITE | 24.767 ms | 0 - 74 MB | NPU | [CavaFace.tflite](https://huggingface.co/qualcomm/CavaFace/blob/main/CavaFace.tflite) |
40
+ | CavaFace | float | QCS8275 (Proxy) | Qualcomm® QCS8275 (Proxy) | QNN_DLC | 24.739 ms | 0 - 58 MB | NPU | [CavaFace.dlc](https://huggingface.co/qualcomm/CavaFace/blob/main/CavaFace.dlc) |
41
+ | CavaFace | float | QCS8450 (Proxy) | Qualcomm® QCS8450 (Proxy) | TFLITE | 7.121 ms | 0 - 179 MB | NPU | [CavaFace.tflite](https://huggingface.co/qualcomm/CavaFace/blob/main/CavaFace.tflite) |
42
+ | CavaFace | float | QCS8450 (Proxy) | Qualcomm® QCS8450 (Proxy) | QNN_DLC | 8.871 ms | 0 - 69 MB | NPU | [CavaFace.dlc](https://huggingface.co/qualcomm/CavaFace/blob/main/CavaFace.dlc) |
43
+ | CavaFace | float | QCS8550 (Proxy) | Qualcomm® QCS8550 (Proxy) | TFLITE | 4.401 ms | 0 - 414 MB | NPU | [CavaFace.tflite](https://huggingface.co/qualcomm/CavaFace/blob/main/CavaFace.tflite) |
44
+ | CavaFace | float | QCS8550 (Proxy) | Qualcomm® QCS8550 (Proxy) | QNN_DLC | 4.311 ms | 0 - 65 MB | NPU | [CavaFace.dlc](https://huggingface.co/qualcomm/CavaFace/blob/main/CavaFace.dlc) |
45
+ | CavaFace | float | QCS8550 (Proxy) | Qualcomm® QCS8550 (Proxy) | ONNX | 4.637 ms | 0 - 12 MB | NPU | [CavaFace.onnx.zip](https://huggingface.co/qualcomm/CavaFace/blob/main/CavaFace.onnx.zip) |
46
+ | CavaFace | float | QCS9075 (Proxy) | Qualcomm® QCS9075 (Proxy) | TFLITE | 7.086 ms | 0 - 74 MB | NPU | [CavaFace.tflite](https://huggingface.co/qualcomm/CavaFace/blob/main/CavaFace.tflite) |
47
+ | CavaFace | float | QCS9075 (Proxy) | Qualcomm® QCS9075 (Proxy) | QNN_DLC | 30.228 ms | 0 - 58 MB | NPU | [CavaFace.dlc](https://huggingface.co/qualcomm/CavaFace/blob/main/CavaFace.dlc) |
48
+ | CavaFace | float | SA7255P ADP | Qualcomm® SA7255P | TFLITE | 24.767 ms | 0 - 74 MB | NPU | [CavaFace.tflite](https://huggingface.co/qualcomm/CavaFace/blob/main/CavaFace.tflite) |
49
+ | CavaFace | float | SA7255P ADP | Qualcomm® SA7255P | QNN_DLC | 24.739 ms | 0 - 58 MB | NPU | [CavaFace.dlc](https://huggingface.co/qualcomm/CavaFace/blob/main/CavaFace.dlc) |
50
+ | CavaFace | float | SA8255 (Proxy) | Qualcomm® SA8255P (Proxy) | TFLITE | 4.34 ms | 0 - 479 MB | NPU | [CavaFace.tflite](https://huggingface.co/qualcomm/CavaFace/blob/main/CavaFace.tflite) |
51
+ | CavaFace | float | SA8255 (Proxy) | Qualcomm® SA8255P (Proxy) | QNN_DLC | 4.315 ms | 0 - 55 MB | NPU | [CavaFace.dlc](https://huggingface.co/qualcomm/CavaFace/blob/main/CavaFace.dlc) |
52
+ | CavaFace | float | SA8295P ADP | Qualcomm® SA8295P | TFLITE | 8.217 ms | 0 - 75 MB | NPU | [CavaFace.tflite](https://huggingface.co/qualcomm/CavaFace/blob/main/CavaFace.tflite) |
53
+ | CavaFace | float | SA8295P ADP | Qualcomm® SA8295P | QNN_DLC | 7.973 ms | 0 - 62 MB | NPU | [CavaFace.dlc](https://huggingface.co/qualcomm/CavaFace/blob/main/CavaFace.dlc) |
54
+ | CavaFace | float | SA8650 (Proxy) | Qualcomm® SA8650P (Proxy) | TFLITE | 4.349 ms | 0 - 420 MB | NPU | [CavaFace.tflite](https://huggingface.co/qualcomm/CavaFace/blob/main/CavaFace.tflite) |
55
+ | CavaFace | float | SA8650 (Proxy) | Qualcomm® SA8650P (Proxy) | QNN_DLC | 4.318 ms | 0 - 73 MB | NPU | [CavaFace.dlc](https://huggingface.co/qualcomm/CavaFace/blob/main/CavaFace.dlc) |
56
+ | CavaFace | float | SA8775P ADP | Qualcomm® SA8775P | TFLITE | 7.086 ms | 0 - 74 MB | NPU | [CavaFace.tflite](https://huggingface.co/qualcomm/CavaFace/blob/main/CavaFace.tflite) |
57
+ | CavaFace | float | SA8775P ADP | Qualcomm® SA8775P | QNN_DLC | 30.228 ms | 0 - 58 MB | NPU | [CavaFace.dlc](https://huggingface.co/qualcomm/CavaFace/blob/main/CavaFace.dlc) |
58
+ | CavaFace | float | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | TFLITE | 3.228 ms | 0 - 174 MB | NPU | [CavaFace.tflite](https://huggingface.co/qualcomm/CavaFace/blob/main/CavaFace.tflite) |
59
+ | CavaFace | float | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | QNN_DLC | 3.206 ms | 0 - 67 MB | NPU | [CavaFace.dlc](https://huggingface.co/qualcomm/CavaFace/blob/main/CavaFace.dlc) |
60
+ | CavaFace | float | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | ONNX | 3.377 ms | 0 - 66 MB | NPU | [CavaFace.onnx.zip](https://huggingface.co/qualcomm/CavaFace/blob/main/CavaFace.onnx.zip) |
61
+ | CavaFace | float | Samsung Galaxy S25 | Snapdragon® 8 Elite For Galaxy Mobile | TFLITE | 2.668 ms | 0 - 79 MB | NPU | [CavaFace.tflite](https://huggingface.co/qualcomm/CavaFace/blob/main/CavaFace.tflite) |
62
+ | CavaFace | float | Samsung Galaxy S25 | Snapdragon® 8 Elite For Galaxy Mobile | QNN_DLC | 2.629 ms | 0 - 65 MB | NPU | [CavaFace.dlc](https://huggingface.co/qualcomm/CavaFace/blob/main/CavaFace.dlc) |
63
+ | CavaFace | float | Samsung Galaxy S25 | Snapdragon® 8 Elite For Galaxy Mobile | ONNX | 2.792 ms | 0 - 63 MB | NPU | [CavaFace.onnx.zip](https://huggingface.co/qualcomm/CavaFace/blob/main/CavaFace.onnx.zip) |
64
+ | CavaFace | float | Snapdragon 8 Elite Gen 5 QRD | Snapdragon® 8 Elite Gen5 Mobile | TFLITE | 2.285 ms | 0 - 80 MB | NPU | [CavaFace.tflite](https://huggingface.co/qualcomm/CavaFace/blob/main/CavaFace.tflite) |
65
+ | CavaFace | float | Snapdragon 8 Elite Gen 5 QRD | Snapdragon® 8 Elite Gen5 Mobile | QNN_DLC | 2.254 ms | 0 - 64 MB | NPU | [CavaFace.dlc](https://huggingface.co/qualcomm/CavaFace/blob/main/CavaFace.dlc) |
66
+ | CavaFace | float | Snapdragon 8 Elite Gen 5 QRD | Snapdragon® 8 Elite Gen5 Mobile | ONNX | 2.446 ms | 0 - 63 MB | NPU | [CavaFace.onnx.zip](https://huggingface.co/qualcomm/CavaFace/blob/main/CavaFace.onnx.zip) |
67
+ | CavaFace | float | Snapdragon X Elite CRD | Snapdragon® X Elite | QNN_DLC | 4.473 ms | 418 - 418 MB | NPU | [CavaFace.dlc](https://huggingface.co/qualcomm/CavaFace/blob/main/CavaFace.dlc) |
68
+ | CavaFace | float | Snapdragon X Elite CRD | Snapdragon® X Elite | ONNX | 4.487 ms | 127 - 127 MB | NPU | [CavaFace.onnx.zip](https://huggingface.co/qualcomm/CavaFace/blob/main/CavaFace.onnx.zip) |
69
+
70
+
71
+
72
+
73
+ ## Installation
74
+
75
+
76
+ Install the package via pip:
77
+ ```bash
78
+ # NOTE: 3.10 <= PYTHON_VERSION < 3.14 is supported.
79
+ pip install "qai-hub-models[cavaface]"
80
+ ```
81
+
82
+
83
+ ## Configure Qualcomm® AI Hub Workbench to run this model on a cloud-hosted device
84
+
85
+ Sign-in to [Qualcomm® AI Hub Workbench](https://workbench.aihub.qualcomm.com/) with your
86
+ Qualcomm® ID. Once signed in navigate to `Account -> Settings -> API Token`.
87
+
88
+ With this API token, you can configure your client to run models on the cloud
89
+ hosted devices.
90
+ ```bash
91
+ qai-hub configure --api_token API_TOKEN
92
+ ```
93
+ Navigate to [docs](https://workbench.aihub.qualcomm.com/docs/) for more information.
94
+
95
+
96
+
97
+ ## Demo off target
98
+
99
+ The package contains a simple end-to-end demo that downloads pre-trained
100
+ weights and runs this model on a sample input.
101
+
102
+ ```bash
103
+ python -m qai_hub_models.models.cavaface.demo
104
+ ```
105
+
106
+ The above demo runs a reference implementation of pre-processing, model
107
+ inference, and post processing.
108
+
109
+ **NOTE**: If you want running in a Jupyter Notebook or Google Colab like
110
+ environment, please add the following to your cell (instead of the above).
111
+ ```
112
+ %run -m qai_hub_models.models.cavaface.demo
113
+ ```
114
+
115
+
116
+ ### Run model on a cloud-hosted device
117
+
118
+ In addition to the demo, you can also run the model on a cloud-hosted Qualcomm®
119
+ device. This script does the following:
120
+ * Performance check on-device on a cloud-hosted device
121
+ * Downloads compiled assets that can be deployed on-device for Android.
122
+ * Accuracy check between PyTorch and on-device outputs.
123
+
124
+ ```bash
125
+ python -m qai_hub_models.models.cavaface.export
126
+ ```
127
+
128
+
129
+
130
+ ## How does this work?
131
+
132
+ This [export script](https://aihub.qualcomm.com/models/cavaface/qai_hub_models/models/CavaFace/export.py)
133
+ leverages [Qualcomm® AI Hub](https://aihub.qualcomm.com/) to optimize, validate, and deploy this model
134
+ on-device. Lets go through each step below in detail:
135
+
136
+ Step 1: **Compile model for on-device deployment**
137
+
138
+ To compile a PyTorch model for on-device deployment, we first trace the model
139
+ in memory using the `jit.trace` and then call the `submit_compile_job` API.
140
+
141
+ ```python
142
+ import torch
143
+
144
+ import qai_hub as hub
145
+ from qai_hub_models.models.cavaface import Model
146
+
147
+ # Load the model
148
+ torch_model = Model.from_pretrained()
149
+
150
+ # Device
151
+ device = hub.Device("Samsung Galaxy S25")
152
+
153
+ # Trace model
154
+ input_shape = torch_model.get_input_spec()
155
+ sample_inputs = torch_model.sample_inputs()
156
+
157
+ pt_model = torch.jit.trace(torch_model, [torch.tensor(data[0]) for _, data in sample_inputs.items()])
158
+
159
+ # Compile model on a specific device
160
+ compile_job = hub.submit_compile_job(
161
+ model=pt_model,
162
+ device=device,
163
+ input_specs=torch_model.get_input_spec(),
164
+ )
165
+
166
+ # Get target model to run on-device
167
+ target_model = compile_job.get_target_model()
168
+
169
+ ```
170
+
171
+
172
+ Step 2: **Performance profiling on cloud-hosted device**
173
+
174
+ After compiling models from step 1. Models can be profiled model on-device using the
175
+ `target_model`. Note that this scripts runs the model on a device automatically
176
+ provisioned in the cloud. Once the job is submitted, you can navigate to a
177
+ provided job URL to view a variety of on-device performance metrics.
178
+ ```python
179
+ profile_job = hub.submit_profile_job(
180
+ model=target_model,
181
+ device=device,
182
+ )
183
+
184
+ ```
185
+
186
+ Step 3: **Verify on-device accuracy**
187
+
188
+ To verify the accuracy of the model on-device, you can run on-device inference
189
+ on sample input data on the same cloud hosted device.
190
+ ```python
191
+ input_data = torch_model.sample_inputs()
192
+ inference_job = hub.submit_inference_job(
193
+ model=target_model,
194
+ device=device,
195
+ inputs=input_data,
196
+ )
197
+ on_device_output = inference_job.download_output_data()
198
+
199
+ ```
200
+ With the output of the model, you can compute like PSNR, relative errors or
201
+ spot check the output with expected output.
202
+
203
+ **Note**: This on-device profiling and inference requires access to Qualcomm®
204
+ AI Hub Workbench. [Sign up for access](https://myaccount.qualcomm.com/signup).
205
+
206
+
207
+
208
+
209
+ ## Deploying compiled model to Android
210
+
211
+
212
+ The models can be deployed using multiple runtimes:
213
+ - TensorFlow Lite (`.tflite` export): [This
214
+ tutorial](https://www.tensorflow.org/lite/android/quickstart) provides a
215
+ guide to deploy the .tflite model in an Android application.
216
+
217
+
218
+ - QNN (`.so` export ): This [sample
219
+ app](https://docs.qualcomm.com/bundle/publicresource/topics/80-63442-50/sample_app.html)
220
+ provides instructions on how to use the `.so` shared library in an Android application.
221
+
222
+
223
+ ## View on Qualcomm® AI Hub
224
+ Get more details on CavaFace's performance across various devices [here](https://aihub.qualcomm.com/models/cavaface).
225
+ Explore all available models on [Qualcomm® AI Hub](https://aihub.qualcomm.com/)
226
+
227
+
228
+ ## License
229
+ * The license for the original implementation of CavaFace can be found
230
+ [here](https://github.com/cavalleria/cavaface/blob/master/LICENSE).
231
+ * 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)
232
+
233
+
234
+
235
+ ## References
236
+ * [Source Model Implementation](https://github.com/cavalleria/cavaface)
237
+
238
+
239
+
240
+ ## Community
241
+ * Join [our AI Hub Slack community](https://aihub.qualcomm.com/community/slack) to collaborate, post questions and learn more about on-device AI.
242
+ * For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com).
243
+
244
+
tool-versions.yaml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ tool_versions:
2
+ onnx:
3
+ qairt: 2.37.1.250807093845_124904
4
+ onnx_runtime: 1.23.0