一、MMDectection简介
MMDetection主要支持目标检测和实例分割两类任务
本次教学基于Openbayes平台
二、如何训练自己的检测模型
下载预训练模型→编写配置文件
[基于已有配置文件进行修改:加载模型、减小训练轮次、改小学习率、启动训练、推理测试]
!min search mmdet --model '[模型名字]'
!mim download mmdet --config [配置文件名字] --dest [下载路径]
#查看配置文件
from mmcv import Config
config = Config.fromfile('[自己写的配置文件.py]')
print(config.pretty_text)
#启动训练
!mim train mmdet [py文件名]
训练完了需要推理
#一张图片上推理
from mmdet.apis imoort init_detector,inference_detector,show_result_pyplot
config_file=''
checkpoint_file=''
img='[测试文件路径]'
model=init_detector(config_file,checkpoint_file)
result=inference_detector(model,img)
show_result_pyplot(mode,img,result)
#整个数据集上推理
!mim test mmdet [配置文件.py] --checkpoint [训练出的模型文件路径] --show-dir [保存路径]