Пример #1
0
def buildModel(args):
	start = time.time()
	num_frames = args.seq_len
	cfg = ModelConfig((num_frames,) + pennaction_dataconf.input_shape, pa16j2d,
	                  num_actions=[15], num_pyramids=6, action_pyramids=[5, 6],
	                  num_levels=4, pose_replica=True,
	                  num_pose_features=160, num_visual_features=160)

	num_predictions = spnet.get_num_predictions(
	    cfg.num_pyramids, cfg.num_levels)
	num_action_predictions = \
	    spnet.get_num_predictions(len(cfg.action_pyramids), cfg.num_levels)

	full_model = spnet.build(cfg)

	weights_file = 'weights/weights_mpii+penn_ar_028.hdf5'

	full_model.load_weights(weights_file, by_name=True)

	models = split_model(full_model, cfg, interlaced=False,
	                     model_names=['2DPose', '2DAction'])
	end = time.time()
	print("Time Taken to build model : ", end - start)
	return models[0], models[1]
Пример #2
0
weights_file = os.getcwd() + '/weights/weights_3dp+ntu_ar_062.hdf5'
logger.debug(weights_file)
if os.path.isfile(weights_file) == False:
    logger.debug (f'Error: file {weights_file} not found!')
    logger.debug (f'\nPlease download it from  https://drive.google.com/file/d/1I6GftXEkL5nohLA60Vi6faW0rvTZg6Kx/view?usp=sharing')
    sys.stdout.flush()
    sys.exit()


"""Load pre-trained weights from pose estimation and copy replica layers."""
full_model.load_weights(weights_file,
        #'output/ntu_spnet_trial_06_nopose_g_512a239/weights_3dp+ntu_ar_030.hdf5',
        by_name=True)

"""Split model to simplify evaluation."""
models = split_model(full_model, cfg, interlaced=False,
        model_names=['3DPose', '3DAction'])

"""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, ['frame'], ['ntuaction'], TEST_MODE, batch_size=1,
#        shuffle=False)


"""Evaluate on Human3.6M using 3D poses."""