You can use this package (disclaimer: I’m the author) to compute all COCO metrics for a given couple of ground truths and predicted bounding boxes. You can install it using pip
:
pip install globox
You first need to save the predictions in any supported format. For instance, if both the ground truths and the predictions are saved in YOLO format (txt files) you can print COCO metrics with:
from globox import AnnotationSet, COCOEvaluator
gts = AnnotationSet.from_yolo("yolo/gts/folder/")
preds = AnnotationSet.from_yolo("yolo/preds/folder/")
evaluator = COCOEvaluator(gts, preds)
evaluator.show_summary()
You can achieve the same thing from the command line:
globox evaluate yolo/gts/folder/ yolo/preds/folder --format yolo --format_dets yolo
If you don't or can't save the predictions to in one of the supported format, you can parse them using the BoundingBox.create(...)
function.
Take a look at the README of the repo for further information.
The confusion matrix can be computed with the help of this other package.