v0.51.0
Browse filesSee https://github.com/qualcomm/ai-hub-models/releases/v0.51.0 for changelog.
Files changed (5)
- README.md+98-214
- SwinV2-Base_float.onnx.zipDeleted-3
- SwinV2-Base_float.tfliteDeleted-3
- release_assets.jsonAdded+46
- tool-versions.yamlDeleted-4
10 unmodified lines111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124210 unmodified lines# SwinV2-Base: Optimized for Mobile Deployment## Imagenet classifier and general purpose backboneSwinV2Base is a machine learning model that can classify images from the Imagenet dataset. It can also be used as a backbone in building more complex models for specific use cases.This model is an implementation of SwinV2-Base found [here](https://github.com/pytorch/vision/blob/main/torchvision/models/swin_transformer.py).This repository provides scripts to run SwinV2-Base on Qualcomm® devices.More details on model performance across various devices, can be found[here](https://aihub.qualcomm.com/models/swinv2_base).### Model Details- **Model Type:** Model_use_case.image_classification- **Model Stats:**- Model checkpoint: Imagenet- Input resolution: 256x256- Number of parameters: 88.8M- Model size (float): 339 MB- Model size (w8a16): 90.2 MB| Model | Precision | Device | Chipset | Target Runtime | Inference Time (ms) | Peak Memory Range (MB) | Primary Compute Unit | Target Model|---|---|---|---|---|---|---|---|---|| SwinV2-Base | float | QCS8275 (Proxy) | Qualcomm® QCS8275 (Proxy) | TFLITE | 81.861 ms | 0 - 614 MB | NPU | [SwinV2-Base.tflite](https://huggingface.co/qualcomm/SwinV2-Base/blob/main/SwinV2-Base.tflite) || SwinV2-Base | float | QCS8450 (Proxy) | Qualcomm® QCS8450 (Proxy) | TFLITE | 46.905 ms | 0 - 730 MB | NPU | [SwinV2-Base.tflite](https://huggingface.co/qualcomm/SwinV2-Base/blob/main/SwinV2-Base.tflite) || SwinV2-Base | float | QCS8550 (Proxy) | Qualcomm® QCS8550 (Proxy) | TFLITE | 35.029 ms | 0 - 4 MB | NPU | [SwinV2-Base.tflite](https://huggingface.co/qualcomm/SwinV2-Base/blob/main/SwinV2-Base.tflite) || SwinV2-Base | float | QCS9075 (Proxy) | Qualcomm® QCS9075 (Proxy) | TFLITE | 38.721 ms | 0 - 596 MB | NPU | [SwinV2-Base.tflite](https://huggingface.co/qualcomm/SwinV2-Base/blob/main/SwinV2-Base.tflite) || SwinV2-Base | float | SA7255P ADP | Qualcomm® SA7255P | TFLITE | 81.861 ms | 0 - 614 MB | NPU | [SwinV2-Base.tflite](https://huggingface.co/qualcomm/SwinV2-Base/blob/main/SwinV2-Base.tflite) || SwinV2-Base | float | SA8295P ADP | Qualcomm® SA8295P | TFLITE | 47.037 ms | 0 - 581 MB | NPU | [SwinV2-Base.tflite](https://huggingface.co/qualcomm/SwinV2-Base/blob/main/SwinV2-Base.tflite) || SwinV2-Base | float | SA8775P ADP | Qualcomm® SA8775P | TFLITE | 38.721 ms | 0 - 596 MB | NPU | [SwinV2-Base.tflite](https://huggingface.co/qualcomm/SwinV2-Base/blob/main/SwinV2-Base.tflite) || SwinV2-Base | float | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | TFLITE | 24.258 ms | 0 - 745 MB | NPU | [SwinV2-Base.tflite](https://huggingface.co/qualcomm/SwinV2-Base/blob/main/SwinV2-Base.tflite) || SwinV2-Base | float | Samsung Galaxy S25 | Snapdragon® 8 Elite For Galaxy Mobile | TFLITE | 17.996 ms | 0 - 600 MB | NPU | [SwinV2-Base.tflite](https://huggingface.co/qualcomm/SwinV2-Base/blob/main/SwinV2-Base.tflite) || SwinV2-Base | float | Samsung Galaxy S25 | Snapdragon® 8 Elite For Galaxy Mobile | ONNX | 35.181 ms | 30 - 290 MB | NPU | [SwinV2-Base.onnx.zip](https://huggingface.co/qualcomm/SwinV2-Base/blob/main/SwinV2-Base.onnx.zip) || SwinV2-Base | float | Snapdragon 8 Elite Gen 5 QRD | Snapdragon® 8 Elite Gen 5 Mobile | TFLITE | 14.619 ms | 0 - 653 MB | NPU | [SwinV2-Base.tflite](https://huggingface.co/qualcomm/SwinV2-Base/blob/main/SwinV2-Base.tflite) || SwinV2-Base | float | Snapdragon 8 Elite Gen 5 QRD | Snapdragon® 8 Elite Gen 5 Mobile | ONNX | 40.283 ms | 29 - 318 MB | NPU | [SwinV2-Base.onnx.zip](https://huggingface.co/qualcomm/SwinV2-Base/blob/main/SwinV2-Base.onnx.zip) || SwinV2-Base | float | Snapdragon X Elite CRD | Snapdragon® X Elite | ONNX | 64.884 ms | 178 - 178 MB | NPU | [SwinV2-Base.onnx.zip](https://huggingface.co/qualcomm/SwinV2-Base/blob/main/SwinV2-Base.onnx.zip) |## InstallationInstall the package via pip:```bashpip install qai-hub-models```## Configure Qualcomm® AI Hub Workbench to run this model on a cloud-hosted deviceSign-in to [Qualcomm® AI Hub Workbench](https://workbench.aihub.qualcomm.com/) with yourQualcomm® ID. Once signed in navigate to `Account -> Settings -> API Token`.With this API token, you can configure your client to run models on the cloudhosted devices.```bashqai-hub configure --api_token API_TOKEN```Navigate to [docs](https://workbench.aihub.qualcomm.com/docs/) for more information.## Demo off targetThe package contains a simple end-to-end demo that downloads pre-trainedweights and runs this model on a sample input.```bashpython -m qai_hub_models.models.swinv2_base.demo```The above demo runs a reference implementation of pre-processing, modelinference, and post processing.**NOTE**: If you want running in a Jupyter Notebook or Google Colab likeenvironment, please add the following to your cell (instead of the above).```%run -m qai_hub_models.models.swinv2_base.demo```### Run model on a cloud-hosted deviceIn addition to the demo, you can also run the model on a cloud-hosted Qualcomm®device. This script does the following:* Performance check on-device on a cloud-hosted device* Downloads compiled assets that can be deployed on-device for Android.* Accuracy check between PyTorch and on-device outputs.```bashpython -m qai_hub_models.models.swinv2_base.export```## How does this work?This [export script](https://aihub.qualcomm.com/models/swinv2_base/qai_hub_models/models/SwinV2-Base/export.py)leverages [Qualcomm® AI Hub](https://aihub.qualcomm.com/) to optimize, validate, and deploy this modelon-device. Lets go through each step below in detail:Step 1: **Compile model for on-device deployment**To compile a PyTorch model for on-device deployment, we first trace the modelin memory using the `jit.trace` and then call the `submit_compile_job` API.```pythonimport torchimport qai_hub as hubfrom qai_hub_models.models.swinv2_base import Model# Load the modeltorch_model = Model.from_pretrained()# Devicedevice = hub.Device("Samsung Galaxy S25")# Trace modelinput_shape = torch_model.get_input_spec()sample_inputs = torch_model.sample_inputs()pt_model = torch.jit.trace(torch_model, [torch.tensor(data[0]) for _, data in sample_inputs.items()])# Compile model on a specific devicecompile_job = hub.submit_compile_job(model=pt_model,device=device,input_specs=torch_model.get_input_spec(),)# Get target model to run on-devicetarget_model = compile_job.get_target_model()```Step 2: **Performance profiling on cloud-hosted device**After compiling models from step 1. Models can be profiled model on-device using the`target_model`. Note that this scripts runs the model on a device automaticallyprovisioned in the cloud. Once the job is submitted, you can navigate to aprovided job URL to view a variety of on-device performance metrics.```pythonprofile_job = hub.submit_profile_job(model=target_model,device=device,)```Step 3: **Verify on-device accuracy**To verify the accuracy of the model on-device, you can run on-device inferenceon sample input data on the same cloud hosted device.```pythoninput_data = torch_model.sample_inputs()inference_job = hub.submit_inference_job(model=target_model,device=device,inputs=input_data,)on_device_output = inference_job.download_output_data()```With the output of the model, you can compute like PSNR, relative errors orspot check the output with expected output.**Note**: This on-device profiling and inference requires access to Qualcomm®AI Hub Workbench. [Sign up for access](https://myaccount.qualcomm.com/signup).## Run demo on a cloud-hosted deviceYou can also run the demo on-device.```bashpython -m qai_hub_models.models.swinv2_base.demo --eval-mode on-device```**NOTE**: If you want running in a Jupyter Notebook or Google Colab likeenvironment, please add the following to your cell (instead of the above).```%run -m qai_hub_models.models.swinv2_base.demo -- --eval-mode on-device```## Deploying compiled model to AndroidThe models can be deployed using multiple runtimes:- TensorFlow Lite (`.tflite` export): [Thistutorial](https://www.tensorflow.org/lite/android/quickstart) provides aguide to deploy the .tflite model in an Android application.- QNN (`.so` export ): This [sampleapp](https://docs.qualcomm.com/bundle/publicresource/topics/80-63442-50/sample_app.html)provides instructions on how to use the `.so` shared library in an Android application.## View on Qualcomm® AI HubGet more details on SwinV2-Base's performance across various devices [here](https://aihub.qualcomm.com/models/swinv2_base).Explore all available models on [Qualcomm® AI Hub](https://aihub.qualcomm.com/)## License* The license for the original implementation of SwinV2-Base can be found[here](https://github.com/pytorch/vision/blob/main/LICENSE).## References* [Swin Transformer V2: Scaling Up Capacity and Resolution](https://arxiv.org/abs/2111.09883)* [Source Model Implementation](https://github.com/pytorch/vision/blob/main/torchvision/models/swin_transformer.py)## Community* Join [our AI Hub Slack community](https://aihub.qualcomm.com/community/slack) to collaborate, post questions and learn more about on-device AI.* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com).10 unmodified lines111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512610 unmodified lines# SwinV2-Base: Optimized for Qualcomm DevicesSwinV2Base is a machine learning model that can classify images from the Imagenet dataset. It can also be used as a backbone in building more complex models for specific use cases.This is based on the implementation of SwinV2-Base found [here](https://github.com/pytorch/vision/blob/main/torchvision/models/swin_transformer.py).This repository contains pre-exported model files optimized for Qualcomm® devices. You can use the [Qualcomm® AI Hub Models](https://github.com/qualcomm/ai-hub-models/blob/main/src/qai_hub_models/models/swinv2_base) library to export with custom configurations. More details on model performance across various devices, can be found [here](#performance-summary).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.## Getting StartedThere are two ways to deploy this model on your device:### Option 1: Download Pre-Exported ModelsBelow are pre-exported model assets ready for deployment.| Runtime | Precision | Chipset | SDK Versions | Download ||---|---|---|---|---|| ONNX | float | Universal | QAIRT 2.42, ONNX Runtime 1.24.3 | [Download](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/swinv2_base/releases/v0.51.0/swinv2_base-onnx-float.zip)| ONNX | w8a16 | Universal | QAIRT 2.42, ONNX Runtime 1.24.3 | [Download](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/swinv2_base/releases/v0.51.0/swinv2_base-onnx-w8a16.zip)| QNN_DLC | float | Universal | QAIRT 2.45 | [Download](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/swinv2_base/releases/v0.51.0/swinv2_base-qnn_dlc-float.zip)| QNN_DLC | w8a16 | Universal | QAIRT 2.45 | [Download](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/swinv2_base/releases/v0.51.0/swinv2_base-qnn_dlc-w8a16.zip)| TFLITE | float | Universal | QAIRT 2.45 | [Download](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/swinv2_base/releases/v0.51.0/swinv2_base-tflite-float.zip)For more device-specific assets and performance metrics, visit **[SwinV2-Base on Qualcomm® AI Hub](https://aihub.qualcomm.com/models/swinv2_base)**.### Option 2: Export with Custom ConfigurationsUse the [Qualcomm® AI Hub Models](https://github.com/qualcomm/ai-hub-models/blob/main/src/qai_hub_models/models/swinv2_base) Python library to compile and export the model with your own:- Custom weights (e.g., fine-tuned checkpoints)- Custom input shapes- Target device and runtime configurationsThis option is ideal if you need to customize the model beyond the default configuration provided here.See our repository for [SwinV2-Base on GitHub](https://github.com/qualcomm/ai-hub-models/blob/main/src/qai_hub_models/models/swinv2_base) for usage instructions.## Model Details**Model Type:** Model_use_case.image_classification**Model Stats:**- Model checkpoint: Imagenet- Input resolution: 256x256- Number of parameters: 88.8M- Model size (float): 339 MB- Model size (w8a16): 90.2 MB## Performance Summary| Model | Runtime | Precision | Chipset | Inference Time (ms) | Peak Memory Range (MB) | Primary Compute Unit|---|---|---|---|---|---|---| SwinV2-Base | ONNX | float | Snapdragon® 8 Elite Gen 5 Mobile | 11.733 ms | 1 - 1020 MB | NPU| SwinV2-Base | ONNX | float | Snapdragon® X2 Elite | 12.544 ms | 179 - 179 MB | NPU| SwinV2-Base | ONNX | float | Snapdragon® X Elite | 32.734 ms | 178 - 178 MB | NPU| SwinV2-Base | ONNX | float | Snapdragon® 8 Gen 3 Mobile | 21.746 ms | 0 - 2329 MB | NPU| SwinV2-Base | ONNX | float | Qualcomm® QCS8550 (Proxy) | 31.491 ms | 0 - 196 MB | NPU| SwinV2-Base | ONNX | float | Qualcomm® QCS9075 | 38.785 ms | 0 - 4 MB | NPU| SwinV2-Base | ONNX | float | Snapdragon® 8 Elite For Galaxy Mobile | 16.303 ms | 0 - 1012 MB | NPU| SwinV2-Base | ONNX | w8a16 | Snapdragon® 8 Elite Gen 5 Mobile | 11.395 ms | 0 - 1005 MB | NPU| SwinV2-Base | ONNX | w8a16 | Snapdragon® X2 Elite | 12.122 ms | 97 - 97 MB | NPU| SwinV2-Base | ONNX | w8a16 | Snapdragon® X Elite | 31.018 ms | 97 - 97 MB | NPU| SwinV2-Base | ONNX | w8a16 | Snapdragon® 8 Gen 3 Mobile | 20.319 ms | 0 - 1295 MB | NPU| SwinV2-Base | ONNX | w8a16 | Qualcomm® QCS6490 | 1306.327 ms | 62 - 91 MB | CPU| SwinV2-Base | ONNX | w8a16 | Qualcomm® QCS8550 (Proxy) | 29.734 ms | 0 - 102 MB | NPU| SwinV2-Base | ONNX | w8a16 | Qualcomm® QCS9075 | 34.846 ms | 0 - 3 MB | NPU| SwinV2-Base | ONNX | w8a16 | Qualcomm® QCM6690 | 713.751 ms | 80 - 101 MB | CPU| SwinV2-Base | ONNX | w8a16 | Snapdragon® 8 Elite For Galaxy Mobile | 14.665 ms | 0 - 866 MB | NPU| SwinV2-Base | ONNX | w8a16 | Snapdragon® 7 Gen 4 Mobile | 662.899 ms | 156 - 178 MB | CPU| SwinV2-Base | QNN_DLC | float | Snapdragon® 8 Elite Gen 5 Mobile | 11.557 ms | 0 - 424 MB | NPU| SwinV2-Base | QNN_DLC | float | Snapdragon® X2 Elite | 12.375 ms | 1 - 1 MB | NPU| SwinV2-Base | QNN_DLC | float | Snapdragon® X Elite | 29.74 ms | 1 - 1 MB | NPU| SwinV2-Base | QNN_DLC | float | Snapdragon® 8 Gen 3 Mobile | 19.935 ms | 1 - 552 MB | NPU| SwinV2-Base | QNN_DLC | float | Qualcomm® QCS8275 (Proxy) | 74.006 ms | 1 - 393 MB | NPU| SwinV2-Base | QNN_DLC | float | Qualcomm® QCS8550 (Proxy) | 28.682 ms | 1 - 3 MB | NPU| SwinV2-Base | QNN_DLC | float | Qualcomm® SA8775P | 31.978 ms | 1 - 392 MB | NPU| SwinV2-Base | QNN_DLC | float | Qualcomm® QCS9075 | 37.916 ms | 1 - 3 MB | NPU| SwinV2-Base | QNN_DLC | float | Qualcomm® QCS8450 (Proxy) | 44.29 ms | 0 - 538 MB | NPU| SwinV2-Base | QNN_DLC | float | Qualcomm® SA7255P | 74.006 ms | 1 - 393 MB | NPU| SwinV2-Base | QNN_DLC | float | Qualcomm® SA8295P | 38.42 ms | 1 - 384 MB | NPU| SwinV2-Base | QNN_DLC | float | Snapdragon® 8 Elite For Galaxy Mobile | 15.045 ms | 1 - 398 MB | NPU| SwinV2-Base | QNN_DLC | w8a16 | Snapdragon® 8 Elite Gen 5 Mobile | 11.362 ms | 0 - 943 MB | NPU| SwinV2-Base | QNN_DLC | w8a16 | Snapdragon® X2 Elite | 12.461 ms | 0 - 0 MB | NPU| SwinV2-Base | QNN_DLC | w8a16 | Snapdragon® X Elite | 31.327 ms | 0 - 0 MB | NPU| SwinV2-Base | QNN_DLC | w8a16 | Snapdragon® 8 Gen 3 Mobile | 20.03 ms | 0 - 621 MB | NPU| SwinV2-Base | QNN_DLC | w8a16 | Qualcomm® QCS8275 (Proxy) | 53.241 ms | 0 - 934 MB | NPU| SwinV2-Base | QNN_DLC | w8a16 | Qualcomm® QCS8550 (Proxy) | 29.722 ms | 0 - 3 MB | NPU| SwinV2-Base | QNN_DLC | w8a16 | Qualcomm® SA8775P | 29.923 ms | 0 - 916 MB | NPU| SwinV2-Base | QNN_DLC | w8a16 | Qualcomm® QCS9075 | 36.121 ms | 0 - 2 MB | NPU| SwinV2-Base | QNN_DLC | w8a16 | Qualcomm® SA7255P | 53.241 ms | 0 - 934 MB | NPU| SwinV2-Base | QNN_DLC | w8a16 | Snapdragon® 8 Elite For Galaxy Mobile | 15.127 ms | 0 - 888 MB | NPU| SwinV2-Base | TFLITE | float | Snapdragon® 8 Elite Gen 5 Mobile | 11.961 ms | 0 - 969 MB | NPU| SwinV2-Base | TFLITE | float | Snapdragon® 8 Gen 3 Mobile | 21.923 ms | 0 - 655 MB | NPU| SwinV2-Base | TFLITE | float | Qualcomm® QCS8275 (Proxy) | 75.284 ms | 0 - 902 MB | NPU| SwinV2-Base | TFLITE | float | Qualcomm® QCS8550 (Proxy) | 32.027 ms | 0 - 3 MB | NPU| SwinV2-Base | TFLITE | float | Qualcomm® SA8775P | 35.296 ms | 0 - 847 MB | NPU| SwinV2-Base | TFLITE | float | Qualcomm® QCS9075 | 39.731 ms | 0 - 180 MB | NPU| SwinV2-Base | TFLITE | float | Qualcomm® QCS8450 (Proxy) | 46.679 ms | 0 - 647 MB | NPU| SwinV2-Base | TFLITE | float | Qualcomm® SA7255P | 75.284 ms | 0 - 902 MB | NPU| SwinV2-Base | TFLITE | float | Qualcomm® SA8295P | 43.86 ms | 0 - 474 MB | NPU| SwinV2-Base | TFLITE | float | Snapdragon® 8 Elite For Galaxy Mobile | 15.94 ms | 0 - 904 MB | NPU## License* The license for the original implementation of SwinV2-Base can be found[here](https://github.com/pytorch/vision/blob/main/LICENSE).## References* [Swin Transformer V2: Scaling Up Capacity and Resolution](https://arxiv.org/abs/2111.09883)* [Source Model Implementation](https://github.com/pytorch/vision/blob/main/torchvision/models/swin_transformer.py)## Community* Join [our AI Hub Slack community](https://aihub.qualcomm.com/community/slack) to collaborate, post questions and learn more about on-device AI.* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com).
123version https://git-lfs.github.com/spec/v1oid sha256:bab753a0fc91d87a3d3e1f56694758806724e539f1e1f33a2e495176286e0b58size 326861095123version https://git-lfs.github.com/spec/v1oid sha256:6d807396b2b0ac7c07d521029ab4c3bf4203b5a38382d91e675369392a780f12size 36182621612345678910111213141516171819202122232425262728293031323334353637383940414243444546{ "version": "0.51.0", "precisions": { "float": { "universal_assets": { "tflite": { "tool_versions": { "qairt": "2.45.0.260326154327", "litert": "1.4.2" }, "download_url": "https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/swinv2_base/releases/v0.51.0/swinv2_base-tflite-float.zip" }, "qnn_dlc": { "tool_versions": { "qairt": "2.45.0.260326154327" }, "download_url": "https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/swinv2_base/releases/v0.51.0/swinv2_base-qnn_dlc-float.zip" }, "onnx": { "tool_versions": { "qairt": "2.42.0.251225135753_193295", "onnx_runtime": "1.24.3" }, "download_url": "https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/swinv2_base/releases/v0.51.0/swinv2_base-onnx-float.zip" } } }, "w8a16": { "universal_assets": { "qnn_dlc": { "tool_versions": { "qairt": "2.45.0.260326154327" }, "download_url": "https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/swinv2_base/releases/v0.51.0/swinv2_base-qnn_dlc-w8a16.zip" }, "onnx": { "tool_versions": { "qairt": "2.42.0.251225135753_193295", "onnx_runtime": "1.24.3" }, "download_url": "https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/swinv2_base/releases/v0.51.0/swinv2_base-onnx-w8a16.zip" } } } }}1234tool_versions: onnx: qairt: 2.37.1.250807093845_124904 onnx_runtime: 1.23.0README.md+98-214
SwinV2-Base_float.onnx.zipDeleted-3
SwinV2-Base_float.tfliteDeleted-3
release_assets.jsonAdded+46
tool-versions.yamlDeleted-4