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)

显示检测结果:

你可能感兴趣的:(深度学习,深度学习,python,git,mmdetection)