def main(): # load heatmaps .etc rpsm_db = generate_data_for_rpsm() # load pairwise constraints pairwise_file = os.path.join(config.DATASET.ROOT, 'testdata', 'pairwise_b16.pkl') with open(pairwise_file, 'rb') as f: pairwise = pickle.load(f) pairwise = pairwise['pairwise_constrain'] all_cameras, all_hms, all_boxes, all_grid_centers, all_limb_lengths, all_gts = load_rpsm_testdata_all( rpsm_db) res = [] for idx, (cameras, hms, boxes, grid_center, limb_length, gt) in enumerate( zip(all_cameras, all_hms, all_boxes, all_grid_centers, all_limb_lengths, all_gts)): pose = rpsm(cameras, hms, boxes, grid_center, limb_length, pairwise, config) # print('GroundTruth Pose: ', gt) # print('Recovered Pose by RPSM: ', pose) mpjpe = np.mean(np.sqrt(np.sum((pose - gt)**2, axis=1))) # print('MPJPE: ', mpjpe) res.append(mpjpe) if idx % 500 == 0: print('%d:%.2f' % (idx, mpjpe)) print('MPJPE: ', np.mean(res))
def main(): args = parse_args() logger, final_output_dir, tb_log_dir = create_logger( config, args.cfg, 'test3d') prediction_path = os.path.join(final_output_dir, config.TEST.HEATMAP_LOCATION_FILE) test_dataset = eval('dataset.' + config.DATASET.TEST_DATASET)( config, config.DATASET.TEST_SUBSET, False) all_heatmaps = h5py.File(prediction_path)['heatmaps'] pairwise_file = config.PICT_STRUCT.PAIRWISE_FILE with open(pairwise_file, 'rb') as f: pairwise = pickle.load(f)['pairwise_constrain'] cnt = 0 grouping = test_dataset.grouping mpjpes = [] for items in grouping: heatmaps = [] boxes = [] poses = [] cameras = [] for idx in items: datum = test_dataset.db[idx] camera = datum['camera'] cameras.append(camera) poses.append( camera_to_world_frame(datum['joints_3d'], camera['R'], camera['T'])) box = {} box['scale'] = np.array(datum['scale']) box['center'] = np.array(datum['center']) boxes.append(box) heatmaps.append(all_heatmaps[cnt]) cnt += 1 heatmaps = np.array(heatmaps) # This demo uses GT root locations and limb length; but can be replaced by statistics grid_center = poses[0][0] body = HumanBody() limb_length = compute_limb_length(body, poses[0]) prediction = rpsm(cameras, heatmaps, boxes, grid_center, limb_length, pairwise, config) mpjpe = np.mean(np.sqrt(np.sum((prediction - poses[0])**2, axis=1))) mpjpes.append(mpjpe) print(np.mean(mpjpes))
def main(): parse_args() test_data_file = 'data/testdata/rpsm_testdata_b16.pkl' pairwise_file = 'data/testdata/pairwise_b16.pkl' with open(pairwise_file, 'rb') as f: pairwise = pickle.load(f) pairwise = pairwise['pairwise_constrain'] all_cameras, all_hms, all_boxes, all_grid_centers, all_limb_lengths, all_gts = load_rpsm_testdata_all( test_data_file) res = [] for idx, (cameras, hms, boxes, grid_center, limb_length, gt) in enumerate(zip(all_cameras, all_hms, all_boxes, all_grid_centers,all_limb_lengths, all_gts)): pose = rpsm(cameras, hms, boxes, grid_center, limb_length, pairwise, config) # print('GroundTruth Pose: ', gt) # print('Recovered Pose by RPSM: ', pose) mpjpe = np.mean(np.sqrt(np.sum((pose - gt)**2, axis=1))) # print('MPJPE: ', mpjpe) res.append(mpjpe) if idx % 500 == 0: print('%d:%.2f' % (idx, mpjpe)) print('MPJPE: ', np.mean(res))