Python影像辨識筆記(十三):計算YOLOv4 Weights的mAP

Image for post
Image for post
Image for post
Image for post
Image for post
Image for post

2020 / 06 /11更新重要觀念:

Training set、Validation set、Test set的差別

Ripley, B.D(1996), Pattern Recognition and Neural Networks

能在local測試mAP嗎?

不行,因為官方沒有提供test set的label,只能透過COCO的Server去評估mAP

參考資料:

https://github.com/AlexeyAB/darknet/wiki

How to evaluate AP of YOLOv4 on the MS COCO evaluation server

1. 設定 width=608 height=608 (or 512x512, or 416x416) in the [net] section of cfg/yolov4.cfg file

https://github.com/AlexeyAB/darknet/blob/6f718c257815a984253346bba8fb7aa756c55090/cfg/yolov4.cfg#L8-L9

2. 下載並解壓縮test-dev2017 dataset:

test集圖片中的txt和jpg要擺在同一個資料夾裡面。

3. 下載testdev2017.txt清單檔案,並改成自己的路徑。

https://raw.githubusercontent.com/AlexeyAB/darknet/master/scripts/testdev2017.txt

4. 下載yolov4.weights

5. 建立cfg/coco-mAP.data

cfg/coco.data 的內容應該如下所示

#將train、valid改成屬於自己路徑的資料夾
classes= 80
train = /yanwei.liu/darknet/coco/trainvalno5k.txt
valid = yanwei.liu/darknet/coco/testdev2017.txt #要用test set
names = /yanwei.liu/darknet/data/coco.names
backup = /yanwei.liu/darknet/backup/
eval=coco

6. 在darknet目錄底下建立/results/ 資料夾

mkdir results

7. 執行驗證:

./darknet detector valid cfg/coco-mAP.data cfg/yolov4.cfg yolov4.weights

8. 第七步驟完成後,將 /results/coco_results.json 改名成 detections_test-dev2017_yolov4_results.json 並且壓縮成 detections_test-dev2017_yolov4_results.zip

$ cd results
$ mv coco_results.json detections_test-dev2017_yolov4_results.json
$ zip detections_test-dev2017_yolov4_results.zip detections_test-dev2017_yolov4_results.json

9. 提交 detections_test-dev2017_yolov4_results.zip 到MS COCO 驗證伺服器,選擇( test-dev2019 (bbox) )項目

該網站需要註冊帳號才能使用

Written by

Machine Learning / Deep Learning / Python / Flutter cakeresume.com/yanwei-liu

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store