目标检测库MMDetection的配置(MMDetection: Open MMLab Detection Toolbox and Benchmark)

 

1、论文下载地址:

MMDetection: Open MMLab Detection Toolbox and Benchmark. [paper

2、代码下载地址:

https://github.com/open-mmlab/mmdetection

3、创建虚拟环境并激活

conda create -n openmmlab python=3.7 -y
conda activate openmmlab

4、安装pytorch和torchvision

pip install torch===1.4.0 -f https://download.pytorch.org/whl/torch_stable.html
 
pip install torchvision===0.5.0 -f https://download.pytorch.org/whl/torch_stable.html

5、安装mmcv-full

pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu100/torch1.4.0/index.html

我的CUDA版本是10.0,torch版本是1.4.0,大家针对性更改。安装编译需要很长一段时间,耐心等待。

6、安装apex

下载apex:

git clone https://github.com/NVIDIA/apex.git

 进入apex目录安装

cd apex

python setup.py install

7、安装MMDetection

进入第2步骤下载的工程路径运行:

pip install -r requirements/build.txt
python setup.py develop

可能遇到错误:

No local packages or working download links found for panopticapi@ git+https://github.com/cocodataset/panopticapi.git
error: Could not find suitable distribution for Requirement.parse('panopticapi@ git+https://github.com/cocodataset/panopticapi.git')

错误原因:

服务器上网络问题,连不上github,所以git库包panopticapi失败。

解决方法:

1)手动下载panopticapi包

https://github.com/cocodataset/panopticapi

2)放到工程路径解压

3)手动编译

 python panopticapi/setup.py develop

 4)打开runtime.txt,删除第三行的 @ git+https://github.com.cnpmjs.org/cocodataset/panopticapi.git

 5)重新运行python setup.py develop,编译成功。

8、下载预训练模型

下载地址:

https://github.com/open-mmlab/mmdetection/blob/master/docs/model_zoo.md

以faster R-CNN为例

1)

 2)

3)新建checkpoints路径,将下载的模型放入

9、新建demo.py文件,输入以下代码

from mmdet.apis import init_detector, inference_detector, show_result_pyplot
import cv2

config_file = 'configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py'
# download the checkpoint from model zoo and put it in `checkpoints/`
# url: https://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_1x_coco/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth
checkpoint_file = 'checkpoints/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth'
device = 'cuda:0'
# init a detector
model = init_detector(config_file, checkpoint_file, device=device)
# inference the demo image

image='demo/demo.jpg'

result = inference_detector(model, image)

show_result_pyplot(model, image, result, score_thr=0.3)

# image = model.show_result(image, result, score_thr=0.3)
#
# cv2.imshow('demo', image)
# cv2.waitKey()

10、运行得到结果

python demo.py

  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值