outputs = [] for b in range(int(len(model.outputs) / 2)): outputs.append( concatenate([model.outputs[2 * b], model.outputs[2 * b + 1]], name='blk%d' % (b + 1))) model = Model(model.input, outputs, name=model.name) logger.debug("DATASETS") """Load the MPII dataset.""" mpii = MpiiSinglePerson('datasets/MPII', dataconf=mpii_sp_dataconf) logger.debug(mpii.dataset_path) """Pre-load validation samples and generate the eval. callback.""" mpii_val = BatchLoader(mpii, x_dictkeys=['frame'], y_dictkeys=['pose', 'afmat', 'headsize'], mode=VALID_MODE, batch_size=mpii.get_length(VALID_MODE), num_predictions=1, shuffle=False) logger.debug(mpii_val.datasets) printcn(OKBLUE, 'Pre-loading MPII validation data...') [x_val], [p_val, afmat_val, head_val] = mpii_val[0] pose_pred = np.zeros_like(p_val) scores, y_pred = eval_singleperson_pckh(model, x_val, p_val[:, :, 0:2], afmat_val, head_val) logger.info("SCORES ") logger.debug(scores) pose_pred = get_pred_data(mpii, pose_pred=pose_pred, pred=y_pred, mode=mode)
# poselayout=pa17j3d, topology='frames')f penn_sf = PennAction(datasetpath('Penn_Action'), pennaction_dataconf, poselayout=pa17j3d, topology='frames', use_gt_bbox=True) ntu_sf = Ntu(datasetpath('NTU'), ntu_pe_dataconf, poselayout=pa17j3d, topology='frames', use_gt_bbox=True) """Create an object to load data from all datasets.""" data_tr = BatchLoader([mpii, penn_sf, ntu_sf], ['frame'], ['pose'], TRAIN_MODE, batch_size=[batch_size_mpii, batch_size_ar, batch_size_ar], num_predictions=num_predictions, shuffle=True) """MPII validation samples.""" mpii_val = BatchLoader(mpii, ['frame'], ['pose', 'afmat', 'headsize'], VALID_MODE, batch_size=mpii.get_length(VALID_MODE), shuffle=True) printcn(OKBLUE, 'Pre-loading MPII validation data...') [x_val], [p_val, afmat_val, head_val] = mpii_val[0] mpii_callback = MpiiEvalCallback(x_val, p_val, afmat_val, head_val, map_to_pa16j=pa17j3d.map_to_pa16j, logdir=logdir) # """Human3.6H validation samples.""" # h36m_val = BatchLoader(h36m, ['frame'], # ['pose_w', 'pose_uvd', 'afmat', 'camera', 'action'], VALID_MODE, # batch_size=h36m.get_length(VALID_MODE), shuffle=True) # printcn(OKBLUE, 'Preloading Human3.6M validation samples...') # [x_val], [pw_val, puvd_val, afmat_val, scam_val, action] = h36m_val[0] # # h36m_callback = H36MEvalCallback(x_val, pw_val, afmat_val, # puvd_val[:,0,2], scam_val, action, logdir=logdir)
poselayout=pa17j3d, topology='frames', use_gt_bbox=True) """Create an object to load data from all datasets.""" data_tr = BatchLoader([mpii, h36m, penn_sf, ntu_sf], ['frame'], ['pose'], TRAIN_MODE, batch_size=[ batch_size_mpii, batch_size_mpii, batch_size_ar, batch_size_ar ], num_predictions=num_predictions, shuffle=True) """MPII validation samples.""" mpii_val = BatchLoader(mpii, ['frame'], ['pose', 'afmat', 'headsize'], VALID_MODE, batch_size=mpii.get_length(VALID_MODE), shuffle=True) printcn(OKBLUE, 'Pre-loading MPII validation data...') [x_val], [p_val, afmat_val, head_val] = mpii_val[0] mpii_callback = MpiiEvalCallback(x_val, p_val, afmat_val, head_val, map_to_pa16j=pa17j3d.map_to_pa16j, logdir=logdir) """Human3.6H validation samples.""" h36m_val = BatchLoader(h36m, ['frame'], ['pose_w', 'pose_uvd', 'afmat', 'camera', 'action'], VALID_MODE, batch_size=h36m.get_length(VALID_MODE), shuffle=True)
num_joints = 16 model = reception.build(input_shape, num_joints, dim=2, num_blocks=num_blocks, num_context_per_joint=2, ksize=(5, 5), concat_pose_confidence=False) """Load pre-trained model.""" # weights_path = get_file(weights_file, TF_WEIGHTS_PATH, md5_hash=md5_hash, cache_subdir='models') model.load_weights(weights_path) """Merge pose and visibility as a single output.""" outputs = [] for b in range(int(len(model.outputs) / 2)): outputs.append(concatenate([model.outputs[2*b], model.outputs[2*b + 1]], name='blk%d' % (b + 1))) model = Model(model.input, outputs, name=model.name) """Load the MPII dataset.""" mpii = MpiiSinglePerson(f"{dataset_path}datasets/MPII", dataconf=mpii_sp_dataconf) """Pre-load validation samples and generate the eval. callback.""" mpii_val = BatchLoader(mpii, x_dictkeys=['frame'], y_dictkeys=['pose', 'afmat', 'headsize'], mode=VALID_MODE, batch_size=mpii.get_length(VALID_MODE), num_predictions=1, shuffle=False) printcn(OKBLUE, 'Pre-loading MPII validation data...') [x_val], [p_val, afmat_val, head_val] = mpii_val[0] eval_singleperson_pckh(model, x_val, p_val[:,:,0:2], afmat_val, head_val)
num_joints = 16 model = reception.build(input_shape, num_joints, dim=2, num_blocks=num_blocks, num_context_per_joint=2, ksize=(5, 5)) """Load the MPII dataset.""" mpii = MpiiSinglePerson('datasets/MPII', dataconf=mpii_sp_dataconf) data_tr = BatchLoader(mpii, ['frame'], ['pose'], TRAIN_MODE, batch_size=batch_size, num_predictions=num_blocks, shuffle=True) """Pre-load validation samples and generate the eval. callback.""" mpii_val = BatchLoader(mpii, x_dictkeys=['frame'], y_dictkeys=['pose', 'afmat', 'headsize'], mode=VALID_MODE, batch_size=mpii.get_length(VALID_MODE), num_predictions=1, shuffle=False) printcn(OKBLUE, 'Pre-loading MPII validation data...') [x_val], [p_val, afmat_val, head_val] = mpii_val[0] eval_callback = MpiiEvalCallback(x_val, p_val, afmat_val, head_val, eval_model=model, batch_size=2, pred_per_block=1, logdir=logdir) loss = pose_regression_loss('l1l2bincross', 0.01) model.compile(loss=loss, optimizer=RMSprop()) model.summary() def lr_scheduler(epoch, lr): if epoch in [80, 100]: newlr = 0.2*lr printcn(WARNING, 'lr_scheduler: lr %g -> %g @ %d' % (lr, newlr, epoch))
"""Load pre-trained weights from pose estimation and copy replica layers.""" # full_model.load_weights( # "C:\\networks\\deephar\\output\\ntu_baseline\\0429\\base_ntu_model_weights.hdf5", # by_name=True) # full_model.load_weights( # 'output/ntu_spnet_trial-03_fa9d2e2/weights_3dp+ntu_ar_050.hdf5', # by_name=True) # 'output/ntu_spnet_trial-03-ft2_0ae2bf7/weights_3dp+ntu_ar_058.hdf5') # full_model.load_weights( # 'output/ntu_spnet_trial_06_nopose_f_512a239/weights_3dp+ntu_ar_020.hdf5', # by_name=True) """Trick to pre-load validation samples and generate the eval. callback.""" mpii_val = BatchLoader(mpii, ['frame'], ['pose', 'afmat', 'headsize'], VALID_MODE, batch_size=mpii.get_length(VALID_MODE), shuffle=False) printnl('Pre-loading MPII validation data...') [mpii_x_val], [mpii_p_val, mpii_afmat_val, mpii_head_val] = mpii_val[0] """Human3.6H validation samples.""" # h36m_val = BatchLoader(h36m, ['frame'], # ['pose_w', 'pose_uvd', 'afmat', 'camera', 'action'], VALID_MODE, # batch_size=h36m.get_length(VALID_MODE), shuffle=False) # printcn(OKBLUE, 'Preloading Human3.6M validation samples...') # [h36m_x_val], [h36m_pw_val, h36m_puvd_val, h36m_afmat_val, h36m_scam_val, \ # h36m_action] = h36m_val[0] """NTU subset of testing samples""" ntu_te = BatchLoader(ntu_s1, ['frame'], ['ntuaction'], TEST_MODE, batch_size=1, shuffle=False)