2021/5/24 voc-test数据集 yolov4测试
1 运行eval_voc.py
出现
Traceback (most recent call last): File "C:/Users/gja/Downloads/YOLOv4-pytorch-master/YOLOv4-pytorch-master/eval_voc.py", line 148, in mode=opt.mode File "C:/Users/gja/Downloads/YOLOv4-pytorch-master/YOLOv4-pytorch-master/eval_voc.py", line 38, in init self.__load_model_weights(weight_path) File "C:/Users/gja/Downloads/YOLOv4-pytorch-master/YOLOv4-pytorch-master/eval_voc.py", line 47, in __load_model_weights self.__model.load_state_dict(chkpt["model"]) KeyError: 'model'
在 https://github.com/argusswift/YOLOv4-pytorch/issues/127 得到解决办法:self .__ model.load_state_dict(chkpt [” model“])修改为:self .__ model.load_state_dict(chkpt)
原理为 在读取dict
的key
和value
时,如果key
不存在,就会触发KeyError
错误(https://blog.csdn.net/u011089523/article/details/72887163)
表现为 :PyTorch加载模型model.load_state_dict()出现问题 (https://blog.csdn.net/qq_32998593/article/details/89343507)
2 修改后 成功运行。结果如下:
[2021-05-24 17:18:54,062]-[eval_voc.py line:49]:***********Start Evaluation**************** 100%|██████████| 49/49 [00:04<00:00, 10.08it/s] [2021-05-24 17:18:59,394]-[eval_voc.py line:57]:insulator --> mAP : 0.8226139145595702 [2021-05-24 17:18:59,394]-[eval_voc.py line:57]:knife-2 --> mAP : 0.9758812615955472 [2021-05-24 17:18:59,394]-[eval_voc.py line:60]:mAP:0.8992475880775588 [2021-05-24 17:18:59,394]-[eval_voc.py line:61]:inference time: 500.31 ms [2021-05-24 17:18:59,394]-[eval_voc.py line:63]: ===val cost time:5.3320s
Process finished with exit code 0