SqueezeSAM: User friendly mobile interactive segmentation

Balakrishnan Varadarajan, Bilge Soran, Forrest N. Iandola, Xiaoyu Xiang, Yunyang Xiong, Lemeng Wu, Chenchen Zhu, Raghuraman Krishnamoorthi, Vikas ChandraarXiv 2023 · OpenReview

Abstract

The Segment Anything Model (SAM) has revolutionized interactive segmentation but remains computationally prohibitive for mobile devices due to its 600-million-parameter ViT-H architecture. We present SqueezeSAM, a fully convolutional model that is 62.5x faster and 31.6x smaller than the original SAM. By employing a hybrid UNet architecture and a novel data augmentation scheme for "whole-object" segmentation, SqueezeSAM achieves performance within 1% mIOU of the ViT-H version while enabling real-time use on mobile hardware.

Introduction

Interactive segmentation is a core component of modern mobile photography workflows, used for background removal, object stylization, and creative editing. While Meta’s Segment Anything Model (SAM) set a new standard for universal segmentation, its reliance on heavy Vision Transformers (ViT) makes it unsuitable for on-device execution. On an iPhone CPU, the original SAM can take over 10 seconds per image, a latency that disrupts the user experience. SqueezeSAM addresses this by redesigning the architecture for mobile efficiency without sacrificing the "segment anything" capability.

SqueezeSAM provides a 50x speedup compared to the original SAM, making it viable for interactive mobile applications.

Architecture and Methodology

SqueezeSAM departs from the ViT-heavy design of SAM in favor of a fully convolutional UNet-based architecture. To maintain global context while ensuring speed, the model uses a hybrid encoder-decoder structure. High-resolution features are processed via "DoubleConv" blocks, while Transformer layers are restricted to the 1x1 bottleneck of the UNet.

A key innovation is the use of "Early Fusion." Unlike SAM, which processes image and prompt embeddings separately before merging them in a lightweight decoder, SqueezeSAM feeds user clicks as additional input channels directly into the encoder. This allows the model to prioritize the region of interest from the earliest layers. Furthermore, the use of BatchNorm instead of LayerNorm allows for "operator folding" during inference, significantly reducing the computational footprint on mobile CPUs and GPUs.

Bridging the User Intent Gap

Standard SAM often produces part-based segmentations (e.g., selecting only a shirt when a user clicks a person). Mobile users typically expect "whole-object" selection. To align with this intent, SqueezeSAM utilizes a mask-merging data augmentation strategy during training on the SA-1B dataset. By suppressing smaller, nested masks in favor of larger parent masks, the model learns to segment entire entities. Additionally, the integration of Salient Object Detection (SOD) allows for "zero-click" segmentation, where the model predicts the most likely object of interest to provide an immediate starting point for the user.

Performance and Results

SqueezeSAM achieves an inference latency of just 8ms on an NVIDIA A100 and approximately 300ms on an iPhone CPU. Despite its compact size (19 million parameters), it maintains high accuracy. On the COCO benchmark, SqueezeSAM reaches 77.9% mIOU, nearly matching the 78.4% of the original ViT-H SAM.

Throughput vs. Accuracy comparison. SqueezeSAM (highlighted) achieves superior throughput compared to MobileSAM and FastSAM while maintaining high AP.

As shown in the throughput analysis, SqueezeSAM occupies a unique position on the Pareto frontier, offering significantly higher frames-per-second than previous efficient variants like MobileSAM while delivering competitive segmentation quality.

Conclusion

SqueezeSAM demonstrates that the power of foundation models for segmentation can be distilled into a mobile-friendly format. By combining a convolutional UNet architecture with intent-aware training, it provides a snappy, intuitive experience for mobile users. Future work will focus on leveraging mobile NPUs to further reduce latency and enable real-time video segmentation.

Summary updated

BibTeX
@misc{varadarajan2023squeezesam,
  author = {Balakrishnan Varadarajan and Bilge Soran and Forrest N. Iandola and Xiaoyu Xiang and Yunyang Xiong and Lemeng Wu and Chenchen Zhu and Raghuraman Krishnamoorthi and Vikas Chandra},
  title = {{SqueezeSAM: User friendly mobile interactive segmentation}},
  year = {2023},
  eprint = {2312.06736},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2312.06736},
}
Figure