mmdetection安装


前言

这里为大家整理下自己使用mmdetection的一些经验

一、mmdetection是什么?

mmdetection是商汤科技(2018 COCO 目标检测挑战赛冠军)和香港中文大学最近开源了一个基于Pytorch实现的深度学习目标检测工具箱。

二、mmdetection的安装

1.安装依赖的过程中一定要考虑MMDetection 和 MMCV 版本兼容性
下面给的链接里有一个表格,里面有所有mmdet对应的mmcv版本。简单的按照链接里的教程走,一般都不会有问题。里面还有更加详细的教程

# 如果官网下载比较慢的话,可以自己先在自己创建的虚拟环境下安装好GPU版本的pytorch,然后在自己的虚拟环境下执行pip install openmim后的内容
conda create -n openmmlab python=3.7 pytorch==1.6.0 cudatoolkit=10.1 torchvision -c pytorch -y 
conda activate openmmlab
pip install openmim
mim install mmcv-full
git clone https://github.com/open-mmlab/mmdetection.git
cd mmdetection
pip install -r requirements/build.txt
pip install -v -e .   #注意这里结尾有个点

2.如果不想安装最新版本的mmdetection,可以在下面图片的箭头出处下载其他版本的,但是下载其他版本的,要注意不要用上面的安装方法了,他是自动安装最新版本的一些配置,可以手动安装!在这里插入图片描述
手动安装过程

conda create -n openmmlab python=3.7 -y
conda activate openmmlab
conda install pytorch==1.7.0 torchvision==0.8.0 cudatoolkit=10.2
# 安装指定版本的mmcv-full,对应mmdetection,下面的链接里有表格
pip install mmcv-full=={mmcv_version} -f https://download.openmmlab.com/mmcv/dist/{cu_version}/{torch_version}/index.html
eg:pip install mmcv-full==1.5.3 -f https://download.openmmlab.com/mmcv/dist/cu111/torch1.9.0/index.html
# 这样安装的是最新的mmdetection,如果上面自己下载了,就不用这个操作了
git clone https://github.com/open-mmlab/mmdetection.git
#只要在mmdetection的文件夹路径就行
cd mmdetection
pip install -r requirements/build.txt
pip install -v -e .

3.验证方法

from mmdet.apis import init_detector, inference_detector
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
inference_detector(model, 'demo/demo.jpg')
# 有结果显示就说明安装成功了

转中文教程链接:里面有多种方法https://mmdetection.readthedocs.io/zh_CN/latest/get_started.html#id2

总结

安装有什么问题,可以在评论区留言。

  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

AI、明察秋毫

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值