--- 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/v0.59.0/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.45, ONNX Runtime 1.27.1 | [Download](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/mobilesam/releases/v0.59.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.59.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.59.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/v0.59.0/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/v0.59.0/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® X2 Elite | 2.636 ms | 4 - 4 MB | NPU | decoder | ONNX | float | Snapdragon® X Elite | 6.113 ms | 11 - 11 MB | NPU | decoder | ONNX | float | Snapdragon® 8 Gen 3 Mobile | 4.15 ms | 0 - 241 MB | NPU | decoder | ONNX | float | Snapdragon® 8 Gen 1 Mobile | 14.315 ms | 5 - 233 MB | NPU | decoder | ONNX | float | Qualcomm® Dragonwing™ QCS8550 (Proxy) | 5.91 ms | 4 - 6 MB | NPU | decoder | ONNX | float | Qualcomm® QCS8450 | 14.315 ms | 5 - 233 MB | NPU | decoder | ONNX | float | Qualcomm® Dragonwing™ IQ-9075 | 6.816 ms | 4 - 7 MB | NPU | decoder | ONNX | float | Qualcomm® Dragonwing™ IQ-X7181 | 6.113 ms | 11 - 11 MB | NPU | decoder | ONNX | float | Qualcomm® Dragonwing™ Q-8750 | 3.184 ms | 0 - 237 MB | NPU | decoder | ONNX | float | Snapdragon® 8 Elite Mobile | 3.184 ms | 0 - 237 MB | NPU | decoder | ONNX | float | Snapdragon® 8 Elite Gen 5 Mobile | 2.544 ms | 1 - 215 MB | NPU | decoder | QNN_DLC | float | Snapdragon® X2 Elite | 3.005 ms | 4 - 4 MB | NPU | decoder | QNN_DLC | float | Snapdragon® X Elite | 5.711 ms | 4 - 4 MB | NPU | decoder | QNN_DLC | float | Snapdragon® 8 Gen 3 Mobile | 3.735 ms | 4 - 223 MB | NPU | decoder | QNN_DLC | float | Snapdragon® 8 Gen 1 Mobile | 11.599 ms | 0 - 252 MB | NPU | decoder | QNN_DLC | float | Qualcomm® Dragonwing™ QCS8275 | 12.588 ms | 0 - 193 MB | NPU | decoder | QNN_DLC | float | Qualcomm® Dragonwing™ QCS8550 (Proxy) | 5.279 ms | 4 - 33 MB | NPU | decoder | QNN_DLC | float | Qualcomm® SA8775P | 6.269 ms | 0 - 194 MB | NPU | decoder | QNN_DLC | float | Qualcomm® SA8650P | 6.269 ms | 0 - 194 MB | NPU | decoder | QNN_DLC | float | Qualcomm® SA8255P | 6.269 ms | 0 - 194 MB | NPU | decoder | QNN_DLC | float | Qualcomm® QCS8450 | 11.599 ms | 0 - 252 MB | NPU | decoder | QNN_DLC | float | Qualcomm® Dragonwing™ IQ-9075 | 6.05 ms | 4 - 10 MB | NPU | decoder | QNN_DLC | float | Qualcomm® Dragonwing™ IQ-X7181 | 5.711 ms | 4 - 4 MB | NPU | decoder | QNN_DLC | float | Qualcomm® Dragonwing™ Q-8750 | 2.835 ms | 0 - 223 MB | NPU | decoder | QNN_DLC | float | Qualcomm® SA7255P | 12.588 ms | 0 - 193 MB | NPU | decoder | QNN_DLC | float | Qualcomm® SA8295P | 7.729 ms | 0 - 191 MB | NPU | decoder | QNN_DLC | float | Snapdragon® 8 Elite Mobile | 2.835 ms | 0 - 223 MB | NPU | decoder | QNN_DLC | float | Snapdragon® 8 Elite Gen 5 Mobile | 2.537 ms | 4 - 196 MB | NPU | decoder | TFLITE | float | Snapdragon® 8 Gen 3 Mobile | 3.413 ms | 0 - 211 MB | NPU | decoder | TFLITE | float | Snapdragon® 8 Gen 1 Mobile | 8.008 ms | 0 - 215 MB | NPU | decoder | TFLITE | float | Qualcomm® Dragonwing™ QCS8275 | 11.845 ms | 0 - 185 MB | NPU | decoder | TFLITE | float | Qualcomm® Dragonwing™ QCS8550 (Proxy) | 4.941 ms | 0 - 17 MB | NPU | decoder | TFLITE | float | Qualcomm® SA8775P | 5.934 ms | 0 - 189 MB | NPU | decoder | TFLITE | float | Qualcomm® SA8650P | 5.934 ms | 0 - 189 MB | NPU | decoder | TFLITE | float | Qualcomm® SA8255P | 5.934 ms | 0 - 189 MB | NPU | decoder | TFLITE | float | Qualcomm® QCS8450 | 8.008 ms | 0 - 215 MB | NPU | decoder | TFLITE | float | Qualcomm® Dragonwing™ IQ-9075 | 5.704 ms | 0 - 19 MB | NPU | decoder | TFLITE | float | Qualcomm® Dragonwing™ Q-8750 | 2.596 ms | 0 - 184 MB | NPU | decoder | TFLITE | float | Qualcomm® SA7255P | 11.845 ms | 0 - 185 MB | NPU | decoder | TFLITE | float | Qualcomm® SA8295P | 7.282 ms | 0 - 183 MB | NPU | decoder | TFLITE | float | Snapdragon® 8 Elite Mobile | 2.596 ms | 0 - 184 MB | NPU | decoder | TFLITE | float | Snapdragon® 8 Elite Gen 5 Mobile | 2.165 ms | 0 - 187 MB | NPU | encoder | ONNX | float | Snapdragon® X2 Elite | 100.973 ms | 12 - 12 MB | NPU | encoder | ONNX | float | Snapdragon® X Elite | 168.548 ms | 14 - 14 MB | NPU | encoder | ONNX | float | Snapdragon® 8 Gen 3 Mobile | 125.733 ms | 12 - 1103 MB | NPU | encoder | ONNX | float | Snapdragon® 8 Gen 1 Mobile | 407.934 ms | 22 - 1128 MB | NPU | encoder | ONNX | float | Qualcomm® Dragonwing™ QCS8550 (Proxy) | 173.455 ms | 12 - 30 MB | NPU | encoder | ONNX | float | Qualcomm® QCS8450 | 407.934 ms | 22 - 1128 MB | NPU | encoder | ONNX | float | Qualcomm® Dragonwing™ IQ-9075 | 178.544 ms | 12 - 15 MB | NPU | encoder | ONNX | float | Qualcomm® Dragonwing™ IQ-X7181 | 168.548 ms | 14 - 14 MB | NPU | encoder | ONNX | float | Qualcomm® Dragonwing™ Q-8750 | 100.448 ms | 8 - 919 MB | NPU | encoder | ONNX | float | Snapdragon® 8 Elite Mobile | 100.448 ms | 8 - 919 MB | NPU | encoder | ONNX | float | Snapdragon® 8 Elite Gen 5 Mobile | 82.268 ms | 9 - 1036 MB | NPU | encoder | QNN_DLC | float | Snapdragon® X2 Elite | 46.051 ms | 12 - 12 MB | NPU | encoder | QNN_DLC | float | Snapdragon® X Elite | 103.021 ms | 12 - 12 MB | NPU | encoder | QNN_DLC | float | Snapdragon® 8 Gen 3 Mobile | 65.626 ms | 12 - 1328 MB | NPU | encoder | QNN_DLC | float | Snapdragon® 8 Gen 1 Mobile | 326.924 ms | 11 - 1341 MB | NPU | encoder | QNN_DLC | float | Qualcomm® Dragonwing™ QCS8275 | 207.442 ms | 1 - 1126 MB | NPU | encoder | QNN_DLC | float | Qualcomm® Dragonwing™ QCS8550 (Proxy) | 99.736 ms | 12 - 15 MB | NPU | encoder | QNN_DLC | float | Qualcomm® SA8775P | 100.378 ms | 1 - 1550 MB | NPU | encoder | QNN_DLC | float | Qualcomm® SA8650P | 100.378 ms | 1 - 1550 MB | NPU | encoder | QNN_DLC | float | Qualcomm® SA8255P | 100.378 ms | 1 - 1550 MB | NPU | encoder | QNN_DLC | float | Qualcomm® QCS8450 | 326.924 ms | 11 - 1341 MB | NPU | encoder | QNN_DLC | float | Qualcomm® Dragonwing™ IQ-9075 | 124.552 ms | 14 - 32 MB | NPU | encoder | QNN_DLC | float | Qualcomm® Dragonwing™ IQ-X7181 | 103.021 ms | 12 - 12 MB | NPU | encoder | QNN_DLC | float | Qualcomm® Dragonwing™ Q-8750 | 48.995 ms | 6 - 1122 MB | NPU | encoder | QNN_DLC | float | Qualcomm® SA7255P | 207.442 ms | 1 - 1126 MB | NPU | encoder | QNN_DLC | float | Qualcomm® SA8295P | 324.927 ms | 0 - 1557 MB | NPU | encoder | QNN_DLC | float | Snapdragon® 8 Elite Mobile | 48.995 ms | 6 - 1122 MB | NPU | encoder | QNN_DLC | float | Snapdragon® 8 Elite Gen 5 Mobile | 40.341 ms | 12 - 1258 MB | NPU | encoder | TFLITE | float | Snapdragon® 8 Gen 3 Mobile | 66.798 ms | 0 - 3190 MB | NPU | encoder | TFLITE | float | Snapdragon® 8 Gen 1 Mobile | 311.267 ms | 4 - 1362 MB | NPU | encoder | TFLITE | float | Qualcomm® Dragonwing™ QCS8275 | 196.878 ms | 4 - 1634 MB | NPU | encoder | TFLITE | float | Qualcomm® Dragonwing™ QCS8550 (Proxy) | 90.526 ms | 4 - 8 MB | NPU | encoder | TFLITE | float | Qualcomm® SA8775P | 100.683 ms | 4 - 1670 MB | NPU | encoder | TFLITE | float | Qualcomm® SA8650P | 100.683 ms | 4 - 1670 MB | NPU | encoder | TFLITE | float | Qualcomm® SA8255P | 100.683 ms | 4 - 1670 MB | NPU | encoder | TFLITE | float | Qualcomm® QCS8450 | 311.267 ms | 4 - 1362 MB | NPU | encoder | TFLITE | float | Qualcomm® Dragonwing™ IQ-9075 | 101.504 ms | 0 - 45 MB | NPU | encoder | TFLITE | float | Qualcomm® Dragonwing™ Q-8750 | 48.492 ms | 2 - 1629 MB | NPU | encoder | TFLITE | float | Qualcomm® SA7255P | 196.878 ms | 4 - 1634 MB | NPU | encoder | TFLITE | float | Qualcomm® SA8295P | 258.167 ms | 4 - 1714 MB | NPU | encoder | TFLITE | float | Snapdragon® 8 Elite Mobile | 48.492 ms | 2 - 1629 MB | NPU | encoder | TFLITE | float | Snapdragon® 8 Elite Gen 5 Mobile | 40.214 ms | 4 - 1796 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).