更改COCO数据集评估标准输出结果,可以自行输入IoU阈值判断最终AP

引言

在进行目标检测时,常常需要评估模型的推理效果,事实上,一个好的检测box应该具有较高的定位得分和分类分数,这时衡量不同置信度阈值和不同IoU阈值下的模型检测性能尤为重要。以下放出更改COCO-eval代码使其输出不同IoU(0.5,0.6,0.7,0.8)指标下的结果.

代码

更改pycocotools/cocoeval.py代码,大概458行左右,讲原始函数替换为,可以自行调整并更改

        def _summarizeDets():
            stats = np.zeros((31,))
            stats[0] = _summarize(1)
            stats[1] = _summarize(1, iouThr=.5, maxDets=self.params.maxDets[2])
            stats[2] = _summarize(1, iouThr=.75, maxDets=self.params.maxDets[2])
            stats[3] = _summarize(1, areaRng='small', maxDets=self.params.maxDets[2])
            stats[4] = _summarize(1, areaRng='medium', maxDets=self.params.maxDets[2])
            stats[5] = _summarize(1, areaRng='large', maxDets=self.params.maxDets[2])
            stats[6] = _summarize(0, maxDets=self.params.maxDets[0])
            stats[7] = _summarize(0, maxDets=self.params.maxDets[1])
            stats[8] = _summarize(0, maxDets=self.params.maxDets[2])
            stats[9] = _summarize(0, areaRng='small', maxDets=self.params.maxDets[2])
            stats[10] = _summarize(0, areaRng='medium', maxDets=self.params.maxDets[2])
            stats[11] = _summarize(0, areaRng='large', maxDets=self.params.maxDets[2])

            stats[12] = _summarize(1, iouThr=0.6, maxDets=self.params.maxDets[2])
            stats[13] = _summarize(1,  iouThr=0.7,maxDets=self.params.maxDets[2])
            stats[14] = _summarize(1,  iouThr=0.8,maxDets=self.params.maxDets[2])
            stats[15] = _summarize(1,  iouThr=0.85,maxDets=self.params.maxDets[2])

            stats[16] = _summarize(1,  areaRng='small', iouThr=0.5,maxDets=self.params.maxDets[2])
            stats[17] = _summarize(1,  areaRng='small', iouThr=0.6,maxDets=self.params.maxDets[2])
            stats[18] = _summarize(1,  areaRng='small', iouThr=0.7,maxDets=self.params.maxDets[2])
            stats[19] = _summarize(1,  areaRng='small', iouThr=0.8,maxDets=self.params.maxDets[2])
            stats[20] = _summarize(1,  areaRng='small', iouThr=0.85,maxDets=self.params.maxDets[2])

            stats[21] = _summarize(1,  areaRng='medium', iouThr=0.5,maxDets=self.params.maxDets[2])
            stats[22] = _summarize(1, areaRng='medium', iouThr=0.6,maxDets=self.params.maxDets[2])
            stats[23] = _summarize(1,  areaRng='medium', iouThr=0.7,maxDets=self.params.maxDets[2])
            stats[24] = _summarize(1, areaRng='medium', iouThr=0.8,maxDets=self.params.maxDets[2])
            stats[25] = _summarize(1,  areaRng='medium', iouThr=0.85,maxDets=self.params.maxDets[2])

            stats[26] = _summarize(1,  areaRng='large', iouThr=0.5,maxDets=self.params.maxDets[2])
            stats[27] = _summarize(1, areaRng='large', iouThr=0.6,maxDets=self.params.maxDets[2])

            stats[28] = _summarize(1, areaRng='large', iouThr=0.7,maxDets=self.params.maxDets[2])
            stats[29] = _summarize(1, areaRng='large', iouThr=0.8,maxDets=self.params.maxDets[2])
            stats[30] = _summarize(1, areaRng='large', iouThr=0.85,maxDets=self.params.maxDets[2])

            return stats

效果

 Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0
 Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0
 Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = 0
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0
 Average Precision  (AP) @[ IoU=0.60      | area=   all | maxDets=100 ] = 0
 Average Precision  (AP) @[ IoU=0.70      | area=   all | maxDets=100 ] = 0
 Average Precision  (AP) @[ IoU=0.80      | area=   all | maxDets=100 ] = 0
 Average Precision  (AP) @[ IoU=0.89      | area=   all | maxDets=100 ] = 0
 Average Precision  (AP) @[ IoU=0.50      | area= small | maxDets=100 ] = 0
 Average Precision  (AP) @[ IoU=0.60      | area= small | maxDets=100 ] = 0
 Average Precision  (AP) @[ IoU=0.70      | area= small | maxDets=100 ] = 0
 Average Precision  (AP) @[ IoU=0.80      | area= small | maxDets=100 ] = 0
 Average Precision  (AP) @[ IoU=0.50      | area=medium | maxDets=100 ] = 0
 Average Precision  (AP) @[ IoU=0.60      | area=medium | maxDets=100 ] = 0
 Average Precision  (AP) @[ IoU=0.70      | area=medium | maxDets=100 ] = 0
 Average Precision  (AP) @[ IoU=0.80      | area=medium | maxDets=100 ] = 0
 Average Precision  (AP) @[ IoU=0.89      | area=medium | maxDets=100 ] = 0
 Average Precision  (AP) @[ IoU=0.50      | area= large | maxDets=100 ] = 0
 Average Precision  (AP) @[ IoU=0.60      | area= large | maxDets=100 ] = 0
 Average Precision  (AP) @[ IoU=0.70      | area= large | maxDets=100 ] = 0
 Average Precision  (AP) @[ IoU=0.80      | area= large | maxDets=100 ] = 0
 Average Precision  (AP) @[ IoU=0.89      | area= large | maxDets=100 ] = 0

你可能感兴趣的:(图像处理,检测,python,人工智能,深度学习)