关于Win10系统下mmdetection 2.0环境配置笔记

1.关于mmdetection

之前对于目标检测这块一直都是使用的YOLO系列,偶然接触到mmdetection,大致了解了下,碰巧最近比较闲,就根据网上的资料自己动手搭建了环境,写个博客记录下环境配置过程,方便自己以后需要时查阅。
商汤科技(2018 COCO 目标检测挑战赛冠军)和香港中文大学开源了一个基于Pytorch实现的深度学习目标检测工具箱mmdetection,支持Faster-RCNN,Mask-RCNN,Fast-RCNN等主流的目标检测框架,后续会加入Cascade-RCNN以及其他一系列目标检测框架。
相比于Facebook开源的Detectron框架,作者声称mmdetection有三点优势:performance稍高、训练速度稍快、所需显存稍小。
以增添mmdetection的configs中的各项参数具体解释,以及目标检测比赛的一些小技巧(比赛专用)。

关于环境配置过程,感谢B站的小鸡炖技术UP主。由于最近刚换的电脑,所以关于CUDA、Anaconda等环境都需要重新配置,正好借mmdetection自己再熟悉下,下面记录了我整个的配置过程。

2.基本环境

链接:https://pan.baidu.com/s/17o7Z0jZaEu3b_iLtAnaYvg
提取码:p788
在这里插入图片描述
关于软件的安装及环境配置参考如下博客,亲测有效。
①windows10+nvidia驱动+cuda10.1+cudnn安装教程
https://blog.csdn.net/fengxinzioo/article/details/105646969
②Anaconda更换镜像源方法
https://jingyan.baidu.com/article/1876c8527be1c3890a137645.html
https://blog.csdn.net/SueMagic/article/details/85332457
③pip install -r requirements.txt安装超时解决方法
https://www.cnblogs.com/leafchen/p/13395677.html
https://blog.csdn.net/weixin_43116723/article/details/104139541

3.mmdetection 2.0环境配置

链接:https://pan.baidu.com/s/10H9asPlhFfABYOsZ5oycAA
提取码:u5r0
1.在Anaconda Prompt中新建一个虚拟环境mmd20并激活它。

conda create -n mmd20 python=3.7
conda activate mmd20

2.为方便下载,直接在Anaconda Prompt用pip install + 下载的那个文件的路径和文件名。
安装
在这里插入图片描述

pip install E:\mmdetection\torch-1.3.0-cp37-cp37m-win_amd64.whl
pip install E:\mmdetection\torchvision-0.4.1-cp37-cp37m-win_amd64.whl

在这里插入图片描述
3.pip install cython opencv-python pillow matplotlib
在这里插入图片描述
4.修改D:\Anacondaanzhuang\envs\mmd20\Lib\site-packages\torch\utils\cpp_extension.py(这里根据你安装的Anaconda位置)
在这里插入图片描述
5.将E:\mmdetection2.0\mmd2.0中的flat_hash_map.h和order_preserving_flat_hash_map.h文件替换掉D:\Anacondaanzhuang\envs\mmd20\Lib\site-packages\torch\include\c10\util中的文件。 在这里插入图片描述
6.在E:\mmdetection2.0\mmcv-0.5.8目录下执行

   pip install -e .

在这里插入图片描述
7.因为要用到coco数据集训练,在E:\mmdetection2.0\cocoapi\PythonAPI目录下执行

python setup.py build_ext install

在这里插入图片描述
8.在E:\mmdetection2.0\mmd2.0目录下执行

   pip install -r requirements.txt

在这里插入图片描述
9.在E:\mmdetection2.0\mmd2.0目录下执行(编译时间需要几分钟)

python setup.py develop

10.在E:\mmdetection2.0\mmd2.0目录下进行测试
测试一:

python demo/image_demo.py demo/demo.jpg configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py checkpoints/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth 

在这里插入图片描述
测试二:
①先重新安装opencv-python版本

 pip install opencv-python==4.2.0.34

②输入:

python demo/webcam_demo.py configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py checkpoints/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth

如下:
在这里插入图片描述

4.Linux(Ubuntu)基础使用

4.1 Vmware虚拟机中安装Ubuntu

想要获得Linux环境,一个办法就是将电脑系统直接换成Linux系统,但平常用惯了Windows系统,直接切换为Linux系统或多或少会有很多不便。可以在自己的电脑上安装一个Linux虚拟机。所谓虚拟机,就是在已有的电脑里再虚拟出一个或多个电脑,可以理解为电脑中的电脑。
比如说可以在虚拟机里安装一个Window电脑,或者安装一个Linux电脑,都是可以的。虚拟机的作用就是虚拟出运行一台真正的电脑所需要的各种资源,然后就可以在上面跑其它的操作系统。
常用的虚拟机有Vmware,VirtualBox这两种。这两种虚拟机用起来差不多,这里推荐Vmware Workstation。

Vmware Workstation 15.5.1安装和激活
https://pan.baidu.com/s/1eWc4BwbLq72gns5O-SVvKA
提取码:hqw0
推荐:虚拟机的安装使用、ubuntu的安装及镜像源更新等
VMware Workstation 15.5.1安装及Ubuntu18.04安装
VMware Workstation 虚拟机权威指南——零基础虚拟机深度讲解
Linux(Ubuntu)零基础体验教学
VMware Workstation 16安装和VMwareTools及Ubuntu20.04安装
https://www.bilibili.com/video/BV18U4y1W7av?p=6

在这里插入图片描述
视频地址:https://www.bilibili.com/video/BV174411t7PU?p=1

4.2 ubuntu系统下训练mmdetection2.0

(虚拟机是虚拟显卡,不能装cuda,所以也没法进行GPU加速。于是放弃mmdetection(ubuntu)环境下的训练,改为windows环境下的训练。记下mmdetection(ubuntu)环境下的训练教程,以便以后用到)
Pytorch环境配置(ubuntu):https://www.bilibili.com/video/BV1N54y1i7yG
mmdetection2.3环境配置(ubuntu):https://www.bilibili.com/video/BV1Q54y1v7XR
mmd2.3训练faster-rcnn(ubuntu):https://www.bilibili.com/video/BV1864y1c7UG
mmdetection2.3全家桶(ubuntu):https://www.bilibili.com/video/BV1u64y1c7Mx
mmdetection系列教程合集(ubuntu):https://www.bilibili.com/video/BV1jV411U7zb

Guess you like

Origin blog.csdn.net/qq_45445740/article/details/114676779