pascal voc使用coco標準評測AP50與pasal標準評測的AP50不一致(短)

本文是結論,詳細過程參考 https://blog.csdn.net/yinglang19941010/article/details/102790168

問題描述

使用Pascal的coco格式標註文件是Detectron代碼提供的,下載地址爲https://github.com/facebookresearch/Detectron/blob/master/detectron/datasets/data/README.md#coco-minival-annotations

使用coco評測標準測出的AP50和voc評測標準測出的AP50不一致,相差好幾個點(4~5).

問題解決

修改評測代碼maskrcnn_benchmark/data/datasets/evaluation/coco/cocoeval.py _prepare函數

# orgin code
# gt['ignore'] = 'iscrowd' in gt and gt['iscrowd']  
# changed code
gt['ignore'] = gt['ignore'] if 'ignore' in gt else 0
gt['ignore'] = ('iscrowd' in gt and gt['iscrowd']) or gt['ignore']  # changed by hui

問題簡單分析

Pascal的coco格式標註文件是Detectron代碼提供的,下載地址爲https://github.com/facebookresearch/Detectron/blob/master/detectron/datasets/data/README.md#coco-minival-annotations
加載查看annotations字段,發現他有一個ignore字段,估計應該是pascal裏的difficult字段之類的

In [2]: import json
In [3]: jd_gt = json.load(open('pascal_test2007.json'))                            
In [4]: jd_gt['annotations'][0]                                                    
Out[4]:
{'segmentation': [[47, 239, 47, 371, 195, 371, 195, 239]],
 'area': 19536,
 'iscrowd': 0,
 'image_id': 1,
 'bbox': [47, 239, 148, 132],
 'category_id': 12,
 'id': 1,
 'ignore': 0}

但是標準的coco評測代碼裏並沒有ignroe字段,因此,即使ignore不爲0,也不會被處理,但是Pascal VOC中正好有ignore不爲0的數據.

print(len(jd_gt['annotations']))
ann_gt1 = [a for a in jd_gt['annotations'] if a['iscrowd']==0]
print(len(ann_gt1))
ann_gt2 = [a for a in jd_gt['annotations'] if a['ignore']==0]
print(len(ann_gt2))

Out[]:
14976
14976
12032

因此會有這個問題,即使使用ground-truth作爲檢測結果AP也只有80%

發佈了23 篇原創文章 · 獲贊 18 · 訪問量 8萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章