For explanation about mAP, please read https://github.com/Cartucho/mAP
npm install mean-average-precision
Every prediction/ground truth objects should look like
{
label: "car",
filename: "image1.jpg",
left: 22,
top: 34,
confidence: 0.9, // only for predictions
right: 231,
bottom: 78,
}
const mAP = require('mean-average-precision')
const groundTruths = [{
filename: "image1.jpg",
label: "car",
left: 22,
top: 34,
right: 231,
bottom: 78,
},{
filename: "image1.jpg",
label: "pedestrian",
left: 22,
top: 34,
right: 231,
bottom: 78,
}];
const predictions = [{
filename: 'image1.jpg',
confidence: 0.9,
label: 'car',
left: 25,
top: 38,
right: 201,
bottom: 90
}, {
filename: 'image1.jpg',
label: 'pedestrian',
confidence: 0.7,
left: 32,
top: 39,
right: 452,
bottom: 92
}, {
filename: 'image1.jpg',
confidence: 0.5,
label: 'car',
left: 541,
top: 42,
right: 621,
bottom: 94
}];
mAP({
groundTruths,
predictions
});
// IoU Threshold default value is 0.5
// you can change it using iouThreshold
mAP({
groundTruths,
predictions,
iouThreshold: 0.6
});
// You can have more information
// on which predictions are considered as
// misclassified by doing
mAP.listMisclassified({
groundTruths,
predictions,
iouThreshold: 0.6
});
// You can use the IoU function directly using
mAP.iou({
left: 22,
top: 34,
bottom: 38,
right: 30
},{
left: 21,
top: 32,
bottom: 40,
right: 32
});