Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -37,8 +37,8 @@ More details on model performance across various devices, can be found
|
|
| 37 |
|
| 38 |
| Device | Chipset | Target Runtime | Inference Time (ms) | Peak Memory Range (MB) | Precision | Primary Compute Unit | Target Model
|
| 39 |
| ---|---|---|---|---|---|---|---|
|
| 40 |
-
| Samsung Galaxy S23 Ultra (Android 13) | Snapdragon® 8 Gen 2 | TFLite |
|
| 41 |
-
| Samsung Galaxy S23 Ultra (Android 13) | Snapdragon® 8 Gen 2 | QNN Model Library | 20.
|
| 42 |
|
| 43 |
|
| 44 |
|
|
@@ -100,9 +100,9 @@ python -m qai_hub_models.models.ffnet_54s.export
|
|
| 100 |
```
|
| 101 |
Profile Job summary of FFNet-54S
|
| 102 |
--------------------------------------------------
|
| 103 |
-
Device:
|
| 104 |
-
Estimated Inference Time: 20.
|
| 105 |
-
Estimated Peak Memory Range: 24.
|
| 106 |
Compute Units: NPU (175) | Total (175)
|
| 107 |
|
| 108 |
|
|
@@ -124,29 +124,13 @@ in memory using the `jit.trace` and then call the `submit_compile_job` API.
|
|
| 124 |
import torch
|
| 125 |
|
| 126 |
import qai_hub as hub
|
| 127 |
-
from qai_hub_models.models.ffnet_54s import
|
| 128 |
|
| 129 |
# Load the model
|
| 130 |
-
torch_model = Model.from_pretrained()
|
| 131 |
|
| 132 |
# Device
|
| 133 |
device = hub.Device("Samsung Galaxy S23")
|
| 134 |
|
| 135 |
-
# Trace model
|
| 136 |
-
input_shape = torch_model.get_input_spec()
|
| 137 |
-
sample_inputs = torch_model.sample_inputs()
|
| 138 |
-
|
| 139 |
-
pt_model = torch.jit.trace(torch_model, [torch.tensor(data[0]) for _, data in sample_inputs.items()])
|
| 140 |
-
|
| 141 |
-
# Compile model on a specific device
|
| 142 |
-
compile_job = hub.submit_compile_job(
|
| 143 |
-
model=pt_model,
|
| 144 |
-
device=device,
|
| 145 |
-
input_specs=torch_model.get_input_spec(),
|
| 146 |
-
)
|
| 147 |
-
|
| 148 |
-
# Get target model to run on-device
|
| 149 |
-
target_model = compile_job.get_target_model()
|
| 150 |
|
| 151 |
```
|
| 152 |
|
|
@@ -159,10 +143,10 @@ provisioned in the cloud. Once the job is submitted, you can navigate to a
|
|
| 159 |
provided job URL to view a variety of on-device performance metrics.
|
| 160 |
```python
|
| 161 |
profile_job = hub.submit_profile_job(
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
)
|
| 165 |
-
|
| 166 |
```
|
| 167 |
|
| 168 |
Step 3: **Verify on-device accuracy**
|
|
@@ -172,12 +156,11 @@ on sample input data on the same cloud hosted device.
|
|
| 172 |
```python
|
| 173 |
input_data = torch_model.sample_inputs()
|
| 174 |
inference_job = hub.submit_inference_job(
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
)
|
| 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
|
|
@@ -188,6 +171,20 @@ AI Hub. [Sign up for access](https://myaccount.qualcomm.com/signup).
|
|
| 188 |
|
| 189 |
|
| 190 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 191 |
|
| 192 |
## Deploying compiled model to Android
|
| 193 |
|
|
|
|
| 37 |
|
| 38 |
| Device | Chipset | Target Runtime | Inference Time (ms) | Peak Memory Range (MB) | Precision | Primary Compute Unit | Target Model
|
| 39 |
| ---|---|---|---|---|---|---|---|
|
| 40 |
+
| Samsung Galaxy S23 Ultra (Android 13) | Snapdragon® 8 Gen 2 | TFLite | 19.912 ms | 2 - 45 MB | FP16 | NPU | [FFNet-54S.tflite](https://huggingface.co/qualcomm/FFNet-54S/blob/main/FFNet-54S.tflite)
|
| 41 |
+
| Samsung Galaxy S23 Ultra (Android 13) | Snapdragon® 8 Gen 2 | QNN Model Library | 20.147 ms | 24 - 44 MB | FP16 | NPU | [FFNet-54S.so](https://huggingface.co/qualcomm/FFNet-54S/blob/main/FFNet-54S.so)
|
| 42 |
|
| 43 |
|
| 44 |
|
|
|
|
| 100 |
```
|
| 101 |
Profile Job summary of FFNet-54S
|
| 102 |
--------------------------------------------------
|
| 103 |
+
Device: Snapdragon X Elite CRD (11)
|
| 104 |
+
Estimated Inference Time: 20.31 ms
|
| 105 |
+
Estimated Peak Memory Range: 24.05-24.05 MB
|
| 106 |
Compute Units: NPU (175) | Total (175)
|
| 107 |
|
| 108 |
|
|
|
|
| 124 |
import torch
|
| 125 |
|
| 126 |
import qai_hub as hub
|
| 127 |
+
from qai_hub_models.models.ffnet_54s import
|
| 128 |
|
| 129 |
# Load the model
|
|
|
|
| 130 |
|
| 131 |
# Device
|
| 132 |
device = hub.Device("Samsung Galaxy S23")
|
| 133 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
|
| 135 |
```
|
| 136 |
|
|
|
|
| 143 |
provided job URL to view a variety of on-device performance metrics.
|
| 144 |
```python
|
| 145 |
profile_job = hub.submit_profile_job(
|
| 146 |
+
model=target_model,
|
| 147 |
+
device=device,
|
| 148 |
+
)
|
| 149 |
+
|
| 150 |
```
|
| 151 |
|
| 152 |
Step 3: **Verify on-device accuracy**
|
|
|
|
| 156 |
```python
|
| 157 |
input_data = torch_model.sample_inputs()
|
| 158 |
inference_job = hub.submit_inference_job(
|
| 159 |
+
model=target_model,
|
| 160 |
+
device=device,
|
| 161 |
+
inputs=input_data,
|
| 162 |
+
)
|
| 163 |
+
on_device_output = inference_job.download_output_data()
|
|
|
|
| 164 |
|
| 165 |
```
|
| 166 |
With the output of the model, you can compute like PSNR, relative errors or
|
|
|
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
+
## Run demo on a cloud-hosted device
|
| 175 |
+
|
| 176 |
+
You can also run the demo on-device.
|
| 177 |
+
|
| 178 |
+
```bash
|
| 179 |
+
python -m qai_hub_models.models.ffnet_54s.demo --on-device
|
| 180 |
+
```
|
| 181 |
+
|
| 182 |
+
**NOTE**: If you want running in a Jupyter Notebook or Google Colab like
|
| 183 |
+
environment, please add the following to your cell (instead of the above).
|
| 184 |
+
```
|
| 185 |
+
%run -m qai_hub_models.models.ffnet_54s.demo -- --on-device
|
| 186 |
+
```
|
| 187 |
+
|
| 188 |
|
| 189 |
## Deploying compiled model to Android
|
| 190 |
|