Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

COCO api evaluation for subset of classes

I'm using the python coco api to run evaluation for object detection. I have two files, a ground truth json, and a results json. The coco notebook demo only shows running eval for all classes. How can I run it for only one specific class or a subset of classes? Currently I'm doing this:

from pycocotools.coco import COCO
from pycocotools.cocoeval import COCOeval

annType = 'bbox'

cocoGt=COCO(gt_json)
cocoDt=cocoGt.loadRes(results_json)

imgIds=sorted(cocoGt.getImgIds())

# running evaluation
cocoEval = COCOeval(cocoGt,cocoDt,annType)
cocoEval.params.imgIds = imgIds
cocoEval.evaluate()
cocoEval.accumulate()
cocoEval.summarize()
like image 584
Austin Avatar asked May 21 '19 23:05

Austin


People also ask

How is Coco dataset area calculated?

area - This is a product of the width and height of the bounding box. It helps us determine the size of the bounding box.

What is Coco evaluator?

COCO Dataset consists of annotated images with face keypoints and object detection keypoints and also contains an evaluator to perform bounding box measurements. COCO Dataset can be used to train the dataset for an image segmentation problem into a deep learning model.

What is Coco API?

COCO API - http://cocodataset.org/ COCO is a large image dataset designed for object detection, segmentation, person keypoints detection, stuff segmentation, and caption generation. This package provides Matlab, Python, and Lua APIs that assists in loading, parsing, and visualizing the annotations in COCO.


1 Answers

I refer to this page (http://www.programmersought.com/article/3065285708/)

cocoEval = COCOeval(cocoGt,cocoDt,annType)
coco_eval.params.catIds = [1] #person id : 1
cocoEval.params.imgIds = imgIds   
cocoEval.evaluate()  
cocoEval.accumulate()  
cocoEval.summarize() 

Additionaly, I modified cocoapi/PythonAPI/pycocotools/cocoeval.py to calculate AP for each category.
https://github.com/kimyoon-young/centerNet-deep-sort/blob/b694fc52f880dfbba481d43a7d5284a29f386ca7/tools/cocoeval.py#L458-L464

The result is like below.

category : 0 : 0.410733757610904 #person AP
category : 1 : 0.20226150054237374 #bird AP
....
category : 79 : 0.04993736566987926
(all categories) mAP : 0.27999824034118914 # my results
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.280 #original

like image 113
김윤영 Avatar answered Sep 22 '22 07:09

김윤영