MMdetection安装教程(Ubuntu)

1、下载工程

自行去 Github 下载代码
在下载好代码之后,打开里面的安装文档,查看一下要安装的 Python 最低版本和 Pytorch最低版本

  • Python 3.6+
  • PyTorch 1.3+
  • CUDA 9.2+ (如果基于 PyTorch 源码安装,也能够支持 CUDA 9.0)
2、新建虚拟环境
conda create -n mmdetection python=3.7 -y

新建成功后,进入虚拟环境里面

source activate mmdetection
3、安装Pytorch

我这里安装的是 Pytorch1.7.0+cu101 版本

pip install torch==1.7.0+cu101 torchvision==0.8.1+cu101 torchaudio==0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
4、安装 mmcv-full

mmcv-full安装命令文档
去上面这个网址,查看一下对应 Pytorch版本 和 对应 CUDA版本 的安装命令,我这里安装的版本是
mmcv-full>=1.3.17

pip install mmcv-full==1.13.17 -f https://download.openmmlab.com/mmcv/dist/cu101/torch1.7.0/index.html
5、以上都安装成功后

从模型网址:模型网址
下载预训练模型,并放在指定文件夹
然后在主工程目录下,新建 demo.py 文件,运行即可
如果有报错,缺库文件,根据提示直接安装,就好了。

from mmdet.apis import init_detector, inference_detector, show_result_pyplot

config_file = './configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py'
# 从 model zoo 下载 checkpoint 并放在 `checkpoints/` 文件下
# 网址为: http://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 = 'cpu'
# 初始化检测器
model = init_detector(config_file, checkpoint_file, device=device)
# 推理演示图像
result = inference_detector(model, './demo/demo.jpg')
show_result_pyplot(model=model, img='demo/demo.jpg', result=result, score_thr=0.9)
  • 1
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值