v0.46.1
Browse filesSee https://github.com/quic/ai-hub-models/releases/v0.46.1 for changelog.
- OpenAI-Clip_float.dlc +0 -3
- OpenAI-Clip_float.onnx.zip +0 -3
- OpenAI-Clip_float.tflite +0 -3
- README.md +74 -213
- tool-versions.yaml +0 -4
OpenAI-Clip_float.dlc
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:b9d43080f00ad5214d7268b1a90ea2313a02f33e99082fd5e156b09217fc0bbb
|
| 3 |
-
size 599439284
|
|
|
|
|
|
|
|
|
|
|
|
OpenAI-Clip_float.onnx.zip
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:bbd9cf0f9a317b3400283b9dab145a843e4a7ba4bf7396c3a273d0073ccf49ef
|
| 3 |
-
size 406345322
|
|
|
|
|
|
|
|
|
|
|
|
OpenAI-Clip_float.tflite
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:4cc191e297a62574c8f713be4324796c79da5a6ea859c1754e962a84d0e5959a
|
| 3 |
-
size 598745484
|
|
|
|
|
|
|
|
|
|
|
|
README.md
CHANGED
|
@@ -10,231 +10,92 @@ pipeline_tag: image-classification
|
|
| 10 |
|
| 11 |

|
| 12 |
|
| 13 |
-
# OpenAI-Clip: Optimized for
|
| 14 |
-
## Multi-modal foundational model for vision and language tasks like image/text similarity and for zero-shot image classification
|
| 15 |
-
|
| 16 |
|
| 17 |
Contrastive Language-Image Pre-Training (CLIP) uses a ViT like transformer to get visual features and a causal language model to get the text features. Both the text and visual features can then be used for a variety of zero-shot learning tasks.
|
| 18 |
|
| 19 |
-
This
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 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 |
-
| OpenAI-Clip |
|
| 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 |
-
## Demo off target
|
| 94 |
-
|
| 95 |
-
The package contains a simple end-to-end demo that downloads pre-trained
|
| 96 |
-
weights and runs this model on a sample input.
|
| 97 |
-
|
| 98 |
-
```bash
|
| 99 |
-
python -m qai_hub_models.models.openai_clip.demo
|
| 100 |
-
```
|
| 101 |
-
|
| 102 |
-
The above demo runs a reference implementation of pre-processing, model
|
| 103 |
-
inference, and post processing.
|
| 104 |
-
|
| 105 |
-
**NOTE**: If you want running in a Jupyter Notebook or Google Colab like
|
| 106 |
-
environment, please add the following to your cell (instead of the above).
|
| 107 |
-
```
|
| 108 |
-
%run -m qai_hub_models.models.openai_clip.demo
|
| 109 |
-
```
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
### Run model on a cloud-hosted device
|
| 113 |
-
|
| 114 |
-
In addition to the demo, you can also run the model on a cloud-hosted Qualcomm®
|
| 115 |
-
device. This script does the following:
|
| 116 |
-
* Performance check on-device on a cloud-hosted device
|
| 117 |
-
* Downloads compiled assets that can be deployed on-device for Android.
|
| 118 |
-
* Accuracy check between PyTorch and on-device outputs.
|
| 119 |
-
|
| 120 |
-
```bash
|
| 121 |
-
python -m qai_hub_models.models.openai_clip.export
|
| 122 |
-
```
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
## How does this work?
|
| 127 |
-
|
| 128 |
-
This [export script](https://aihub.qualcomm.com/models/openai_clip/qai_hub_models/models/OpenAI-Clip/export.py)
|
| 129 |
-
leverages [Qualcomm® AI Hub](https://aihub.qualcomm.com/) to optimize, validate, and deploy this model
|
| 130 |
-
on-device. Lets go through each step below in detail:
|
| 131 |
-
|
| 132 |
-
Step 1: **Compile model for on-device deployment**
|
| 133 |
-
|
| 134 |
-
To compile a PyTorch model for on-device deployment, we first trace the model
|
| 135 |
-
in memory using the `jit.trace` and then call the `submit_compile_job` API.
|
| 136 |
-
|
| 137 |
-
```python
|
| 138 |
-
import torch
|
| 139 |
-
|
| 140 |
-
import qai_hub as hub
|
| 141 |
-
from qai_hub_models.models.openai_clip import Model
|
| 142 |
-
|
| 143 |
-
# Load the model
|
| 144 |
-
torch_model = Model.from_pretrained()
|
| 145 |
-
|
| 146 |
-
# Device
|
| 147 |
-
device = hub.Device("Samsung Galaxy S25")
|
| 148 |
-
|
| 149 |
-
# Trace model
|
| 150 |
-
input_shape = torch_model.get_input_spec()
|
| 151 |
-
sample_inputs = torch_model.sample_inputs()
|
| 152 |
-
|
| 153 |
-
pt_model = torch.jit.trace(torch_model, [torch.tensor(data[0]) for _, data in sample_inputs.items()])
|
| 154 |
-
|
| 155 |
-
# Compile model on a specific device
|
| 156 |
-
compile_job = hub.submit_compile_job(
|
| 157 |
-
model=pt_model,
|
| 158 |
-
device=device,
|
| 159 |
-
input_specs=torch_model.get_input_spec(),
|
| 160 |
-
)
|
| 161 |
-
|
| 162 |
-
# Get target model to run on-device
|
| 163 |
-
target_model = compile_job.get_target_model()
|
| 164 |
-
|
| 165 |
-
```
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
Step 2: **Performance profiling on cloud-hosted device**
|
| 169 |
-
|
| 170 |
-
After compiling models from step 1. Models can be profiled model on-device using the
|
| 171 |
-
`target_model`. Note that this scripts runs the model on a device automatically
|
| 172 |
-
provisioned in the cloud. Once the job is submitted, you can navigate to a
|
| 173 |
-
provided job URL to view a variety of on-device performance metrics.
|
| 174 |
-
```python
|
| 175 |
-
profile_job = hub.submit_profile_job(
|
| 176 |
-
model=target_model,
|
| 177 |
-
device=device,
|
| 178 |
-
)
|
| 179 |
-
|
| 180 |
-
```
|
| 181 |
-
|
| 182 |
-
Step 3: **Verify on-device accuracy**
|
| 183 |
-
|
| 184 |
-
To verify the accuracy of the model on-device, you can run on-device inference
|
| 185 |
-
on sample input data on the same cloud hosted device.
|
| 186 |
-
```python
|
| 187 |
-
input_data = torch_model.sample_inputs()
|
| 188 |
-
inference_job = hub.submit_inference_job(
|
| 189 |
-
model=target_model,
|
| 190 |
-
device=device,
|
| 191 |
-
inputs=input_data,
|
| 192 |
-
)
|
| 193 |
-
on_device_output = inference_job.download_output_data()
|
| 194 |
-
|
| 195 |
-
```
|
| 196 |
-
With the output of the model, you can compute like PSNR, relative errors or
|
| 197 |
-
spot check the output with expected output.
|
| 198 |
-
|
| 199 |
-
**Note**: This on-device profiling and inference requires access to Qualcomm®
|
| 200 |
-
AI Hub Workbench. [Sign up for access](https://myaccount.qualcomm.com/signup).
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
## Deploying compiled model to Android
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
The models can be deployed using multiple runtimes:
|
| 209 |
-
- TensorFlow Lite (`.tflite` export): [This
|
| 210 |
-
tutorial](https://www.tensorflow.org/lite/android/quickstart) provides a
|
| 211 |
-
guide to deploy the .tflite model in an Android application.
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
- QNN (`.so` export ): This [sample
|
| 215 |
-
app](https://docs.qualcomm.com/bundle/publicresource/topics/80-63442-50/sample_app.html)
|
| 216 |
-
provides instructions on how to use the `.so` shared library in an Android application.
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
## View on Qualcomm® AI Hub
|
| 220 |
-
Get more details on OpenAI-Clip's performance across various devices [here](https://aihub.qualcomm.com/models/openai_clip).
|
| 221 |
-
Explore all available models on [Qualcomm® AI Hub](https://aihub.qualcomm.com/)
|
| 222 |
-
|
| 223 |
|
| 224 |
## License
|
| 225 |
* The license for the original implementation of OpenAI-Clip can be found
|
| 226 |
[here](https://github.com/openai/CLIP/blob/main/LICENSE).
|
| 227 |
|
| 228 |
-
|
| 229 |
-
|
| 230 |
## References
|
| 231 |
* [Learning Transferable Visual Models From Natural Language Supervision](https://arxiv.org/abs/2103.00020)
|
| 232 |
* [Source Model Implementation](https://github.com/openai/CLIP/)
|
| 233 |
|
| 234 |
-
|
| 235 |
-
|
| 236 |
## Community
|
| 237 |
* Join [our AI Hub Slack community](https://aihub.qualcomm.com/community/slack) to collaborate, post questions and learn more about on-device AI.
|
| 238 |
* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com).
|
| 239 |
-
|
| 240 |
-
|
|
|
|
| 10 |
|
| 11 |

|
| 12 |
|
| 13 |
+
# OpenAI-Clip: Optimized for Qualcomm Devices
|
|
|
|
|
|
|
| 14 |
|
| 15 |
Contrastive Language-Image Pre-Training (CLIP) uses a ViT like transformer to get visual features and a causal language model to get the text features. Both the text and visual features can then be used for a variety of zero-shot learning tasks.
|
| 16 |
|
| 17 |
+
This is based on the implementation of OpenAI-Clip found [here](https://github.com/openai/CLIP/).
|
| 18 |
+
This repository contains pre-exported model files optimized for Qualcomm® devices. You can use the [Qualcomm® AI Hub Models](https://github.com/quic/ai-hub-models/blob/main/qai_hub_models/models/openai_clip) library to export with custom configurations. More details on model performance across various devices, can be found [here](#performance-summary).
|
| 19 |
+
|
| 20 |
+
Qualcomm AI Hub Models uses [Qualcomm AI Hub Workbench](https://workbench.aihub.qualcomm.com) to compile, profile, and evaluate this model. [Sign up](https://myaccount.qualcomm.com/signup) to run these models on a hosted Qualcomm® device.
|
| 21 |
+
|
| 22 |
+
## Getting Started
|
| 23 |
+
There are two ways to deploy this model on your device:
|
| 24 |
+
|
| 25 |
+
### Option 1: Download Pre-Exported Models
|
| 26 |
+
|
| 27 |
+
Below are pre-exported model assets ready for deployment.
|
| 28 |
+
|
| 29 |
+
| Runtime | Precision | Chipset | SDK Versions | Download |
|
| 30 |
+
|---|---|---|---|---|
|
| 31 |
+
| ONNX | float | Universal | QAIRT 2.37, ONNX Runtime 1.23.0 | [Download](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/openai_clip/releases/v0.46.1/openai_clip-onnx-float.zip)
|
| 32 |
+
| QNN_DLC | float | Universal | QAIRT 2.42 | [Download](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/openai_clip/releases/v0.46.1/openai_clip-qnn_dlc-float.zip)
|
| 33 |
+
| TFLITE | float | Universal | QAIRT 2.42, TFLite 2.17.0 | [Download](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/openai_clip/releases/v0.46.1/openai_clip-tflite-float.zip)
|
| 34 |
+
|
| 35 |
+
For more device-specific assets and performance metrics, visit **[OpenAI-Clip on Qualcomm® AI Hub](https://aihub.qualcomm.com/models/openai_clip)**.
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
### Option 2: Export with Custom Configurations
|
| 39 |
+
|
| 40 |
+
Use the [Qualcomm® AI Hub Models](https://github.com/quic/ai-hub-models/blob/main/qai_hub_models/models/openai_clip) Python library to compile and export the model with your own:
|
| 41 |
+
- Custom weights (e.g., fine-tuned checkpoints)
|
| 42 |
+
- Custom input shapes
|
| 43 |
+
- Target device and runtime configurations
|
| 44 |
+
|
| 45 |
+
This option is ideal if you need to customize the model beyond the default configuration provided here.
|
| 46 |
+
|
| 47 |
+
See our repository for [OpenAI-Clip on GitHub](https://github.com/quic/ai-hub-models/blob/main/qai_hub_models/models/openai_clip) for usage instructions.
|
| 48 |
+
|
| 49 |
+
## Model Details
|
| 50 |
+
|
| 51 |
+
**Model Type:** Model_use_case.image_classification
|
| 52 |
+
|
| 53 |
+
**Model Stats:**
|
| 54 |
+
- Model checkpoint: ViT-B/16
|
| 55 |
+
- Image input resolution: 224x224
|
| 56 |
+
- Text context length: 77
|
| 57 |
+
- Number of parameters: 150M
|
| 58 |
+
- Model size (float): 571 MB
|
| 59 |
+
|
| 60 |
+
## Performance Summary
|
| 61 |
+
| Model | Runtime | Precision | Chipset | Inference Time (ms) | Peak Memory Range (MB) | Primary Compute Unit
|
| 62 |
+
|---|---|---|---|---|---|---
|
| 63 |
+
| OpenAI-Clip | ONNX | float | Snapdragon® X Elite | 22.459 ms | 294 - 294 MB | NPU
|
| 64 |
+
| OpenAI-Clip | ONNX | float | Snapdragon® 8 Gen 3 Mobile | 15.269 ms | 0 - 796 MB | NPU
|
| 65 |
+
| OpenAI-Clip | ONNX | float | Qualcomm® QCS8550 (Proxy) | 22.212 ms | 0 - 323 MB | NPU
|
| 66 |
+
| OpenAI-Clip | ONNX | float | Qualcomm® QCS9075 | 25.758 ms | 0 - 4 MB | NPU
|
| 67 |
+
| OpenAI-Clip | ONNX | float | Snapdragon® 8 Elite For Galaxy Mobile | 12.318 ms | 1 - 713 MB | NPU
|
| 68 |
+
| OpenAI-Clip | ONNX | float | Snapdragon® 8 Elite Gen 5 Mobile | 10.095 ms | 1 - 661 MB | NPU
|
| 69 |
+
| OpenAI-Clip | QNN_DLC | float | Snapdragon® X Elite | 18.808 ms | 1 - 1 MB | NPU
|
| 70 |
+
| OpenAI-Clip | QNN_DLC | float | Snapdragon® 8 Gen 3 Mobile | 12.624 ms | 0 - 550 MB | NPU
|
| 71 |
+
| OpenAI-Clip | QNN_DLC | float | Qualcomm® QCS8275 (Proxy) | 55.883 ms | 1 - 507 MB | NPU
|
| 72 |
+
| OpenAI-Clip | QNN_DLC | float | Qualcomm® QCS8550 (Proxy) | 17.922 ms | 1 - 593 MB | NPU
|
| 73 |
+
| OpenAI-Clip | QNN_DLC | float | Qualcomm® SA8775P | 20.876 ms | 1 - 504 MB | NPU
|
| 74 |
+
| OpenAI-Clip | QNN_DLC | float | Qualcomm�� QCS9075 | 20.902 ms | 1 - 3 MB | NPU
|
| 75 |
+
| OpenAI-Clip | QNN_DLC | float | Qualcomm® QCS8450 (Proxy) | 21.094 ms | 0 - 501 MB | NPU
|
| 76 |
+
| OpenAI-Clip | QNN_DLC | float | Qualcomm® SA7255P | 55.883 ms | 1 - 507 MB | NPU
|
| 77 |
+
| OpenAI-Clip | QNN_DLC | float | Qualcomm® SA8295P | 22.195 ms | 0 - 492 MB | NPU
|
| 78 |
+
| OpenAI-Clip | QNN_DLC | float | Snapdragon® 8 Elite For Galaxy Mobile | 10.588 ms | 1 - 515 MB | NPU
|
| 79 |
+
| OpenAI-Clip | QNN_DLC | float | Snapdragon® 8 Elite Gen 5 Mobile | 8.462 ms | 0 - 485 MB | NPU
|
| 80 |
+
| OpenAI-Clip | TFLITE | float | Snapdragon® 8 Gen 3 Mobile | 11.008 ms | 0 - 562 MB | NPU
|
| 81 |
+
| OpenAI-Clip | TFLITE | float | Qualcomm® QCS8275 (Proxy) | 52.168 ms | 0 - 512 MB | NPU
|
| 82 |
+
| OpenAI-Clip | TFLITE | float | Qualcomm® QCS8550 (Proxy) | 15.689 ms | 0 - 4 MB | NPU
|
| 83 |
+
| OpenAI-Clip | TFLITE | float | Qualcomm® SA8775P | 18.638 ms | 0 - 509 MB | NPU
|
| 84 |
+
| OpenAI-Clip | TFLITE | float | Qualcomm® QCS9075 | 20.357 ms | 0 - 294 MB | NPU
|
| 85 |
+
| OpenAI-Clip | TFLITE | float | Qualcomm® QCS8450 (Proxy) | 20.361 ms | 0 - 503 MB | NPU
|
| 86 |
+
| OpenAI-Clip | TFLITE | float | Qualcomm® SA7255P | 52.168 ms | 0 - 512 MB | NPU
|
| 87 |
+
| OpenAI-Clip | TFLITE | float | Qualcomm® SA8295P | 21.567 ms | 0 - 495 MB | NPU
|
| 88 |
+
| OpenAI-Clip | TFLITE | float | Snapdragon® 8 Elite For Galaxy Mobile | 9.059 ms | 0 - 526 MB | NPU
|
| 89 |
+
| OpenAI-Clip | TFLITE | float | Snapdragon® 8 Elite Gen 5 Mobile | 7.023 ms | 0 - 497 MB | NPU
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
|
| 91 |
## License
|
| 92 |
* The license for the original implementation of OpenAI-Clip can be found
|
| 93 |
[here](https://github.com/openai/CLIP/blob/main/LICENSE).
|
| 94 |
|
|
|
|
|
|
|
| 95 |
## References
|
| 96 |
* [Learning Transferable Visual Models From Natural Language Supervision](https://arxiv.org/abs/2103.00020)
|
| 97 |
* [Source Model Implementation](https://github.com/openai/CLIP/)
|
| 98 |
|
|
|
|
|
|
|
| 99 |
## Community
|
| 100 |
* Join [our AI Hub Slack community](https://aihub.qualcomm.com/community/slack) to collaborate, post questions and learn more about on-device AI.
|
| 101 |
* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com).
|
|
|
|
|
|
tool-versions.yaml
DELETED
|
@@ -1,4 +0,0 @@
|
|
| 1 |
-
tool_versions:
|
| 2 |
-
onnx:
|
| 3 |
-
qairt: 2.37.1.250807093845_124904
|
| 4 |
-
onnx_runtime: 1.23.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|