コード例 #1
0
ファイル: co_utils.py プロジェクト: goodxue/CenterNet
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
コード例 #2
0
 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
コード例 #3
0
 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
コード例 #4
0
ファイル: sa_test_total.py プロジェクト: goodxue/CenterNet
 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
コード例 #5
0
ファイル: test.py プロジェクト: goodxue/CenterNet
 #                 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):
 #         fused_data = cu.matching_and_fusion(cam_test_list[i],cam_test_list[j]) #融合
 #         for k in range(j+1,34):
 #             Eval = NuScenesEval('', '', args.format)
コード例 #6
0
    filt_start_time = time.time()
    fused_gt = cu.filt_gt_labels_tuple(*cam_gt_list)
    #ret = cu.filt_gt_labels(cam_gt_list[0],cam_gt_list[1])
    #filt_time = time.time() - filt_start_time
    #print("filt gt for 1 iter, time: ",filt_time)
    filt_start_time = time.time()
    dbscan = DBSCAN(eps = 1.8,min_samples=1)
    #cam_test_index = [2,3,6,7,8,20,23,27,31]
    cam_test_index = [  0, 1,  2,  3,  4,  6,  7,  8,  9, 10, 12, 13, 14, 15, 16, 17, 19, 20, 21, 22, 23, 24, 25, 26,27,31,33]
    new_cam_test = []
    for i in cam_test_index:
        new_cam_test.append(cam_test_list[i])

    fused_test = cu.matching_and_fusion_tuple(*new_cam_test,dbscan=dbscan)
    Eval = NuScenesEval('', '', args.format)
    mAP_temp = Eval.my_evaluate(fused_test,fused_gt)
    print(mAP_temp)



    # X = cu.matching_and_fusion_tuple(*cam_test_list)
    # data = np.stack([X[1][:,0],X[1][:,1]]).transpose()
    # result = DBSCAN(eps = 1.6,min_samples=1).fit(data)
    # y_pred = result.labels_ #每个元素的标签,同一聚类下的元素标签相同
    # label_set = set(y_pred)

    # filtered_preds = np.empty((0, 8))
    # for lb in label_set:
    #     filter_n = np.asarray([lb])
    #     objs_in_cluster = X[1][np.in1d(y_pred, filter_n)]
    #     filtered_obj = cu.mean_fusion(objs_in_cluster)
コード例 #7
0
    #     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])
    plt.show()