mmdetection安装与测试

如下是mmdetection的github地址:

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

在github中的INSTALL.md文件中,对mmdetection的安装已经有详细的说明,但个人感觉还是有些坑,下面是个人总结的安装与测试步骤:

安装:

1. 安装依赖,我的机器上安装的python3.5、cuda9.0、pytorch1.1,注意pytorch要安装不要低于1.1的版本,否则测试的时候会报错,issues建议安装pytorch1.1版本。

2. 安装 cython

sudo pip install cython

3. 安装mmcv

git clone https://github.com/open-mmlab/mmcv.git

cd mmcv

sudo pip install .

4.安装pycocotools, 如果不安装测试的时候会报错

sudo pip install pycocotools

5. 安装mmdetection

下载:

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

cd mmdetection

编译cuda:

./compile.sh

安装mmdetection:

python setup.py develop

 

测试:

1.下载预训练模型

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

在上述链接中下载需要测试的预训练模型,比如我下载的是faster_rcnn_r50_fpn_1x_20181010-3d1b3351.pth,并在mmdetection目录下新建目录checkpoints,将模型存放到该目录下。

2. 创建测试目录

在mmdetection目录下创建my_code/test目录,稍后将测试代码以及待图像存放在该目录下

mkdir -p my_code/test

3. 测试代码

#coding=utf-8

from mmdet.apis import init_detector
from mmdet.apis import inference_detector
from mmdet.apis import show_result

# 模型配置文件
config_file = '../../configs/faster_rcnn_r50_fpn_1x.py'

# 预训练模型文件
checkpoint_file = '../../checkpoints/faster_rcnn_r50_fpn_1x_20181010-3d1b3351.pth'

# 通过模型配置文件与预训练文件构建模型
model = init_detector(config_file, checkpoint_file, device='cuda:0')

# 测试单张图片并进行展示
img = 'test1.jpg'
result = inference_detector(model, img)
show_result(img, result, model.CLASSES)

# 测试一个图像列表并保存结果图像
imgs = ['test1.jpg', 'test2.jpg', 'test3.jpg']
for i, result in enumerate(inference_detector(model, imgs)):
    show_result(imgs[i], result, model.CLASSES, out_file='result_{}.jpg'.format(i))

4. 测试结果:

git clone https://github.com/open-mmlab/mmcv.gitgit clone https://github.com/open-mmlab/mmcv.git

 

  • 8
    点赞
  • 39
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 14
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

洪流之源

你的鼓励将是我创作的最大动力

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

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

打赏作者

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

抵扣说明:

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

余额充值