windows下配置和mmdetection目标检测源码

mmdetection(简称mmdet)是OpenMMLab商汤科技的开源目标检测软件。配置还是会遇到不少坑,下面给出在Windows下面的配置和运行。

(1)建立conda环境

我配置了python3.9没有成功,然后配置了3.8成功搞定,pytorch1.9,cuda10.2,安装conda后利用下面命令创建虚拟环境:

conda create --name py38 python=3.8

(2)从GitHub下载mmdet源码并进行前期预备工作,地址:https://github.com/open-mmlab/mmdetection

以管理员权限运行conda prompt,然后进入安装目录我的是G:\mmdetection-master。

执行下面三个方面的其他组件安装

    1)pytorch安装,用下面的命令

conda install pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch

如果比较慢,就换成

pip3 install torch==1.9.1+cu102 torchvision==0.10.1+cu102 torchaudio===0.9.1 -f https://download.pytorch.org/whl/torch_stable.html

     2)安装源码中的必须组件(pip3 和 pip命令没区别)

pip install -r requirements.txt

    3)安装mmvc

pip install mmcv-full

(3)编译mmdet

运行命令

#激活py38环境

activate py38

#执行编译

python setup.py build develop

(4)运行和测试目标检测

cd/demo,然后建立一个py文件

在文件里面运行如下的代码

from mmdet.apis import init_detector, inference_detector, show_result_pyplot
import mmcv
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'
model = init_detector(config_file, checkpoint_file, device='cuda:0')
img = 'demo.jpg'
# img='input1.jpg'
result = inference_detector(model, img)
show_result_pyplot(model, img, result)

输入结果如下:

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值