FastSAM:50倍更快的Segment Anything模型

FastSAM:50倍更快的Segment Anything革命

闪电般的性能与SAM品质结果

FastSAM 来自CASIA-LMC-Lab,重新定义了图像分割。只用SA-1B数据集的2%训练,这个基于CNN的模型匹配Meta的Segment Anything (SAM)性能,同时运行速度快50倍

关键统计: - 6800万参数(对比SAM-H的6亿) - 无论提示数量多少,推理仅40ms - 2608MB GPU内存(对比SAM-H的7060MB)

🚀 4种强大的提示模式

# Everything模式 - 分割所有内容
python Inference.py --model_path ./weights/FastSAM.pt --img_path ./images/dogs.jpg

# 文本提示
python Inference.py --img_path ./images/dogs.jpg --text_prompt "the yellow dog"

# 框提示 [x,y,w,h]
python Inference.py --box_prompt "[[570,200,230,400]]"

# 点提示
python Inference.py --point_prompt "[[520,360],[620,300]]" --point_label "[1,0]"

🛠️ 快速开始(5分钟)

git clone https://github.com/CASIA-LMC-Lab/FastSAM.git
cd FastSAM
conda create -n FastSAM python=3.9
conda activate FastSAM
pip install -r requirements.txt
# 下载FastSAM.pt检查点
python Inference.py --model_path ./weights/FastSAM.pt --img_path ./images/dogs.jpg

🌐 实时演示可用

📊 基准测试结果

方法 参数量 1点 10点 100点 E(64x64)
SAM-H 0.6G 446 464 627 6972
SAM-B 136M 110 125 230 5417
FastSAM 68M 40 40 40 40

🔬 实际应用

  1. 边缘检测 - BSDS500: ODS 0.750(对比SAM 0.768)
  2. 对象提议 - COCO AR@1000: 63.7(对比SAM-H 67.7)
  3. 实例分割 - COCO AP: 0.379
  4. 下游任务:异常检测、显著对象检测、建筑物提取

🎯 为什么选择FastSAM?

生产就绪 - YOLOv8模型中心集成
开发者友好 - Python API + 网页演示 ✅ 硬件高效 - 在消费级GPU上运行 ✅ 可扩展 - 发布训练代码 ✅ 社区驱动 - 8.3k星标,26位贡献者

最近更新(2024年6月)

  • 边缘质量改进已合并到Ultralytics YOLOv8
  • HuggingFace演示已更新
  • TensorRT优化可用
  • Semantic FastSAM扩展

FastSAM证明,您无需庞大的ViT模型即可实现最先进的分割。完美适用于速度至关重要的实时应用。

GitHub仓库 | 立即试用演示 →

原始文章: 查看原文

分享这篇文章