废话不多说 直接开始
先打开anaconda prompt
1.创建一个新环境
conda create -n FastSAM python=3.9
conda activate FastSAM
2.下载软件包
git clone https://github.com/CASIA-IVA-Lab/FastSAM.git
3.然后跳转到这个包的文件夹下并安装(安装在哪里就跳到哪里,比如说我的就是cd D:\FastSAM,下载很慢,可以去找清华镜像,此处省略)
cd FastSAM
pip install -r requirements.txt
4.安装CLIP
pip install git+https://github.com/openai/CLIP.git
5.在FastSAM下建立一个新文件夹weights
6.下载权重文件到这个新文件夹下
7.使用
python Inference.py --model_path ./weights/FastSAM-x.pt --img_path ./images/dogs.jpg
python Inference.py --model_path ./weights/FastSAM-x.pt --img_path ./images/dogs.jpg --text_prompt "the yellow dog"
python Inference.py --model_path ./weights/FastSAM-x.pt --img_path ./images/dogs.jpg --box_prompt "[570,200,230,400]"
python Inference.py --model_path ./weights/FastSAM-x.pt --img_path ./images/dogs.jpg --point_prompt "[[520,360],[620,300]]" --point_label "[1,0]"
要想运行自己的数据,只需要把自己的图像复制到FastSAM文件下的images文件夹下,将代码中的dog.jpg改为自己的图像名称就行了