Mmdetection 配置

Mmdetection 配置

1、创建虚拟环境

$ conda create -n mmdlab python=3.7 -y
$ conda activate mmdlab

2、根据cuda版本安装pytorch和torchvision(使用pip 安装比conda快)

$ pip install torch==1.4.0+cu100 torchvision==0.5.0+cu100 -f https://download.pytorch.org/whl/torch_stable.html

在这里插入图片描述
图片来自:https://blog.csdn.net/sinat_28442665/article/details/108059954
cuda版本查询:

$ cat /usr/local/cuda/version.txt

3、克隆mmdetection 仓库

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

需要别的版本可到github下载到本地。

4、安装依赖库(2.4版本requirements.txt里面包含mmpycocotools不用装pycocotools,之前版本也包含pycocotools)

$ pip install -r requirements.txt

#安装到mmpycocotools模块可能会遇到error(红色字体)
#重新pip install mmpycocotools
安装mmcv_full:

$ pip install mmcv_full==latest+torch1.4.0+cu100 -f https://openmmlab.oss-accelerate.aliyuncs.com/mmcv/dist/index.html

#具体MMCV版本可到网址查看,把版本号替代latest即可。

安装mmdet:

$ python setup.py develop

or

 $ pip install -v -e .

5、验证demo.py

$ mkdir checkpoints  

#用于存放训练好的模型
#到configs文件下,进入一个网络的文件,在README.md 可以找到模型的下载路径
#下载好模型,放到checkpoints文件下,比如下载了mask_rcnn_r50_fpn_2x_coco.py对应的模型

#在mmdetection路径下运行:

$ python demo/image_demo.py  demo/demo.jpg configs/mask_rcnn/mask_rcnn_r50_fpn_2x_coco.py checkpoints/mask_rcnn_r50_fpn_2x_coco_bbox_mAP-0.392__segm_mAP-0.354_20200505_003907-3e542a40.pth

#无编译错误则环境配置成功

总过程:

$ conda create -n mmdlab python=3.7 -y
$ conda activate mmdlab
$ pip install torch==1.4.0+cu100 torchvision==0.5.0+cu100 -f https://download.pytorch.org/whl/torch_stable.html
$ git clone https://github.com/open-mmlab/mmdetection.git
$ cd mmdetection
$ pip install -r requirements.txt
$ pip install mmcv_full==latest+torch1.4.0+cu100 -f https://openmmlab.oss-accelerate.aliyuncs.com/mmcv/dist/index.html
$ python setup.py develop
$ python demo/image_demo.py  demo/demo.jpg configs/mask_rcnn/mask_rcnn_r50_fpn_2x_coco.py checkpoints/mask_rcnn_r50_fpn_2x_coco_bbox_mAP-0.392__segm_mAP-0.354_20200505_003907-3e542a40.pth

6、配置关键

python=3.7
torch、torchvision、cuda、mmcv_full版本对应好
pip install -r requirements.txt 遇到红色字体要重新install 知道成功
下载训练好的模型,若模型下载不全,会遇到error: _pickle.UnpicklingError: invalid load key, ‘<’.
若自己install 了pycocotools,可能 会遇到AttributeError: module ‘pycocotools’ has no attribute ‘version’ 。卸载pycocotools应该就没问题了,再不行就重新安装mmpycocotools模块

其实mmdetection配置不难,但我就搞了几天。。。。试了好几个版本。。。。。

哔哩哔哩mmdetection视频教程:
https://www.bilibili.com/video/BV1jV411U7zb?from=search&seid=7640738834101766499

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值