Semantic-SAM安装及填坑教程

Semantic-SAM安装教程

安装简介

1 进入终端后,先安装github给的配置命令原封不动的进行下载配置
2 测试完成后,根据问题进行修改

1 下载安装

# 进入Semantic-SAM 的github地址
https://github.com/UX-Decoder/Semantic-SAM
# 根据给定安装步骤,依次安装
pip3 install torch==1.13.1 torchvision==0.14.1 --extra-index-url https://download.pytorch.org/whl/cu113
python -m pip install 'git+https://github.com/MaureenZOU/detectron2-xyz.git'
pip install git+https://github.com/cocodataset/panopticapi.git
git clone https://github.com/UX-Decoder/Semantic-SAM
cd Semantic-SAM
python -m pip install -r requirements.txt

export DATASET=/pth/to/dataset  # path to your coco data

在这里插入图片描述

2 安装测试

使用下述代码对安装的模型进行测试,其中的ckpt,model_type,point位置都需要自己修改

from semantic_sam import prepare_image, plot_multi_results, build_semantic_sam, SemanticSAMPredictor
original_image, input_image = prepare_image(image_pth='examples/dog.jpg')  # change the image path to your image
mask_generator = SemanticSAMPredictor(build_semantic_sam(model_type='<model_type>', ckpt='</your/ckpt/path>')) # model_type: 'L' / 'T', depends on your checkpint
iou_sort_masks, area_sort_masks = mask_generator.predict_masks(original_image, input_image, point='<your prompts>') # input point [[w, h]] relative location, i.e, [[0.5, 0.5]] is the center of the image
plot_multi_results(iou_sort_masks, area_sort_masks, original_image, save_path='../vis/')  # results and original images will be saved at save_path

在这里插入图片描述

3 报错修改

通常运行后会出现以下报错
Please compile MultiScaleDeformableAttention CUDA op with the following commands:
‘cd mask2former/modeling/pixel decoder/ops‘
‘sh make.sh’
在这里插入图片描述
这个报错是由于deformable-DETR-main模型集成错误,所以需要重新对该模型进行编译

3.1 下载Deformable-DETR

https://github.com/fundamentalvision/Deformable-DETR
在github上下载Deformable-DETR模型

3.2 编译Deformable-DETR
# 下载项目后,进入下述目录进行编译
cd ./models/ops
sh ./make.sh
3.3 编译环境

建议编译环境在cuda11,cudnn8,gcc11环境,其他环境可能会编译不通过
添加链接描述

4 测试通过

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

绘视小技巧

本人识别赛top2整理内容齐齐

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值