Hysen Labs
Model or dataset
OroChippw/SegmentAnything-OnnxRunner avatar
OroChippw

SegmentAnything-OnnxRunner

SegmentAnything-OnnxRunner is an example using Meta AI Research's SAM onnx model in C++.The encoder and decoder of SAM are decoupled in this repository.

100 stars17 forksC++MIT
01
DEEP OPEN-SOURCE ANALYSIS

SegmentAnything OnnxRunner: SAM in C++ on the CPU

A C++ example that runs Meta's Segment Anything Model from onnx files with the encoder and decoder kept separate, recorded running on CPU under Windows.

02
DEEP OPEN-SOURCE ANALYSIS

What the runner does

This repository is an example of using Meta AI Research's SAM onnx model in C++. The Segment Anything Model produces object masks from prompts such as points or boxes, and here the encoder and decoder are decoupled. The README exists partly to record the experiment data of running the SAM onnx model on CPU. The header even shows a sample image with the click and box information used.

03
DEEP OPEN-SOURCE ANALYSIS

CPU only, Windows only

Two scoping notes are up front. The interface currently supports CPU execution only, and the code is only supported on Windows, with the README warning it may hit issues on Linux. The listed development environments are both Windows machines, one running Windows 10 Pro with an i5 13600KF and CUDA 11.3, the other Windows 11 Home with an i5 13500H and CUDA 11.7.

04
DEEP OPEN-SOURCE ANALYSIS

The startup parameters

All models are available through a Baidu Pan link, with the encoder and decoder both decoupled and quantized. Once decoupled, repeated interactive clicks on an image do not require re encoding. The startup parameters include required paths for the encoder model, the decoder model, and the image, plus optional flags for the output directory, a demo mode, box information, single mask mode, and an IOU threshold that defaults to 0.9.

05
DEEP OPEN-SOURCE ANALYSIS

The recorded experiment

An experiment record logs results on one device with an i5 13600KF and an RTX 3060, using an input image at 1920 by 1080. Encoder timings on CPU range from about 2.5 seconds for the smaller vit b encoder to about 6 seconds for the larger vit l one, with the quantized versions roughly a third of the size. Decoder runs land around a tenth of a second, which is where the decoupling pays off.

06
DEEP OPEN-SOURCE ANALYSIS

Editorial conclusion

The honest part is the scoping. The README says plainly this is CPU only and Windows only, and then backs that up with measured timings. For anyone who wants SAM in C++ without a GPU, the experiment record is the most useful part.

07
DEEP OPEN-SOURCE ANALYSIS

Official sources

08
Community notes

Community notes