用于目标检测的平均精度评估器。
mean-average-precision的Python项目详细描述
mAP:目标检测的平均精度
一个用于评估目标探测器的简单库。在
^{1}$ 在
在实践中,更高的mAP值表示检测器的性能更好,前提是您的基本事实和类集。在
安装程序包
pip install mean_average_precision
安装最新版本
^{pr2}$示例
importnumpyasnpfrommean_average_precisionimportMeanAveragePrecision# [xmin, ymin, xmax, ymax, class_id, difficult, crowd]gt=np.array([[439,157,556,241,0,0,0],[437,246,518,351,0,0,0],[515,306,595,375,0,0,0],[407,386,531,476,0,0,0],[544,419,621,476,0,0,0],[609,297,636,392,0,0,0]])# [xmin, ymin, xmax, ymax, class_id, confidence]preds=np.array([[429,219,528,247,0,0.460851],[433,260,506,336,0,0.269833],[518,314,603,369,0,0.462608],[592,310,634,388,0,0.298196],[403,384,517,461,0,0.382881],[405,429,519,470,0,0.369369],[433,272,499,341,0,0.272826],[413,390,515,459,0,0.619459]])# create metric_fnmetric_fn=MeanAveragePrecision(num_classes=1)# add some samples to evaluationforiinrange(10):metric_fn.add(preds,gt)# compute PASCAL VOC metricprint(f"VOC PASCAL mAP: {metric_fn.value(iou_thresholds=0.5,recall_thresholds=np.arange(0.,1.1,0.1))['mAP']}")# compute PASCAL VOC metric at the all pointsprint(f"VOC PASCAL mAP in all points: {metric_fn.value(iou_thresholds=0.5)['mAP']}")# compute metric COCO metricprint(f"COCO mAP: {metric_fn.value(iou_thresholds=np.arange(0.5,1.0,0.05),recall_thresholds=np.arange(0.,1.01,0.01),mpolicy='soft')['mAP']}")
- 项目
标签: