--- 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/sam2/web-assets/model_demo.png) # Segment-Anything-Model-2: Optimized for Qualcomm Devices SAM 2, the successor to Meta's Segment Anything Model (SAM), is a cutting-edge tool designed for comprehensive object segmentation in both images and videos. It excels in handling complex visual data through a unified, promptable model architecture that supports real-time processing and zero-shot generalization. This is based on the implementation of Segment-Anything-Model-2 found [here](https://github.com/facebookresearch/sam2). 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/sam2) 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 | |---|---|---|---|---| | QNN_DLC | float | Universal | QAIRT 2.42 | [Download](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/sam2/releases/v0.46.0/sam2-qnn_dlc-float.zip) | QNN_DLC | w8a8 | Universal | QAIRT 2.42 | [Download](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/sam2/releases/v0.46.0/sam2-qnn_dlc-w8a8.zip) | TFLITE | w8a8 | Universal | QAIRT 2.42, TFLite 2.17.0 | [Download](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/sam2/releases/v0.46.0/sam2-tflite-w8a8.zip) For more device-specific assets and performance metrics, visit **[Segment-Anything-Model-2 on Qualcomm® AI Hub](https://aihub.qualcomm.com/models/sam2)**. ### Option 2: Export with Custom Configurations Use the [Qualcomm® AI Hub Models](https://github.com/quic/ai-hub-models/blob/main/qai_hub_models/models/sam2) 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 [Segment-Anything-Model-2 on GitHub](https://github.com/quic/ai-hub-models/blob/main/qai_hub_models/models/sam2) for usage instructions. ## Model Details **Model Type:** Model_use_case.semantic_segmentation **Model Stats:** - Model checkpoint: sam2.1_hiera_t - Input resolution: 720p (720x1280) - Number of parameters (SAM2Encoder): 33.5M - Model size (SAM2Encoder) (float): 128 MB - Number of parameters (SAM2Decoder): 6.22M - Model size (SAM2Decoder) (float): 23.7 MB ## Performance Summary | Model | Runtime | Precision | Chipset | Inference Time (ms) | Peak Memory Range (MB) | Primary Compute Unit |---|---|---|---|---|---|--- | SAM2Decoder | QNN_DLC | float | Qualcomm® QCS8550 (Proxy) | 5.3 ms | 16 - 18 MB | NPU | SAM2Decoder | QNN_DLC | float | Qualcomm® QCS8450 (Proxy) | 8.834 ms | 4 - 223 MB | NPU | SAM2Decoder | QNN_DLC | float | Snapdragon® 8 Elite For Galaxy Mobile | 2.891 ms | 4 - 292 MB | NPU | SAM2Decoder | QNN_DLC | float | Snapdragon® 8 Elite Gen 5 Mobile | 2.585 ms | 4 - 201 MB | NPU | SAM2Decoder | QNN_DLC | w8a8 | Snapdragon® X Elite | 2.181 ms | 4 - 4 MB | NPU | SAM2Decoder | QNN_DLC | w8a8 | Snapdragon® 8 Gen 3 Mobile | 1.251 ms | 0 - 103 MB | NPU | SAM2Decoder | QNN_DLC | w8a8 | Qualcomm® QCS8275 (Proxy) | 3.819 ms | 4 - 82 MB | NPU | SAM2Decoder | QNN_DLC | w8a8 | Qualcomm® QCS8550 (Proxy) | 1.883 ms | 4 - 6 MB | NPU | SAM2Decoder | QNN_DLC | w8a8 | Qualcomm® SA8775P | 2.504 ms | 4 - 84 MB | NPU | SAM2Decoder | QNN_DLC | w8a8 | Qualcomm® QCM6690 | 10.032 ms | 4 - 272 MB | NPU | SAM2Decoder | QNN_DLC | w8a8 | Qualcomm® QCS8450 (Proxy) | 2.66 ms | 0 - 102 MB | NPU | SAM2Decoder | QNN_DLC | w8a8 | Qualcomm® SA7255P | 3.819 ms | 4 - 82 MB | NPU | SAM2Decoder | QNN_DLC | w8a8 | Snapdragon® 8 Elite For Galaxy Mobile | 1.025 ms | 1 - 83 MB | NPU | SAM2Decoder | QNN_DLC | w8a8 | Snapdragon® 7 Gen 4 Mobile | 2.567 ms | 4 - 209 MB | NPU | SAM2Decoder | QNN_DLC | w8a8 | Snapdragon® 8 Elite Gen 5 Mobile | 0.885 ms | 1 - 105 MB | NPU | SAM2Decoder | TFLITE | w8a8 | Snapdragon® 8 Gen 3 Mobile | 9.179 ms | 0 - 258 MB | NPU | SAM2Decoder | TFLITE | w8a8 | Qualcomm® QCS8275 (Proxy) | 20.261 ms | 0 - 234 MB | NPU | SAM2Decoder | TFLITE | w8a8 | Qualcomm® QCS8550 (Proxy) | 12.297 ms | 0 - 55 MB | NPU | SAM2Decoder | TFLITE | w8a8 | Qualcomm® SA8775P | 13.798 ms | 0 - 230 MB | NPU | SAM2Decoder | TFLITE | w8a8 | Qualcomm® QCM6690 | 51.734 ms | 13 - 204 MB | NPU | SAM2Decoder | TFLITE | w8a8 | Qualcomm® QCS8450 (Proxy) | 15.596 ms | 0 - 240 MB | NPU | SAM2Decoder | TFLITE | w8a8 | Qualcomm® SA7255P | 20.261 ms | 0 - 234 MB | NPU | SAM2Decoder | TFLITE | w8a8 | Qualcomm® SA8295P | 14.151 ms | 0 - 238 MB | NPU | SAM2Decoder | TFLITE | w8a8 | Snapdragon® 8 Elite For Galaxy Mobile | 6.822 ms | 0 - 238 MB | NPU | SAM2Decoder | TFLITE | w8a8 | Snapdragon® 7 Gen 4 Mobile | 16.179 ms | 14 - 211 MB | NPU | SAM2Decoder | TFLITE | w8a8 | Snapdragon® 8 Elite Gen 5 Mobile | 5.439 ms | 0 - 238 MB | NPU | SAM2Encoder | QNN_DLC | float | Qualcomm® QCS8550 (Proxy) | 203.499 ms | 12 - 16 MB | NPU | SAM2Encoder | QNN_DLC | float | Qualcomm® QCS8450 (Proxy) | 397.994 ms | 13 - 1948 MB | NPU | SAM2Encoder | QNN_DLC | float | Snapdragon® 8 Elite For Galaxy Mobile | 111.323 ms | 12 - 1672 MB | NPU | SAM2Encoder | QNN_DLC | float | Snapdragon® 8 Elite Gen 5 Mobile | 94.806 ms | 12 - 1651 MB | NPU | SAM2Encoder | QNN_DLC | w8a8 | Snapdragon® X Elite | 83.626 ms | 3 - 3 MB | NPU | SAM2Encoder | QNN_DLC | w8a8 | Snapdragon® 8 Gen 3 Mobile | 55.731 ms | 3 - 2048 MB | NPU | SAM2Encoder | QNN_DLC | w8a8 | Qualcomm® QCS8275 (Proxy) | 142.746 ms | 3 - 1666 MB | NPU | SAM2Encoder | QNN_DLC | w8a8 | Qualcomm® QCS8550 (Proxy) | 80.919 ms | 3 - 6 MB | NPU | SAM2Encoder | QNN_DLC | w8a8 | Qualcomm® SA8775P | 84.664 ms | 3 - 1667 MB | NPU | SAM2Encoder | QNN_DLC | w8a8 | Qualcomm® QCM6690 | 1619.399 ms | 3 - 1890 MB | NPU | SAM2Encoder | QNN_DLC | w8a8 | Qualcomm® QCS8450 (Proxy) | 143.099 ms | 3 - 2019 MB | NPU | SAM2Encoder | QNN_DLC | w8a8 | Qualcomm® SA7255P | 142.746 ms | 3 - 1666 MB | NPU | SAM2Encoder | QNN_DLC | w8a8 | Snapdragon® 8 Elite For Galaxy Mobile | 42.346 ms | 3 - 1588 MB | NPU | SAM2Encoder | QNN_DLC | w8a8 | Snapdragon® 7 Gen 4 Mobile | 112.547 ms | 3 - 1796 MB | NPU | SAM2Encoder | QNN_DLC | w8a8 | Snapdragon® 8 Elite Gen 5 Mobile | 83.05 ms | 3 - 1688 MB | NPU | SAM2Encoder | TFLITE | w8a8 | Snapdragon® 8 Gen 3 Mobile | 60.18 ms | 4 - 1985 MB | NPU | SAM2Encoder | TFLITE | w8a8 | Qualcomm® QCS8275 (Proxy) | 1794.231 ms | 90 - 115 MB | CPU | SAM2Encoder | TFLITE | w8a8 | Qualcomm® QCS8550 (Proxy) | 88.84 ms | 4 - 8 MB | NPU | SAM2Encoder | TFLITE | w8a8 | Qualcomm® SA8775P | 87.736 ms | 4 - 1746 MB | NPU | SAM2Encoder | TFLITE | w8a8 | Qualcomm® QCM6690 | 2482.98 ms | 19 - 276 MB | CPU | SAM2Encoder | TFLITE | w8a8 | Qualcomm® QCS8450 (Proxy) | 150.24 ms | 4 - 2053 MB | NPU | SAM2Encoder | TFLITE | w8a8 | Qualcomm® SA7255P | 1794.231 ms | 90 - 115 MB | CPU | SAM2Encoder | TFLITE | w8a8 | Qualcomm® SA8295P | 99.931 ms | 0 - 1760 MB | NPU | SAM2Encoder | TFLITE | w8a8 | Snapdragon® 8 Elite For Galaxy Mobile | 59.393 ms | 3 - 1791 MB | NPU | SAM2Encoder | TFLITE | w8a8 | Snapdragon® 7 Gen 4 Mobile | 1266.454 ms | 113 - 403 MB | CPU | SAM2Encoder | TFLITE | w8a8 | Snapdragon® 8 Elite Gen 5 Mobile | 39.88 ms | 4 - 1866 MB | NPU ## License * The license for the original implementation of Segment-Anything-Model-2 can be found [here](https://github.com/facebookresearch/sam2/blob/main/LICENSE). ## References * [SAM 2 Segment Anything in Images and Videos](https://arxiv.org/abs/2408.00714) * [Source Model Implementation](https://github.com/facebookresearch/sam2) ## 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).