def load_gt_and_det_data(gt_loc, det_json, data_type): """ Function for loading ground-truth and detection instances for a single folder/sequence :param gt_loc: location of folder/file where ground-truth information can be extracted :param det_json: detection json file for the given folder/sequence :param data_type: string defining if we are analysing 'coco' or 'rvc1' data as this will effect what, and how, data is loaded given the specific filtering process of rvc1. :return: gt_instances, det_instances, and class list """ if data_type == 'coco': # output is a generator of lists of GroundTruthInstance objects and a map of gt_class_ids gt_instances, gt_class_ids_map = read_files.read_COCO_gt(gt_loc, ret_classes=True) # output is a generator of lists of DetectionInstance objects (BBox or PBox depending) det_instances = read_files.read_pbox_json(det_json, gt_class_ids_map, override_cov=args.set_cov) class_idxs = [gt_class_ids_map[key] for key in sorted(gt_class_ids_map.keys())] class_names = list(sorted(gt_class_ids_map.keys())) class_list = [class_names[idx] for idx in np.argsort(class_idxs)] elif data_type == 'rvc1': gt_instances = rvc1_gt_loader.SequenceGTLoader(gt_loc) det_instances = rvc1_submission_loader.DetSequenceLoader(det_json) class_list = rvc1_class_list.CLASSES else: sys.exit("ERROR! Invalid data type provided") # check gt_instances and det_instances are the same size if len(gt_instances) != len(det_instances): sys.exit("ERROR! gt and det not same length. gt: {0}, det: {1}".format(len(gt_instances), len(det_instances))) return gt_instances, det_instances, class_list
def gen_param_sequence(): """ Function for generating the parameter sequence to be used in evaluation procedure. Parameter sequence holds all GroundTruthInstances, DetectionInstances, and ground-truth filter flags across all sequences. :return: param_sequences: ParamSequenceHolder containing all GroundTruthInstances, DetectionInstances, and ground-truth filter flags across all sequences being evaluated. len_sequences: list of sequence lengths for all sequences being evaluated. """ # Load GTs and Detections as appropriate for different data sets (multiple sequences or one folder) if args.test_set == 'coco': # output is a generator of lists of GTInstance objects and a map of gt_class_ids gt_instances, gt_class_ids = read_files.read_COCO_gt( coco_gt_file, ret_classes=True, bbox_gt=args.bbox_gt) det_filename = args.det_loc # output is a generator of lists of DetectionInstance objects (BBox or PBox depending on detection) det_instances = read_files.read_pbox_json(det_filename, gt_class_ids, override_cov=args.set_cov, prob_seg=args.prob_seg) all_gt_instances = [gt_instances] all_det_instances = [det_instances] elif args.test_set == 'rvc1': # output is a list of generator of generators of GTInstance objects all_gt_instances = rvc1_gt_loader.read_ground_truth( rvc1_gt_folder, bbox_gt=args.bbox_gt) # Currently set this version to assume there is a .json file for all sequences in ground-truth all_det_instances = rvc1_submission_loader.read_submission( args.det_loc, ["{0:06d}".format(idx) for idx in range(len(all_gt_instances))], override_cov=args.set_cov) else: sys.exit( "ERROR! Invalid test_set parameter (must be 'coco' or 'rvc1')") param_sequence = ParamSequenceHolder(all_gt_instances, all_det_instances) len_sequences = [ len(all_gt_instances[idx]) for idx in range(len(all_gt_instances)) ] return param_sequence, len_sequences
def gen_param_sequence(): """ Function for generating the parameter sequence to be used in evaluation procedure. Parameter sequence holds all GroundTruthInstances, DetectionInstances, and ground-truth filter flags across all sequences. :return: param_sequences: ParamSequenceHolder containing all GroundTruthInstances, DetectionInstances, and ground-truth filter flags across all sequences being evaluated. len_sequences: list of sequence lengths for all sequences being evaluated. """ # Load GTs and Detections as appropriate for different data sets (multiple sequences or one folder) #if args.test_set == 'coco': # output is a generator of lists of GTInstance objects and a map of gt_class_ids coco_gt_file = 'gt.json' det_loc = 'pred.json' gt_instances, gt_class_ids = read_files.read_COCO_gt(coco_gt_file, ret_classes=True, bbox_gt=True) det_filename = det_loc # output is a generator of lists of DetectionInstance objects (BBox or PBox depending on detection) det_instances = read_files.read_pbox_json(det_filename, gt_class_ids, prob_seg=False) all_gt_instances = [gt_instances] all_det_instances = [det_instances] #print("all_gt = ", all_gt_instances[0], all_det_instances) param_sequence = ParamSequenceHolder(all_gt_instances, all_det_instances) len_sequences = [ len(all_gt_instances[idx]) for idx in range(len(all_gt_instances)) ] return param_sequence, len_sequences