用darknet的YOLOv4训练后在验证集上测试。
0.下载darknet源码并编译
git clone https://github.com/AlexeyAB/darknet/
修改Makefile文件,根据作者提示修改参数
git clone https://github.com/AlexeyAB/darknet
cd darknet
make
1、准备好测试集
需要将图片和标签放在一个文件夹下
2、准备相关文件
.data文件
修改画红框的两个地址
.txt文件
包含所有验证集/测试集图片的txt文件
以下脚本可以帮助快速生成
import glob
img_path ='/home/zxc/yutong/darknet-yolov4/class29_train/images/val/*.jpg'
img_list = glob.glob(img_path)
f = open('test.txt','w')
for img in img_list:
f.write(img+'\n')
f.close()
.names文件
包含目标检测类别的文件
3、在命令行测试验证集
依次为.data文件 .cfg网络参数 .weights权重文件
./darknet detector map test.data node1/yolov4-tiny.cfg node1/yolov4-tiny_last.weights
打印出每一个类别的AP50以及所有类别的map50
参考
darknet训练时计算mAP和测试计算mAP
https://github.com/AlexeyAB/darknet