Ejemplo n.º 1
0
    kp_uv21_gt = np.squeeze(kp_uv21_gt)
    kp_vis = np.squeeze(kp_vis)

    # detect keypoints
    coord_hw_pred_crop = detect_keypoints(np.squeeze(keypoints_scoremap_v))
    coord_hw_pred = trafo_coords(coord_hw_pred_crop, center_v, scale_crop_v,
                                 256)
    coord_uv_pred = np.stack([coord_hw_pred[:, 1], coord_hw_pred[:, 0]], 1)

    # scale pred to image size of the dataset (to match with stored coordinates)
    coord_uv_pred[:, 1] /= scale[0]
    coord_uv_pred[:, 0] /= scale[1]

    # some datasets are already stored with downsampled resolution
    scale2orig_res = 1.0
    if hasattr(dataset, 'resolution'):
        scale2orig_res = dataset.resolution

    util.feed(kp_uv21_gt / scale2orig_res, kp_vis,
              coord_uv_pred / scale2orig_res)

    if (i % 100) == 0:
        print('%d / %d images Listo!: %.3f percent' %
              (i, dataset.num_samples, i * 100.0 / dataset.num_samples))

# Output results
mean, median, auc, _, _ = util.get_measures(0.0, 30.0, 20)
print('Resultados de evaluacion:')
print('Promedio de la media EPE: %.3f pixels' % mean)
print('Promedio de la mediana EPE: %.3f pixels' % median)
print('Area debajo de la curva: %.3f' % auc)
Ejemplo n.º 2
0
    keypoint_scale = np.squeeze(keypoint_scale)

    # rescale to meters
    coord3d_pred_v *= keypoint_scale

    # center gt
    keypoint_xyz21 -= keypoint_xyz21[0, :]

    util.feed(keypoint_xyz21, keypoint_vis21, coord3d_pred_v)

    if (i % 100) == 0:
        print('%d / %d images done: %.3f percent' %
              (i, dataset.num_samples, i * 100.0 / dataset.num_samples))

# Output results
mean, median, auc, pck_curve_all, threshs = util.get_measures(
    0.0, 0.050, 20)  # rainier: Should lead to 0.764 / 9.405 / 12.210
print('Evaluation results')
print('Average mean EPE: %.3f mm' % (mean * 1000))
print('Average median EPE: %.3f mm' % (median * 1000))
print('Area under curve between 0mm - 50mm: %.3f' % auc)

# only use subset that lies in 20mm .. 50mm
pck_curve_all, threshs = pck_curve_all[8:], threshs[8:] * 1000.0
auc_subset = calc_auc(threshs, pck_curve_all)
print('Area under curve between 20mm - 50mm: %.3f' % auc_subset)

# Show Figure 9 from the paper
if type(dataset) == BinaryDbReaderSTB:

    import matplotlib.pyplot as plt
    curve_list = get_stb_ref_curves()
Ejemplo n.º 3
0
        plot_hand(coord_hw_pred_crop, plt, color_fixed=np.array([0.0, 0.0, 1.0]))
        plot_hand(kp_uv21_gt[:, ::-1], plt, color_fixed=np.array([1.0, 0.0, 0.0]))
        plt.show()

    if args.save:
        result = {}
        result['img_dir'] = img_dir[0].decode()
        for i in (1, 5, 9, 13, 17):
            coord_uv_pred_crop[i:i+4] = coord_uv_pred_crop[i+3:i-1:-1] # reverse the order of fingers (from palm to tip)
        if int(hand_side[1]):
            coord_uv_pred_crop[:, 0] = net.crop_size - 1 - coord_uv_pred_crop[:, 0]
        coord_uv_pred_crop -= net.crop_size//2
        result['hand2d'] = (coord_uv_pred_crop/crop_scale + crop_center[::-1]).tolist()
        results.append(result)

mean, median, auc, pck_curve_all, threshs = util.get_measures(0.0, 1.0, 100)
print('Evaluation results:')
print('Average mean EPE: %.3f pixels' % mean)
print('Average median EPE: %.3f pixels' % median)
print('Area under curve: %.3f' % auc)

fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(threshs, pck_curve_all)
ax.set_xlabel('threshold')
ax.set_ylabel('PCK')
ax.set_xticks(np.arange(0, 1, 0.1))
ax.set_yticks(np.arange(0, 1, 0.1))
plt.grid()
plt.show()
Ejemplo n.º 4
0
        ax3.set_ylim([-0.1, 0.1])
        ax3.set_zlim([-0.1, 0.1])
        ax3.set_aspect('equal')
        ax3.set_xticklabels([])
        ax3.set_yticklabels([])
        ax3.set_zticklabels([])

        plt.tight_layout()
        plt.show()
        plt.pause(0.001)
        plt.savefig(model_path + "/eval_results/prediction_RgbTo3D_" + dataset_name + "%05d" % i)



# Output results
mean, median, auc, pck_curve_all, threshs = util_vae.get_measures(0.0, 0.050, 20)
print('Evaluation results:')
print('Average mean EPE: %.3f mm' % (mean*1000))
print('Average median EPE: %.3f mm' % (median*1000))
print('Area under curve: %.3f' % auc)
pck_curve_all, threshs = pck_curve_all[8:], threshs[8:]*1000.0
auc_subset = calc_auc(threshs, pck_curve_all)
print('Area under curve between 20mm - 50mm: %.3f' % auc_subset)

curve_list = []
curve_list.append((threshs, pck_curve_all, model_name + ' (AUC=%.3f)' % auc_subset))
if type(dataset) == BinaryDbReaderSTB:
    curve_list.extend(get_stb_ref_curves())


plt.ioff()
Ejemplo n.º 5
0
        image_crop_v = ((image_crop_v + 0.5) * 255).astype('uint8')
        coord_hw_pred_crop = detect_keypoints(np.squeeze(keypoints_scoremap_v))
        coord_uv_pred_crop = np.stack(
            [coord_hw_pred_crop[:, 1], coord_hw_pred_crop[:, 0]], 1)

        kp_vis2d = np.ones_like(keypoint_uv_gt[:, 0])
        kp_vis = np.ones_like(keypoint_xyz21_gt[:, 0])
        eval2d.feed(keypoint_uv_gt, kp_vis2d, coord_uv_pred_crop)
        eval3d.feed(keypoint_xyz21_gt, kp_vis, keypoint_coord3d_v)

        # for i, kp in enumerate(keypoint_uv_gt):
        # kp = tuple(kp.astype(np.uint8))
        # image_crop_v = cv2.circle(image_crop_v, kp, 2, [255,255,255], 2)
        # image_crop_v = cv2.putText(image_crop_v, str(i),
        # kp,cv2.FONT_HERSHEY_SIMPLEX, 0.5,
        # [0,255,0])

        # import pdb; pdb.set_trace()
        # cv2.imwrite("test.png", image_crop_v)
mean, median, auc, _, _ = eval3d.get_measures(0.0, 0.050, 20)
print('Evaluation results for 3d ')
print('Average mean EPE: %.3f mm' % (mean * 1000))
print('Average median EPE: %.3f mm' % (median * 1000))
print('Area under curve: %.3f' % auc)

mean, median, auc, _, _ = eval2d.get_measures(0.0, 30.0, 20)
print('Evaluation results 2d :')
print('Average mean EPE: %.3f pixels' % mean)
print('Average median EPE: %.3f pixels' % median)
print('Area under curve: %.3f' % auc)