Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mAP (mean average precision) calculation for different Datasets (MSCOCO, ImageNet, PascalVOC) #2746

Open
AlexeyAB opened this issue Mar 26, 2019 · 8 comments
Labels
Explanations Explanations of the source code, algorithms or method of use

Comments

@AlexeyAB
Copy link
Owner

AlexeyAB commented Mar 26, 2019

Different approaches of mAP (mean average precision) calculation:

  1. -map_points 101 for MS COCO
  2. -map_points 11 for PascalVOC 2007 (uncomment difficult in voc.data)
  3. -map_points 0 for ImageNet, PascalVOC 2010-2012 and your custom dataset

For example:

  • use this command to calculate mAP@0.5 for ImageNet, PascalVOC 2010-2012 and your custom dataset:
    ./darknet detector map cfg/coco.data cfg/yolov3-spp.cfg yolov3-spp.weights

  • use this command to calculate mAP@0.5 for PascalVOC 2007 dataset:
    ./darknet detector map cfg/coco.data cfg/yolov3-spp.cfg yolov3-spp.weights -points 11

  • use this command to calculate mAP@0.5 for MSCOCO dataset:
    ./darknet detector map cfg/coco.data cfg/yolov3-spp.cfg yolov3-spp.weights -points 101 -iou_thresh 0.5

  • use these commands to calculate mAP@[.5, .95] for MSCOCO dataset:

./darknet detector map cfg/coco.data cfg/yolov3.cfg yolov3.weights -iou_thresh 0.50 -points 101
./darknet detector map cfg/coco.data cfg/yolov3.cfg yolov3.weights -iou_thresh 0.55 -points 101
./darknet detector map cfg/coco.data cfg/yolov3.cfg yolov3.weights -iou_thresh 0.60 -points 101
./darknet detector map cfg/coco.data cfg/yolov3.cfg yolov3.weights -iou_thresh 0.65 -points 101
./darknet detector map cfg/coco.data cfg/yolov3.cfg yolov3.weights -iou_thresh 0.70 -points 101
./darknet detector map cfg/coco.data cfg/yolov3.cfg yolov3.weights -iou_thresh 0.75 -points 101
./darknet detector map cfg/coco.data cfg/yolov3.cfg yolov3.weights -iou_thresh 0.80 -points 101
./darknet detector map cfg/coco.data cfg/yolov3.cfg yolov3.weights -iou_thresh 0.85 -points 101
./darknet detector map cfg/coco.data cfg/yolov3.cfg yolov3.weights -iou_thresh 0.90 -points 101
./darknet detector map cfg/coco.data cfg/yolov3.cfg yolov3.weights -iou_thresh 0.95 -points 101

Then calculate:
AP@[.5, .95] = mAP@IoU=0.50:.05:.0.95 =
(mAP@IoU=0.50 + mAP@IoU=0.55 + mAP@IoU=0.60 + mAP@IoU=0.65 + mAP@IoU=0.70 + mAP@IoU=0.75 + mAP@IoU=0.80 + mAP@IoU=0.85 + mAP@IoU=0.90 + mAP@IoU=0.95) / 10


I.e.


URLs:

@AlexeyAB AlexeyAB added the Explanations Explanations of the source code, algorithms or method of use label Mar 26, 2019
@pjspillai
Copy link

pjspillai commented Mar 27, 2019

@AlexeyAB
Hi, Thanks for sharing these! These are super helpful.

Quick question, did you try verifying your mAP script result matches the one mentioned in Yolo3 paper on the COCO test-dev set? Thanks!

@AlexeyAB
Copy link
Owner Author

@pjspillai Hi,

There are no public annotations for COCO test-dev, so there is nothing to use with detector map command. But there is only 2014 Testing Image info [1MB] that doesn't contain bboxes: http://cocodataset.org/#download

How to check Yolo v3 on COCO test-dev set on evaluation server is described here: #2145


You can check yolov3-spp.weights model on COCO 2014 val-set 5k, that you can get by using this script: https://github.com/AlexeyAB/darknet/blob/master/scripts/get_coco_dataset.sh
And get mAP@0.5 ~= 59.3%

@chenjoya
Copy link

@AlexeyAB Hi,
Thanks for your elegant solution!
Could you provide a more convenient method to calc AP@[.5, .95]? e.g.:

./darknet detector map cfg/coco.data cfg/yolov3-spp.cfg yolov3-spp.weights -points 101 -iou_thresh 0.5~0.95

Thanks!

@chenjoya
Copy link

chenjoya commented Mar 28, 2019

Here we provide YOLOv3-320 evaluation results on COCO val 2017 by this implemention and cocoapi respectively. It seems that there are some difference between them.

repo AP50 AP75 script
cocoapi 63.6 35.6 ./darknet detector valid cfg/coco.data cfg/yolov3.cfg yolov3.weights -out yolov3-320, then eval the yolov3-320.json with cocoapi
darknet-AlexeyAB 62.29 34.55 ./darknet detector map cfg/coco.data cfg/yolov3.cfg yolov3.weights -points 101 -iou_thresh 0.5 or 0.75

COCOAPI: (https://github.com/cocodataset/cocoapi)
2

This implemention (AP50 & AP75):
1
3

Thanks for your attention.

@AlexeyAB
Copy link
Owner Author

@chenjoya Hi,

  • What command line parameters did you use for cocoeval.py?

There are additional params (iscrowd) in the COCO dataset which can be taken into account by the Pycocotool script, but Yolo can't, because Yolo labels don't support them.

@p3jawors
Copy link

p3jawors commented Oct 1, 2019

@AlexeyAB can you please confirm the command for running mAP (or evaluation for that matter) on PASCAL-VOC 07? I see you have it listed as
./darknet detector map cfg/coco.data cfg/yolov3-spp.cfg yolov3-spp.weights -points 11
but the reference to coco.data seems wrong. I also get issues running this command as it looks for the file coco_testdev. I imagine the line should be
./darknet detector map cfg/voc.data cfg/yolov3-voc.cfg yolov3-voc.weights -points 11
However, I am having trouble finding the yolov3-voc.weights.

If I try to run it with the yolov3-spp.weights and yolov3-spp.cfg it also does not work (number of classes mismatch). I believe that those weights are also trained on MS-COCO since the cfg is set to 80 classes. The same happens with yolov3.weights and yolov3.cfg.

Can you please confirm the command to run on PASCAL-VOC07, and if you have a link to the pre-trained weights that would be immensely appreciated.

@AlexeyAB
Copy link
Owner Author

AlexeyAB commented Oct 1, 2019

There is no trained model of Yolo v3 for Pascal VOC.

There is model Yolo v2 for Pascal VOC: https://github.com/AlexeyAB/darknet#pre-trained-models
yolov2.cfg (194 MB COCO Yolo v2) - requires 4 GB GPU-RAM: https://pjreddie.com/media/files/yolov2.weights
yolo-voc.cfg (194 MB VOC Yolo v2) - requires 4 GB GPU-RAM: http://pjreddie.com/media/files/yolo-voc.weights

How to check the mAP on Pascal VOC: https://github.com/AlexeyAB/darknet#how-to-calculate-map-on-pascalvoc-2007

@p3jawors
Copy link

p3jawors commented Oct 1, 2019

Thank you for the quick reply,

Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Explanations Explanations of the source code, algorithms or method of use
Projects
None yet
Development

No branches or pull requests

4 participants