ubuntu安装mmdetection

ubuntu安装mmdetection
1. 新建python虚拟环境

conda create -n openmmlab python=3.7 
conda activate openmmlab

2. 安装pytorch和torchvision
(需要提前安装好cuda和cudnn,torch的版本要和cuda对应上)

pip install torch==1.8.0+cu111 torchvision==0.9.0+cu111 -f https://download.pytorch.org/whl/torch_stable.html

3. 安装mmcv

这是官方推荐的方式,但是感觉不太好用,会出现版本对应不上的问题
pip install openmim
mim install mmcv-full #版本对应不上,不建议

所以我使用的方式为:
pip install mmcv-full -f http://download.openmmlab.com/mmcv/dist/cu111/toch1.8.0/index.html
注:这行代码里面的cu111/toch1.8.0需要改成自己服务器上对应的版本

4. 接下来就可以按照mmdetection了。

git clone https://github.com/open-mmlab/mmdetection.git
cd mmdetection
pip install -r requirements/build.txt
pip install -v -e .

5. 测试mmdetection

以faster rcnn为例:
(1)先新建一个存在权重文件的文件夹checkpoints

cd mmdetection
mkdir checkpoints

(2) 下载权重文件
http://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_1x_coco/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth

(3)将上面下载的权重文件放在checkpoints文件夹里面
(4)运行命令
在cpu上运行

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 --device cpu

在gpu上运行

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

参考链接:
https://github.com/open-mmlab/mmdetection/blob/master/docs/zh_cn/get_started.md

  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值