def func_co(x): x.sort() Eval = NuScenesEval('', '', args.format) fused_data = cu.matching_and_fusion(cam_test_list[x[0]],cam_test_list[x[1]]) fused_gt = cu.filt_gt_labels_tuple(cam_gt_list[x[0]],cam_gt_list[x[1]]) mAP_temp = Eval.my_evaluate(fused_data,fused_gt) return 1- mAP_temp
def fov_match_and_fusion2(pred1, pred2, gt_label, point1, point2, trust_first=True, fusion_fuction=None, args=None): from detection_evaluation.nuscenes_eval_core import NuScenesEval ret = [] pr1 = [] pr2 = [] gt = [] fov, _ = FOV(point1).caculate_iou(FOV(point2)) for ind, (frame_det1, frame_det2, frame_gt) in enumerate(zip(pred1, pred2, gt_label)): trust_frame = frame_det1 if trust_first else frame_det2 fov_det1 = np.empty((0, 8)) fov_det2 = np.empty((0, 8)) fov_gt = np.empty((0, 8)) for ind_un, car_point in enumerate(frame_det1.astype(np.float)): #print(car_point) if _polygon_contains_point(fov, (car_point[0], car_point[1])): fov_det1 = np.vstack((fov_det1, car_point)) for ind_un, car_point in enumerate(frame_det2.astype(np.float)): if _polygon_contains_point(fov, (car_point[0], car_point[1])): fov_det2 = np.vstack((fov_det2, car_point)) for ind_un, car_point in enumerate(frame_gt.astype(np.float)): if _polygon_contains_point(fov, (car_point[0], car_point[1])): fov_gt = np.vstack((fov_gt, car_point)) matched, unmatched1, unmatched2 = match_pairs( fov_det1.astype(np.float), fov_det2.astype(np.float)) #unmatched = np.vstack((unmatched1,unmatched2)) ret.append(np.vstack((matched, unmatched1, unmatched2))) pr1.append(fov_det1) pr2.append(fov_det2) gt.append(fov_gt) #delete_index = [] #print(ind,':',len(unmatched)) # for ind_un,car_point in enumerate(unmatched): # if _polygon_contains_point(fov,(car_point[0],car_point[1])): # if car_point.tolist() in trust_frame.tolist(): # continue # else: # delete_index.append(ind_un) #tmp = np.delete(unmatched,obj=delete_index,axis=0) #ret.append(np.vstack((matched,tmp))) #ret.append(unmatched) #print(len(tmp)) Eval = NuScenesEval('', '', args.format) mAP_temp = Eval.my_evaluate(ret, gt) Eval = NuScenesEval('', '', args.format) mAP_1 = Eval.my_evaluate(pr1, gt) Eval = NuScenesEval('', '', args.format) mAP_2 = Eval.my_evaluate(pr2, gt) return mAP_temp, mAP_1, mAP_2
def fuse_constellation(x): #根据x的维度进行融合 x.sort() size_n = x.shape[0] main_cam = x[0] gt_list = [] gt_list.append(cam_gt_list[main_cam]) for i in x[1:]: fused_data = cu.matching_and_fusion(cam_test_list[main_cam],cam_test_list[i]) #融合 gt_list.append(cam_gt_list[i]) fused_gt = cu.filt_gt_labels_tuple(*gt_list) Eval = NuScenesEval('', '', args.format) mAP_temp = Eval.my_evaluate(fused_data,fused_gt) return 1- mAP_temp
def fuse_constellation(x): #根据x的维度进行融合 x.sort() size_n = x.shape[0] #fused_data = cam_test_list[x[0]] #gt_list = [] #gt_list.append(cam_gt_list[main_cam]) new_cam_test = [] for i in x: new_cam_test.append(cam_test_list[i]) fused_data = cu.matching_and_fusion_tuple(*new_cam_test, dbscan=dbscan) # for i in x[1:]: # fused_data = cu.matching_and_fusion(fused_data,cam_test_list[i]) #融合 #gt_list.append(cam_gt_list[i]) #fused_gt = cu.filt_gt_labels_tuple(*gt_list) Eval = NuScenesEval('', '', args.format) #print(fused_data == cam_test_list[x[0]]) mAP_temp = Eval.my_evaluate(fused_data, fused_gt) return 1 - mAP_temp
def main(): args = parse_args() NuScenesEval(args.pred_labels, args.gt_labels, args.format)
# fused_gt = cu.filt_gt_labels_tuple(cam_gt_list[i],cam_gt_list[j],cam_gt_list[k],cam_gt_list[z]) # #评估 # mAP_temp = Eval.my_evaluate(fused_data,fused_gt) # if mAP_temp > max_map: # max_map = mAP_temp # max_i,max_j = i,j # print('temp max mAP: {}.......... time: ## i: {} j: {} k:{} z:{}'.format(max_map,i,j,k,z)) #print(mAP_temp) max_map = 0 max_i, max_j = 0, 0 fused_gt = cu.filt_gt_labels_tuple(*cam_gt_list) for i in range(34): for j in range(i + 1, 34): fused_data = cu.matching_and_fusion(cam_test_list[i], cam_test_list[j]) #融合 Eval = NuScenesEval('', '', args.format) #fused_gt = cu.filt_gt_labels_tuple(cam_gt_list[i],cam_gt_list[j],cam_gt_list[k]) #评估 mAP_temp = Eval.my_evaluate(fused_data, fused_gt) if mAP_temp > max_map: max_map = mAP_temp max_i, max_j = i, j print( 'temp max mAP: {}.......... time: ## i: {} j: {} '. format(max_map, i, j)) #print(mAP_temp) # max_map = 0 # max_i,max_j = 0,0 # fused_gt = cu.filt_gt_labels_tuple(*cam_gt_list) # for i in range(34): # for j in range(i+1,34):
# objs_in_cluster = X[num_test][np.in1d(y_pred, filter_n)] # filtered_obj = cu.mean_fusion(objs_in_cluster) # filtered_preds = np.vstack((filtered_preds, filtered_obj)) #print(X[0][:,0:2]) print(len(fused_gt[num_test])) #print(y_pred) #print("gt_num: ",len(fused_gt[1])) #print(len(X[0])) #print(X[0][:,0].shape) #print(X[0].shape) #print(data.shape) cluster_num = len(label_set) - (1 if -1 in y_pred else 0) print("cluster_num: ", cluster_num) Eval = NuScenesEval('', '', args.format) mAP_temp = Eval.my_evaluate([filtered_preds], [fused_gt[num_test]]) print('Evaluation: ', mAP_temp) Eval = NuScenesEval('', '', args.format) mAP_ori = Eval.my_evaluate([X[num_test]], [fused_gt[num_test]]) # fused_data = cu.matching_and_fusion(fused_data,cam_test_list[k]) # Eval = NuScenesEval('', '', args.format) # mAP_temp = Eval.my_evaluate(fused_data[1],fused_gt[1]) # print('Evaluation2: ',mAP_temp) plt.title('pred_num:{} cluster_num:{} mAP:{:.3f}'.format( len(data[:, 0]), cluster_num, mAP_temp)) #plt.title('pred_num:{} gt_num:{} mAP:{:.3f}'.format(len(fused_data_ori[num_test][:,0]),len(fused_gt[num_test]),mAP_fused)) plt.scatter(data[:, 0], data[:, 1], marker='o', c=y_pred) # plt.scatter(data[:,0], data[:,1], marker='o',c=data[:,1]) #plt.scatter(fused_data_ori[num_test][:,0], fused_data_ori[num_test][:,1], marker='o',c=fused_data_ori[num_test][:,1])