龙空技术网

Windows 上安装 MobileSAM 笔记

木子光军 44

前言:

当前大家对“anaconda安装onnx”大致比较着重,同学们都想要知道一些“anaconda安装onnx”的相关资讯。那么小编也在网络上收集了一些对于“anaconda安装onnx””的相关知识,希望兄弟们能喜欢,小伙伴们一起来了解一下吧!

MobileSAM 是视觉大模型 SAM 的轻量版。普通电脑也可快速体验视觉大模型。

本文假设您已安装 CUDA v12.1 、Anaconda、Git。

依次执行以下命令进行安装。

1、创建环境

conda create --name sam python=3.9

2、激活环境

conda activate sam 

3、安装pytorch

pip3 install torch torchvision torchaudio --index-url 

4、安装MobileSAM依赖包

pip install onnxruntime==1.17.1pip install opencv-python pycocotools matplotlib onnxpip install torchpack onnxsimpip install ruff==0.2.2pip install gradio==4.19.2pip install  timm

5、下载MobileSAM源码

git clone 

6、源码安装MobileSAM

cd MobileSAMpip install -e . 

7、体验 MobileSAM v1 版

cd MobileSAM/apppython app.py

8、体验 MobileSAM v2 版

需先下载模型权值文件 解压到 MobileSAM\MobileSAMv2\weight 目录中。

cd MobileSAM/MobileSAMv2python Inference.py --img_path ./test_images/ --output_dir ./test_outputs/  --encoder_type efficientvit_l2

如果分割结果太细碎,可调整参数conf。如:

python Inference.py --img_path ./test_images/ --output_dir ./test_outputs/  --encoder_type sam_vit_h --conf 0.9

标签: #anaconda安装onnx