def ytvos_eval(result_file, result_types, ytvos, max_dets=(100, 300, 1000), frame_id=None, show=False): if mmcv.is_str(ytvos): ytvos = YTVOS(ytvos) assert isinstance(ytvos, YTVOS) if frame_id is not None: anns = ytvos.anns for key, item in anns.items(): anns[key]['segmentations'] = [anns[key]['segmentations'][frame_id]] ytvos.anns = anns if len(ytvos.anns) == 0: print("Annotations does not exist") return assert result_file.endswith('.json') ytvos_dets = ytvos.loadRes(result_file) vid_ids = ytvos.getVidIds() for res_type in result_types: iou_type = res_type ytvosEval = YTVOSeval(ytvos, ytvos_dets, iou_type) ytvosEval.params.vidIds = vid_ids if res_type == 'proposal': ytvosEval.params.useCats = 0 ytvosEval.params.maxDets = list(max_dets) ytvosEval.evaluate() ytvosEval.accumulate() # ytvosEval.summarize() stats = ytvosEval.summarize(show=show) return stats
def ytvos_eval(result_file, result_types, ytvos, max_dets=(100, 300, 1000)): if mmcv.is_str(ytvos): ytvos = YTVOS(ytvos) assert isinstance(ytvos, YTVOS) # if len(ytvos.anns) == 0: # print("Annotations does not exist") # return assert result_file.endswith('.json') ytvos_dets = ytvos.loadRes(result_file) vid_ids = ytvos.getVidIds() for res_type in result_types: iou_type = res_type ytvosEval = YTVOSeval(ytvos, ytvos_dets, iou_type) ytvosEval.params.vidIds = vid_ids if res_type == 'proposal': ytvosEval.params.useCats = 0 ytvosEval.params.maxDets = list(max_dets) ytvosEval.evaluate() ytvosEval.accumulate() ytvosEval.summarize()