基于PaddlePaddle实现的目标检测模型PP-YOLO
PP-YOLO
PP-YOLO 是 PaddleDetection 优化和改进的 YOLOv3 的模型,其精度(COCO 数据集 mAP)和推理速度均优于 YOLOv4 模型,PP-YOLO 在 COCO test-dev2017 数据集上精度达到 45.9%,在单卡 V100 上 FP32 推理速度为 72.9 FPS, V100 上开启 TensorRT 下 FP16 推理速度为 155.6 FPS。
本教程源码地址:https://github.com/yeyupiaoling/PP-YOLO
训练
- 安装 PaddlePaddle GPU 版本,需要 1.8.4 以上。
python -m pip install paddlepaddle-gpu==1.8.4.post107 -i https://mirror.baidu.com/pypi/simple
- 安装 ppdet,以及所需依赖包。
python setup.py
- 准备数据,默认使用的是 VOC 格式的数据集,如果要修改为 COCO 格式的数据集,需要修改
configs/ppyolo.yml
。其中 VOC 格式操作如下,首先将标注文件放在dataset/annotation/
,图像文件放在dataset/images/
,最后执行create_data_list.py
程序生成数据列表和类别名称。 - 修改
configs/ppyolo.yml
中的类别数量num_classes
,这个类别数量不用算上背景这一类别。 - 执行
train.py
开始训练。
评估
执行 eval.py
完成模型评估,其中参数 --weights
为模型的路径,不需要带后缀名,--overlap_thresh
为需要评分的阈值,执行之后输入如下,从输出可以知道当阈值为 0.75 时,mAP 为 90.75。
$ python eval.py --weights=save_models/model_final --overlap_thresh=0.75
2020-08-17 12:56:58,530-INFO: Test iter 0
2020-08-17 12:57:13,349-INFO: Test iter 100
2020-08-17 12:57:27,421-INFO: Test iter 200
2020-08-17 12:57:36,716-INFO: Test finish iter 268
2020-08-17 12:57:36,716-INFO: Total number of images: 1070, inference time: 27.43800773116421 fps.
2020-08-17 12:57:36,717-INFO: Start evaluate...
2020-08-17 12:57:36,999-INFO: Accumulating evaluatation results...
2020-08-17 12:57:37,017-INFO: mAP(0.75, 11point) = 90.75
预测
- 执行预测执行先要导出预测模型,执行
export_model.py
,其中参数--weights
为模型的路径,不需要带后缀名,--output_dir
输出预测模型的路径,文件目录结构如下。
$ python export_model.py --weights=save_models/model_final --output_dir=output/
$ tree output
output/
├── infer_cfg.yml
├── __model__
└── __params__
- 项目提供了两种预测方式,第一个
infer_path.py
为使用图像路径进行预测,第二个infer_camera.py
为调用摄像头进行实时预测。
您好,在训练完进行验证时,出现了这样的报错。
File "/home/aistudio/ppdet/utils/eval_utils.py", line 263, in eval_results
map_type=map_type)
File "/home/aistudio/ppdet/utils/voc_eval.py", line 86, in bbox_eval
detection_map.update(bbox, gt_box, gt_label, difficult)
File "/home/aistudio/ppdet/utils/map_utils.py", line 121, in update
if max_overlap > self.overlap_thresh:
TypeError: '>' not supported between instances of 'numpy.ndarray' and 'str'
请问要怎么解决呢