Пример #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
logger.debug("NUM PREDICTIONS")
logger.debug(num_action_predictions)

"""Load datasets"""
# h36m = Human36M(datasetpath('Human3.6M'), dataconf=human36m_dataconf,
        # poselayout=pa17j3d, topology='frames')

ntu_data_path = os.getcwd() + '/datasets/NTU'
logger.debug(ntu_data_path)

ntu = Ntu(ntu_data_path, ntu_dataconf, poselayout=pa17j3d,
        topology='sequences', use_gt_bbox=True, clip_size=num_frames, num_S=5)
#logger.debug ('WARNING!! USING ONLY S1 FOR EVALUATION!')

"""Build the full model"""
full_model = spnet.build(cfg)

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)