mmdetection的应用_测试demo_训练自己voc格式的数据集
根据电脑配置mmdetection环境
根据官网的install.md教程并结合自己电脑配置环境安装
电脑配置
Ubuntu 16.04
RTX2070
环境主要配置版本:
python3.7
cuda 10.0
cudnn 7.6.4
pytorch 1.1.0
pytorch 与 cuda适配版本下载链接
环境里缺的包自己在终端用pip安装上。
安装mmcv
git clone https://github.com/open-mmlab/mmcv.git
cd mmcv
pip install . # 此处有个 .
将整个mmdetection项目 clone 到电脑上
git clone https://github.com/open-mmlab/mmdetection.git
cd mmdetection
之后,需要进行编译,切勿忘记这一步编译。
即
pip install -r requirements/build.txt
pip install "git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI"
pip install -v -e . # or "python setup.py develop"
参考博客:mmdetection工具网上博客整理
mmdetection源码笔记(一):train.py解读
mmdetection源码阅读笔记
mmdetection - 基于PyTorch的开源目标检测系统
将coco模型转化为voc模型:参考链接
mmdetection的基本使用
环境配置及编译结束后,开始进行demo的测试。
demo测试-前提条件是需要有模型文件,在mmdetection文件夹下创建checkpoints文件夹放置模型文件。模型文件下载处。
模型配置文件在configs
文件下。其各个参数的含义参考:
博客:mmdetection的configs中的各项参数具体解释
在 tools 文件夹下 新建demo.py
demo.py测试代码如下:
from mmdet.apis import init_detector, inference_detector, show_result
#
config_file = '../configs/rpn_r50_fpn_1x.py'
checkpoint_file = '../checkpoints/rpn_r50_fpn_1x_20181010-4a9c0712.pth'
model = init_detector(config_file, checkpoint_file)
img = '../demo/demo.jpg'
result = inference_detector(model, img)
# show_result(img, result, model.CLASSES)
# show_result(img, result, model.CLASSES, out_file='result.jpg')
show_result(img, result, model.CLASSES)
报错:
Traceback (most recent call last):
File "/home/ouc/6_objectdet/URPC2020/mmdetection/tools/demo.py", line 43, in <module>
show_result(img, result, model.CLASSES)
File "/home/ouc/6_objectdet/URPC2020/mmdetection/mmdet/apis/inference.py", line 179, in