Prompt-driven segmentation
MobileSAM
Click a point, get a mask. Distilled SAM for live interactive use.
About this model
MobileSAM pairs a TinyViT encoder of about 5M parameters with the original SAM ViT-H prompt decoder. Around 28 MB for the encoder, 16 MB for the decoder. The family caches the image embedding across repeated prompts on the same image, so re-clicking is fast.
On M1 Max CPU, the first call takes 1.4 seconds; subsequent prompts on the same image take 83 ms. CoreML build fails on the encoder, so this runs on CPU.
What you can build
- Build a click-to-cut tool in a photo editor.
- Let a user mask a subject with one tap on mobile.
- Refine a coarse box from FastSAM into a clean mask.
- Segment objects interactively for dataset labeling.
Variants & downloads
Choose the build for your appModel files are being prepared.
Explore the model’s examples, source links, and integration notes while download variants are added.
Example inference
Performance
Results depend on the device, runtime, and test conditions. Each measurement keeps its own context.
M1 Max, macOS 15, ONNX Runtime 1.17
See original catalog hardware notes · CPU
83.2 ms
Warm inference
Reference result from the existing catalog; conversion variant and measurement date were not recorded.
RTX 2060, Ubuntu 24.04, ONNX Runtime 1.24.3
See original catalog hardware notes · CUDA
10.5 ms
Warm inference
Reference result from the existing catalog; conversion variant and measurement date were not recorded.
Integration examples
Vision SDK integration
cpp
#include "imaged/sdk.hpp"
#include "imaged/families/sam/sam_family.hpp"
imaged::SDK::AI ai;
auto& config = ai.getOptions();
config.set("sam.encoder.model", "weights/mobile_sam.encoder.onnx");
config.set("sam.decoder.model", "weights/sam_vit_h_4b8939.decoder.onnx");
imaged::SDK::SamFamily family;
family.load(config);
imaged::SDK::Image image;
image.load("scene.jpg");
imaged::SDK::PointPromptInput prompt;
prompt.image = ℑ
prompt.points.push_back({600.f, 350.f, 1}); // foreground click
auto result = std::get<imaged::SDK::DetectionResult>(family.run({prompt}));