✔️

SAM系のCPU速度の比較

に公開

初めに

CPUでも動きそうなSAM系がいくつかでているので試してみます。
比較するのは以下
https://github.com/facebookresearch/sam2
https://github.com/NVIDIA-AI-IOT/nanosam
https://github.com/xinghaochen/TinySAM
https://github.com/ChaoningZhang/MobileSAM

サンプル画像

https://www.pakutaso.com/20240715194post-51253.html
https://www.pakutaso.com/20250657163post-54639.html
https://www.pakutaso.com/20250435093post-54118.html

結果

すべてGoogleColabのCPUでの結果です。
試した範囲では、精度では、sam2.1 largeがベストですが、NanoSAMが20倍速くてほぼ同等で優秀でした。

Implementation model Time(s) 精度(主観)
sam2 sam2.1_hiera_tiny image1 7.24
image2 7.7
image3 11.7
image1 〇
image2 △
image3 ×
sam2 sam2.1_hiera_small image1 9.46
image2 9.13
image3 11.4
image1 〇
image2 ×
image3 〇
sam2 sam2.1_hiera_base_plus image1 15.5
image2 15
image3 17.7
image1 〇
image2 △
image3 ×
sam2 sam2.1_hiera_large image1 39.2
image2 37.7
image3 47.2
image1 〇
image2 〇
image3 〇
nanosam resnet18_image_encoder.onnx
mobile_sam_mask_decoder.onnx
image1 1.56
image2 1.65
image3 2.91
image1 〇
image2 △
image3 〇
TinySAM tinysam_42.3.pth image1 4.76
image2 4.63
image3 5.29
image1 ×
image2 ×
image3 ×
MobileSAM mobile_sam image1 4.39
image2 4.99
image3 6.55
image1 〇
image2 △
image3 〇

マスク画像結果

sam2(sam2.1_hiera_tiny)

sam2(sam2.1_hiera_small)

sam2(sam2.1_hiera_base_plus)

sam2(sam2.1_hiera_large)

nanosam(resnet18_image_encoder.onnx)

TinySAM(tinysam_42.3.pth)

MobileSAM(mobile_sam)

Discussion