Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
@@ -38,10 +38,10 @@ More details on model performance across various devices, can be found
|
|
38 |
|
39 |
| Device | Chipset | Target Runtime | Inference Time (ms) | Peak Memory Range (MB) | Precision | Primary Compute Unit | Target Model
|
40 |
| ---|---|---|---|---|---|---|---|
|
41 |
-
| Samsung Galaxy S23 Ultra (Android 13) | Snapdragon® 8 Gen 2 | TFLite | 11.
|
42 |
-
| Samsung Galaxy S23 Ultra (Android 13) | Snapdragon® 8 Gen 2 | TFLite |
|
43 |
-
| Samsung Galaxy S23 Ultra (Android 13) | Snapdragon® 8 Gen 2 | QNN Model Library | 7.
|
44 |
-
| Samsung Galaxy S23 Ultra (Android 13) | Snapdragon® 8 Gen 2 | QNN Model Library | 50.
|
45 |
|
46 |
|
47 |
|
@@ -103,17 +103,17 @@ python -m qai_hub_models.models.openai_clip.export
|
|
103 |
```
|
104 |
Profile Job summary of CLIPTextEncoder
|
105 |
--------------------------------------------------
|
106 |
-
Device:
|
107 |
-
Estimated Inference Time:
|
108 |
-
Estimated Peak Memory Range: 0.
|
109 |
Compute Units: NPU (377) | Total (377)
|
110 |
|
111 |
Profile Job summary of CLIPImageEncoder
|
112 |
--------------------------------------------------
|
113 |
-
Device:
|
114 |
-
Estimated Inference Time:
|
115 |
-
Estimated Peak Memory Range: 0.
|
116 |
-
Compute Units: NPU (
|
117 |
|
118 |
|
119 |
```
|
@@ -134,29 +134,49 @@ in memory using the `jit.trace` and then call the `submit_compile_job` API.
|
|
134 |
import torch
|
135 |
|
136 |
import qai_hub as hub
|
137 |
-
from qai_hub_models.models.openai_clip import
|
138 |
|
139 |
# Load the model
|
140 |
-
|
|
|
|
|
|
|
141 |
|
142 |
# Device
|
143 |
device = hub.Device("Samsung Galaxy S23")
|
144 |
|
|
|
145 |
# Trace model
|
146 |
-
|
147 |
-
|
148 |
|
149 |
-
|
150 |
|
151 |
# Compile model on a specific device
|
152 |
-
|
153 |
-
model=
|
154 |
device=device,
|
155 |
-
input_specs=
|
156 |
)
|
157 |
|
158 |
# Get target model to run on-device
|
159 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
|
161 |
```
|
162 |
|
@@ -168,10 +188,16 @@ After compiling models from step 1. Models can be profiled model on-device using
|
|
168 |
provisioned in the cloud. Once the job is submitted, you can navigate to a
|
169 |
provided job URL to view a variety of on-device performance metrics.
|
170 |
```python
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
|
176 |
```
|
177 |
|
@@ -180,14 +206,20 @@ Step 3: **Verify on-device accuracy**
|
|
180 |
To verify the accuracy of the model on-device, you can run on-device inference
|
181 |
on sample input data on the same cloud hosted device.
|
182 |
```python
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
)
|
189 |
-
|
190 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
191 |
|
192 |
```
|
193 |
With the output of the model, you can compute like PSNR, relative errors or
|
|
|
38 |
|
39 |
| Device | Chipset | Target Runtime | Inference Time (ms) | Peak Memory Range (MB) | Precision | Primary Compute Unit | Target Model
|
40 |
| ---|---|---|---|---|---|---|---|
|
41 |
+
| Samsung Galaxy S23 Ultra (Android 13) | Snapdragon® 8 Gen 2 | TFLite | 11.739 ms | 0 - 8 MB | FP16 | NPU | [CLIPTextEncoder.tflite](https://huggingface.co/qualcomm/OpenAI-Clip/blob/main/CLIPTextEncoder.tflite)
|
42 |
+
| Samsung Galaxy S23 Ultra (Android 13) | Snapdragon® 8 Gen 2 | TFLite | 65.346 ms | 0 - 9 MB | FP16 | NPU | [CLIPImageEncoder.tflite](https://huggingface.co/qualcomm/OpenAI-Clip/blob/main/CLIPImageEncoder.tflite)
|
43 |
+
| Samsung Galaxy S23 Ultra (Android 13) | Snapdragon® 8 Gen 2 | QNN Model Library | 7.795 ms | 0 - 16 MB | FP16 | NPU | [CLIPTextEncoder.so](https://huggingface.co/qualcomm/OpenAI-Clip/blob/main/CLIPTextEncoder.so)
|
44 |
+
| Samsung Galaxy S23 Ultra (Android 13) | Snapdragon® 8 Gen 2 | QNN Model Library | 50.085 ms | 0 - 61 MB | FP16 | NPU | [CLIPImageEncoder.so](https://huggingface.co/qualcomm/OpenAI-Clip/blob/main/CLIPImageEncoder.so)
|
45 |
|
46 |
|
47 |
|
|
|
103 |
```
|
104 |
Profile Job summary of CLIPTextEncoder
|
105 |
--------------------------------------------------
|
106 |
+
Device: Snapdragon X Elite CRD (11)
|
107 |
+
Estimated Inference Time: 8.29 ms
|
108 |
+
Estimated Peak Memory Range: 0.16-0.16 MB
|
109 |
Compute Units: NPU (377) | Total (377)
|
110 |
|
111 |
Profile Job summary of CLIPImageEncoder
|
112 |
--------------------------------------------------
|
113 |
+
Device: Snapdragon X Elite CRD (11)
|
114 |
+
Estimated Inference Time: 36.01 ms
|
115 |
+
Estimated Peak Memory Range: 0.57-0.57 MB
|
116 |
+
Compute Units: NPU (369) | Total (369)
|
117 |
|
118 |
|
119 |
```
|
|
|
134 |
import torch
|
135 |
|
136 |
import qai_hub as hub
|
137 |
+
from qai_hub_models.models.openai_clip import CLIPTextEncoder,CLIPImageEncoder
|
138 |
|
139 |
# Load the model
|
140 |
+
text_encoder_model = CLIPTextEncoder.from_pretrained()
|
141 |
+
|
142 |
+
image_encoder_model = CLIPImageEncoder.from_pretrained()
|
143 |
+
|
144 |
|
145 |
# Device
|
146 |
device = hub.Device("Samsung Galaxy S23")
|
147 |
|
148 |
+
|
149 |
# Trace model
|
150 |
+
text_encoder_input_shape = text_encoder_model.get_input_spec()
|
151 |
+
text_encoder_sample_inputs = text_encoder_model.sample_inputs()
|
152 |
|
153 |
+
traced_text_encoder_model = torch.jit.trace(text_encoder_model, [torch.tensor(data[0]) for _, data in text_encoder_sample_inputs.items()])
|
154 |
|
155 |
# Compile model on a specific device
|
156 |
+
text_encoder_compile_job = hub.submit_compile_job(
|
157 |
+
model=traced_text_encoder_model ,
|
158 |
device=device,
|
159 |
+
input_specs=text_encoder_model.get_input_spec(),
|
160 |
)
|
161 |
|
162 |
# Get target model to run on-device
|
163 |
+
text_encoder_target_model = text_encoder_compile_job.get_target_model()
|
164 |
+
|
165 |
+
# Trace model
|
166 |
+
image_encoder_input_shape = image_encoder_model.get_input_spec()
|
167 |
+
image_encoder_sample_inputs = image_encoder_model.sample_inputs()
|
168 |
+
|
169 |
+
traced_image_encoder_model = torch.jit.trace(image_encoder_model, [torch.tensor(data[0]) for _, data in image_encoder_sample_inputs.items()])
|
170 |
+
|
171 |
+
# Compile model on a specific device
|
172 |
+
image_encoder_compile_job = hub.submit_compile_job(
|
173 |
+
model=traced_image_encoder_model ,
|
174 |
+
device=device,
|
175 |
+
input_specs=image_encoder_model.get_input_spec(),
|
176 |
+
)
|
177 |
+
|
178 |
+
# Get target model to run on-device
|
179 |
+
image_encoder_target_model = image_encoder_compile_job.get_target_model()
|
180 |
|
181 |
```
|
182 |
|
|
|
188 |
provisioned in the cloud. Once the job is submitted, you can navigate to a
|
189 |
provided job URL to view a variety of on-device performance metrics.
|
190 |
```python
|
191 |
+
|
192 |
+
text_encoder_profile_job = hub.submit_profile_job(
|
193 |
+
model=text_encoder_target_model,
|
194 |
+
device=device,
|
195 |
+
)
|
196 |
+
|
197 |
+
image_encoder_profile_job = hub.submit_profile_job(
|
198 |
+
model=image_encoder_target_model,
|
199 |
+
device=device,
|
200 |
+
)
|
201 |
|
202 |
```
|
203 |
|
|
|
206 |
To verify the accuracy of the model on-device, you can run on-device inference
|
207 |
on sample input data on the same cloud hosted device.
|
208 |
```python
|
209 |
+
text_encoder_input_data = text_encoder_model.sample_inputs()
|
210 |
+
text_encoder_inference_job = hub.submit_inference_job(
|
211 |
+
model=text_encoder_target_model,
|
212 |
+
device=device,
|
213 |
+
inputs=text_encoder_input_data,
|
214 |
+
)
|
215 |
+
text_encoder_inference_job.download_output_data()
|
216 |
+
image_encoder_input_data = image_encoder_model.sample_inputs()
|
217 |
+
image_encoder_inference_job = hub.submit_inference_job(
|
218 |
+
model=image_encoder_target_model,
|
219 |
+
device=device,
|
220 |
+
inputs=image_encoder_input_data,
|
221 |
+
)
|
222 |
+
image_encoder_inference_job.download_output_data()
|
223 |
|
224 |
```
|
225 |
With the output of the model, you can compute like PSNR, relative errors or
|