--- library_name: pytorch license: other tags: - foundation - android pipeline_tag: image-segmentation --- ![](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/mobilesam/web-assets/model_demo.png) # MobileSam: Optimized for Qualcomm Devices Transformer based encoder-decoder where prompts specify what to segment in an image thereby allowing segmentation without the need for additional training. The image encoder generates embeddings and the lightweight decoder operates on the embeddings for point and mask based image segmentation. This is based on the implementation of MobileSam found [here](https://github.com/facebookresearch/segment-anything). 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/mobilesam) 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 Started There are two ways to deploy this model on your device: ### Option 1: Download Pre-Exported Models Below 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/mobilesam/releases/v0.52.0/mobilesam-onnx-float.zip) | QNN_DLC | float | Universal | QAIRT 2.45 | [Download](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/mobilesam/releases/v0.52.0/mobilesam-qnn_dlc-float.zip) | TFLITE | float | Universal | QAIRT 2.45 | [Download](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/mobilesam/releases/v0.52.0/mobilesam-tflite-float.zip) For more device-specific assets and performance metrics, visit **[MobileSam on Qualcomm® AI Hub](https://aihub.qualcomm.com/models/mobilesam)**. ### Option 2: Export with Custom Configurations Use the [Qualcomm® AI Hub Models](https://github.com/qualcomm/ai-hub-models/blob/main/src/qai_hub_models/models/mobilesam) 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 configurations This option is ideal if you need to customize the model beyond the default configuration provided here. See our repository for [MobileSam on GitHub](https://github.com/qualcomm/ai-hub-models/blob/main/src/qai_hub_models/models/mobilesam) for usage instructions. ## Model Details **Model Type:** Model_use_case.semantic_segmentation **Model Stats:** - Model checkpoint: vit_t - Input resolution: 720p (720x1280) - Number of parameters (sam_encoder): 6.95M - Model size (sam_encoder) (float): 26.6 MB - Number of parameters (sam_decoder): 6.16M - Model size (sam_decoder) (float): 23.7 MB ## Performance Summary | Model | Runtime | Precision | Chipset | Inference Time (ms) | Peak Memory Range (MB) | Primary Compute Unit |---|---|---|---|---|---|--- | decoder | ONNX | float | Snapdragon® 8 Elite Gen 5 Mobile | 2.952 ms | 0 - 242 MB | NPU | decoder | ONNX | float | Snapdragon® X2 Elite | 3.025 ms | 11 - 11 MB | NPU | decoder | ONNX | float | Snapdragon® X Elite | 7.599 ms | 11 - 11 MB | NPU | decoder | ONNX | float | Snapdragon® 8 Gen 3 Mobile | 4.963 ms | 5 - 268 MB | NPU | decoder | ONNX | float | Qualcomm® QCS8550 (Proxy) | 7.126 ms | 0 - 17 MB | NPU | decoder | ONNX | float | Qualcomm® QCS9075 | 8.461 ms | 4 - 7 MB | NPU | decoder | ONNX | float | Snapdragon® 8 Elite For Galaxy Mobile | 3.676 ms | 1 - 231 MB | NPU | decoder | QNN_DLC | float | Snapdragon® 8 Elite Gen 5 Mobile | 2.118 ms | 2 - 188 MB | NPU | decoder | QNN_DLC | float | Snapdragon® X2 Elite | 2.59 ms | 4 - 4 MB | NPU | decoder | QNN_DLC | float | Snapdragon® X Elite | 5.173 ms | 4 - 4 MB | NPU | decoder | QNN_DLC | float | Snapdragon® 8 Gen 3 Mobile | 3.366 ms | 4 - 213 MB | NPU | decoder | QNN_DLC | float | Qualcomm® QCS8275 (Proxy) | 11.694 ms | 1 - 184 MB | NPU | decoder | QNN_DLC | float | Qualcomm® QCS8550 (Proxy) | 4.808 ms | 4 - 6 MB | NPU | decoder | QNN_DLC | float | Qualcomm® SA8775P | 5.867 ms | 2 - 187 MB | NPU | decoder | QNN_DLC | float | Qualcomm® QCS9075 | 5.883 ms | 4 - 10 MB | NPU | decoder | QNN_DLC | float | Qualcomm® QCS8450 (Proxy) | 10.521 ms | 0 - 212 MB | NPU | decoder | QNN_DLC | float | Qualcomm® SA7255P | 11.694 ms | 1 - 184 MB | NPU | decoder | QNN_DLC | float | Qualcomm® SA8295P | 7.321 ms | 0 - 188 MB | NPU | decoder | QNN_DLC | float | Snapdragon® 8 Elite For Galaxy Mobile | 2.58 ms | 0 - 183 MB | NPU | decoder | TFLITE | float | Snapdragon® 8 Elite Gen 5 Mobile | 2.608 ms | 0 - 190 MB | NPU | decoder | TFLITE | float | Snapdragon® 8 Gen 3 Mobile | 3.757 ms | 0 - 240 MB | NPU | decoder | TFLITE | float | Qualcomm® QCS8275 (Proxy) | 12.867 ms | 0 - 215 MB | NPU | decoder | TFLITE | float | Qualcomm® QCS8550 (Proxy) | 5.613 ms | 0 - 8 MB | NPU | decoder | TFLITE | float | Qualcomm® SA8775P | 6.617 ms | 0 - 215 MB | NPU | decoder | TFLITE | float | Qualcomm® QCS9075 | 6.868 ms | 0 - 19 MB | NPU | decoder | TFLITE | float | Qualcomm® QCS8450 (Proxy) | 9.292 ms | 0 - 217 MB | NPU | decoder | TFLITE | float | Qualcomm® SA7255P | 12.867 ms | 0 - 215 MB | NPU | decoder | TFLITE | float | Qualcomm® SA8295P | 8.817 ms | 0 - 190 MB | NPU | decoder | TFLITE | float | Snapdragon® 8 Elite For Galaxy Mobile | 2.992 ms | 0 - 186 MB | NPU | encoder | ONNX | float | Snapdragon® 8 Elite Gen 5 Mobile | 87.98 ms | 20 - 1523 MB | NPU | encoder | ONNX | float | Snapdragon® X2 Elite | 93.865 ms | 14 - 14 MB | NPU | encoder | ONNX | float | Snapdragon® X Elite | 173.026 ms | 12 - 12 MB | NPU | encoder | ONNX | float | Snapdragon® 8 Gen 3 Mobile | 125.003 ms | 20 - 3038 MB | NPU | encoder | ONNX | float | Qualcomm® QCS8550 (Proxy) | 179.446 ms | 12 - 38 MB | NPU | encoder | ONNX | float | Qualcomm® QCS9075 | 201.765 ms | 12 - 15 MB | NPU | encoder | ONNX | float | Snapdragon® 8 Elite For Galaxy Mobile | 101.134 ms | 9 - 1395 MB | NPU | encoder | QNN_DLC | float | Snapdragon® 8 Elite Gen 5 Mobile | 45.191 ms | 10 - 1310 MB | NPU | encoder | QNN_DLC | float | Snapdragon® X2 Elite | 48.308 ms | 12 - 12 MB | NPU | encoder | QNN_DLC | float | Snapdragon® X Elite | 98.3 ms | 12 - 12 MB | NPU | encoder | QNN_DLC | float | Snapdragon® 8 Gen 3 Mobile | 66.639 ms | 11 - 1557 MB | NPU | encoder | QNN_DLC | float | Qualcomm® QCS8275 (Proxy) | 209.871 ms | 1 - 1193 MB | NPU | encoder | QNN_DLC | float | Qualcomm® QCS8550 (Proxy) | 95.037 ms | 5 - 8 MB | NPU | encoder | QNN_DLC | float | Qualcomm® SA8775P | 101.107 ms | 0 - 1601 MB | NPU | encoder | QNN_DLC | float | Qualcomm® QCS9075 | 121.551 ms | 12 - 30 MB | NPU | encoder | QNN_DLC | float | Qualcomm® QCS8450 (Proxy) | 316.36 ms | 12 - 1581 MB | NPU | encoder | QNN_DLC | float | Qualcomm® SA7255P | 209.871 ms | 1 - 1193 MB | NPU | encoder | QNN_DLC | float | Qualcomm® SA8295P | 261.882 ms | 0 - 1211 MB | NPU | encoder | QNN_DLC | float | Snapdragon® 8 Elite For Galaxy Mobile | 49.263 ms | 12 - 1211 MB | NPU | encoder | TFLITE | float | Snapdragon® 8 Elite Gen 5 Mobile | 106.887 ms | 32 - 1084 MB | NPU | encoder | TFLITE | float | Snapdragon® 8 Gen 3 Mobile | 170.886 ms | 33 - 2317 MB | NPU | encoder | TFLITE | float | Qualcomm® QCS8275 (Proxy) | 363.051 ms | 33 - 1119 MB | NPU | encoder | TFLITE | float | Qualcomm® QCS8550 (Proxy) | 222.429 ms | 33 - 37 MB | NPU | encoder | TFLITE | float | Qualcomm® SA8775P | 243.033 ms | 33 - 1114 MB | NPU | encoder | TFLITE | float | Qualcomm® QCS9075 | 313.198 ms | 32 - 109 MB | NPU | encoder | TFLITE | float | Qualcomm® QCS8450 (Proxy) | 536.317 ms | 0 - 1932 MB | NPU | encoder | TFLITE | float | Qualcomm® SA7255P | 363.051 ms | 33 - 1119 MB | NPU | encoder | TFLITE | float | Qualcomm® SA8295P | 373.763 ms | 19 - 1147 MB | NPU | encoder | TFLITE | float | Snapdragon® 8 Elite For Galaxy Mobile | 129.761 ms | 0 - 1074 MB | NPU ## License * The license for the original implementation of MobileSam can be found [here](https://github.com/facebookresearch/segment-anything/blob/main/LICENSE). ## References * [Segment Anything](https://arxiv.org/abs/2306.14289) * [Source Model Implementation](https://github.com/facebookresearch/segment-anything) ## 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).