Mean Average Precision evaluator for object detection.
Project description
mAP: Mean Average Precision for Object Detection
A simple library for the evaluation of object detectors.
In practice, a higher mAP value indicates a better performance of your detector, given your ground-truth and set of classes.
Install package
pip install mean_average_precision
Install the latest version
pip install --upgrade git+https://github.com/bes-dev/mean_average_precision.git
Example
import numpy as np
from mean_average_precision import MetricBuilder
# [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]
])
# print list of available metrics
print(MetricBuilder.get_metrics_list())
# create metric_fn
metric_fn = MetricBuilder.build_evaluation_metric("map_2d", async_mode=True, num_classes=1)
# add some samples to evaluation
for i in range(10):
metric_fn.add(preds, gt)
# compute PASCAL VOC metric
print(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 points
print(f"VOC PASCAL mAP in all points: {metric_fn.value(iou_thresholds=0.5)['mAP']}")
# compute metric COCO metric
print(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']}")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for mean_average_precision-2021.4.26.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20596a0a411fcdd2bdb159636f21f3501de76395fcb8ac3db0b90982b4bdfd7d |
|
MD5 | e9340c64fc11c38979a49da1441257d6 |
|
BLAKE2b-256 | d0c8e0fa7f81b32e5e698d13ff19f2899a854728a60d8eae40b73b6d0dde7568 |
Close
Hashes for mean_average_precision-2021.4.26.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a4d08e27f016c8e6ffb8bea0687f59eca63c0060543f90c2e1373a48e5500c5 |
|
MD5 | d51951bd851733ddb0fa774d1209a870 |
|
BLAKE2b-256 | 321a512cf3479e6c3e2ec95c2931c293a0ee60a709196172d9cc8a88134e4211 |