深度学习系列之mmdetection目标检测工具安装、测试

深度学习系列之mmdetection目标检测工具安装、测试

  Windows10 环境下mmdetection安装


前言

深度学习目标检测工具箱mmdetection,支持Faster-RCNN,Mask-RCNN,Fast-RCNN等主流的目标检测框架。


提示:以下是本篇文章正文内容,下面案例可供参考

一、安装前准备

   1. 已安装好Pytorch环境
   2. 选择mmcv—安装mmcv或者mmcv-full,其中mmcv是CPU版本,mmcv-full是GPU版本,根据Pytorch和CUDA版本选择合适的mmcv-full版本:
   网站:https://download.openmmlab.com/mmcv/dist/index.html


二、安装

1.Pytorch安装

   参考 深度学习系列之环境配置(i7-10700 + RTX3080+32G+500G)

2.安装mmcv-full(根据CUDA选择安装版本)

   网上说,我也这么操作了,毕竟是安装mmcv-full。首先conda环境中查看是否安装了mmcv,输入pip list ,然后卸载环境中已经存在的mmcv,输入 pip uninstall mmcv
   安装方式1:选择对应版本安装(本人选择)

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

  参考cuda选择(本文安装选择):mmcv_full-1.2.0+torch1.7.0+cu110-cp37-cp37m-manylinux1_x86_64.whl

   安装方式2:官网下载github源码安装(github里有安装手册)

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

3.安装mmdetection

git clone https://github.com/open-mmlab/mmdetection.git
cd mmdetection
pip install -r requirements
python setup.py develop

  参考文件夹目录
在这里插入图片描述

三、验证(测试)

   1.测试文件准备
   下载权重文件放在下面“测试”新建文件夹checkpoints文件夹中,新建测试代码()如下,其中configs、demo官方下载文件已经包含。

wget https://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_1x_coco/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth

   2.测试代码

from mmdet.apis import init_detector, inference_detector,show_result_pyplot
import matplotlib
matplotlib.use('TkAgg')  
import matplotlib.pyplot as plt

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
img= 'demo/demo.jpg'
result = inference_detector(model, img)
show_result_pyplot(model, img, result)

   测试图片
来自mmdetection官方github

   测试结果
在这里插入图片描述


总结

   还好很顺利,一次安装成功,如有不足,请留言指正 ,谢谢!

参考

1.mmdetection官方安装流程

猜你喜欢

转载自blog.csdn.net/weixin_38716233/article/details/124814079