mmdetection 安装 以及 测试记录

安装

首先下载 mmdetection的包:
官方的下载地址:

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

如果下载太慢了就从码云上下载能快一点:

git https://gitee.com/hejuncheng1/mmdetection.git

假定已经安装好最基础的CUDA,cudnn,pytorch,torchvision等等

然后需要安装mmcv,可以直接pip install mmcv ,但是后面可能会出现No module named 'mmcv._ext' 的错误,所以推荐去下载whl,然后本地安装,网址在这:https://download.openmmlab.com/mmcv/dist/index.html
选择对应版本下载然后本地pip安装即可。

进入mmdetection目录下:

cd mmdetection

首先安装要求的环境:

pip install -r requirements.txt

大概率会出现包下不下来的情况,这时候可以去手动下载然后本地安装。

完事后还是在mmdetection目录下执行就ok了

python setup.py develop
# or "pip install -v -e ."

测试是否安装完成

在mmdetection目录下新建 checkpoints文件夹,然后下载faster-rcnn的预训练权重,放到checkpoints里:

wget http://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_1x_coco/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth

在mmdetection目录下打开python,输入以下命令进行demo.jpg的检测:

from mmdet.apis import init_detector, inference_detector, show_result_pyplot
import mmcv
config_file = 'configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py'
checkpoint_file = 'checkpoints/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth'
device = 'cuda:0'
model = init_detector(config_file, checkpoint_file, device=device)
# 这一步会输出: "Use load_from_local loader"
img = 'demo/demo.jpg'
result = inference_detector(model,img)
show_result_pyplot(model,img,result)

显示检测结果:
在这里插入图片描述

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值