def print_coco_metrics(self, json_file):
        """
        Args:
            json_file (str): path to the results json file in coco format
        Returns:
            dict: the evaluation metrics
        """
        from pycocotools.cocoeval import COCOeval
        ret = {}
        cocoDt = self.coco.loadRes(json_file)
        cocoEval = COCOeval(self.coco, cocoDt, 'bbox')
        cocoEval.evaluate()
        cocoEval.accumulate()
        cocoEval.summarize()
        fields = ['IoU=0.5:0.95', 'IoU=0.5', 'IoU=0.75', 'small', 'medium', 'large']
        for k in range(6):
            ret['mAP(bbox)/' + fields[k]] = cocoEval.stats[k]

        json_obj = json.load(open(json_file))
        if len(json_obj) > 0 and 'segmentation' in json_obj[0]:
            cocoEval = COCOeval(self.coco, cocoDt, 'segm')
            cocoEval.evaluate()
            cocoEval.accumulate()
            cocoEval.summarize()
            for k in range(6):
                ret['mAP(segm)/' + fields[k]] = cocoEval.stats[k]
        return ret
def print_coco_metrics ( self , json_file ) : from pycocotools . cocoeval import COCOeval ret = { } cocoDt = self . coco . loadRes ( json_file ) cocoEval = COCOeval ( self . coco , cocoDt , 'bbox' ) cocoEval . evaluate ( ) cocoEval . accumulate ( ) cocoEval . summarize ( ) fields = [ 'IoU=0.5:0.95' , 'IoU=0.5' , 'IoU=0.75' , 'small' , 'medium' , 'large' ] for k in range ( 6 ) : ret [ 'mAP(bbox)/' + fields [ k ] ] = cocoEval . stats [ k ] json_obj = json . load ( open ( json_file ) ) if len ( json_obj ) > 0 and 'segmentation' in json_obj [ 0 ] : cocoEval = COCOeval ( self . coco , cocoDt , 'segm' ) cocoEval . evaluate ( ) cocoEval . accumulate ( ) cocoEval . summarize ( ) for k in range ( 6 ) : ret [ 'mAP(segm)/' + fields [ k ] ] = cocoEval . stats [ k ] return ret
Args:
            json_file (str): path to the results json file in coco format
        Returns:
            dict: the evaluation metrics