-
Notifications
You must be signed in to change notification settings - Fork 5
Home
Михаил edited this page Feb 13, 2024
·
4 revisions
I often use this project, but I saw it abandoned and without a public repository on github. Also, part of the project remained unfinished for a long time. I implemented some of the author's ideas and decided to make the results publicly available.
This package wraps a facebook C++ implementation of COCO-eval operations found in the pycocotools package. This implementation greatly speeds up the evaluation time for coco's AP metrics, especially when dealing with a high number of instances in an image.
from faster_coco_eval import COCO, COCOeval_faster
....
iouType = "segm"
useCats = False
cocoGt = COCO(prepared_coco_in_dict_or_path_to_coco_file)
cocoDt = cocoGt.loadRes(prepared_anns_or_path_to_anns_file)
cocoEval = COCOeval_faster(cocoGt, cocoDt, iouType, extra_calc=True)
cocoEval.params.maxDets = [len(cocoGt.anns)]
if not useCats:
cocoEval.params.useCats = 0
cocoEval.evaluate()
cocoEval.accumulate()
cocoEval.summarize()
print(cocoEval.stats_as_dict)
Further use is identical to the official library.
from faster_coco_eval import COCO
from faster_coco_eval.extra import Curves
cocoGt = COCO(....)
cocoDt = cocoGt.loadRes(....)
cur = Curves(cocoGt, cocoDt, iou_tresh=0.5, iouType='segm')
cur.plot_pre_rec()
image_preview_count = 2
cocoGt = COCO(....)
preview = PreviewResults(cocoGt, iouType="segm")
preview.display_tp_fp_fn(
data_folder=.....,
image_ids=list(cocoGt.imgs.keys())[:image_preview_count],
display_gt=True,
)