mmdetection的更新与安装

原本使用了老版本的mmdetection ,但是长期未用就删除了,再安装的时候已经是新版本的mmdetection了,之前的简单的安装方式是不可用的,所以在这里重新进行mmdetection的安装,现将相关的安装步骤详细介绍如下:
更新到新版本mmdetection
软件版本
pytorch :1.4.0
cuda:10.0
Python3.7
安装过程最大的问题就是CUDA puytorch以及相应的mmcv的版本对应问题。因为mmcv的版本受限于CUDA版本,而本服务器的CUAD版本为10.0,无法改变。所以基于此进行了相应的改变。
总体先基于CUDA版本安装pytorch的版本,然后对pytorch进行重新的升级。在对mmcv进行安装

1、使用conda创建虚拟环境
conda create -n mmdetection python=3.7
conda activate mmdetection
2 在虚拟环境中安装软件
1)安装pytorch
这里因为受限于本CUDA的版本10.0,而在pytorch的官网上只有相对应的1.2.0等的版本,而后面的的mmcv也有CUDA和torch版本的要求。所以这里采用了先从pytorch官网下载对应CUDA10.0版本的pytorch,然后重新升级pytorch到更高版本的方式来安装CUDA对应高版本的pytorch
命令:
conda install pytorch1.2.0 torchvision0.4.0 cudatoolkit=10.0 -c pytorch
然后升级torch版本
conda update pytorch torchvision
升级后的版本为:
pytorch-1.4.0
torchvision-0.5.0
参考文献:
https://blog.csdn.net/miao0967020148/article/details/80400357
2)安装mmcv
mmcv为mmdetection配套的视觉库。通过调查得知,他主要与CUDA版本有关,所以调查选择了合适的版本
pip install mmcv-full
3)安装mmdetection
采用方法是直接从源文件安装(https://github.com/open-mmlab/mmdetection/blob/master/docs/install.md)
解压文件到相应文件夹中,然后进入
cd mmdetection
安装相应的依赖
pip install -r requirements/build.txt
pip install -v -e . # or “python setup.py develop”
参考文献步骤:
https://github.com/open-mmlab/mmdetection/blob/master/docs/install.md
4)测试DEMO1:faster-rcnn r50 fpn 1x coco 显示在屏幕上
python tools/test.py configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py
checkpoints/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth
–show
这里需要下载相应pth到checkpoints文件夹中,相关pth模型存放在https://github.com/open-mmlab/mmdetection/tree/master/configs/faster_rcnn

运行程序即可得到相应的输出结果:
mmdetection的更新与安装