def _evaluate_predictions_on_coco(coco_gt, coco_results, iou_type, kpt_oks_sigmas=None, is_rela=False): """ Evaluate the coco results using COCOEval API. """ assert len(coco_results) > 0 if iou_type == "segm": coco_results = copy.deepcopy(coco_results) # When evaluating mask AP, if the results contain bbox, cocoapi will # use the box area as the area of the instance, instead of the mask area. # This leads to a different definition of small/medium/large. # We remove the bbox field to let mask AP use mask area. for c in coco_results: c.pop("bbox", None) if is_rela: coco_dt = coco_gt.loadRes_rela(coco_results) else: coco_dt = coco_gt.loadRes(coco_results) coco_eval = COCOeval(coco_gt, coco_dt, iou_type) # Use the COCO default keypoint OKS sigmas unless overrides are specified if kpt_oks_sigmas: coco_eval.params.kpt_oks_sigmas = np.array(kpt_oks_sigmas) if is_rela: coco_eval.evaluate_rela() else: coco_eval.evaluate() coco_eval.accumulate() coco_eval.summarize() return coco_eval