示例#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
from deephar.utils import *

sys.path.append(os.path.join(os.getcwd(), 'exp/common'))

from h36m_tools import eval_human36m_sc_error
from ntu_tools import eval_multiclip_dataset

logdir = './'
if len(sys.argv) > 1:
    logdir = sys.argv[1]
    mkdir(logdir)
    sys.stdout = open(str(logdir) + '/log.txt', 'w')

num_frames = 8
cfg = ModelConfig((num_frames,) + ntu_dataconf.input_shape, pa17j3d,
        num_actions=[60], num_pyramids=2, action_pyramids=[1, 2],
        num_levels=4, pose_replica=False,
        num_pose_features=192, num_visual_features=192)

logger.debug(cfg)
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)
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)
示例#3
0
from mpii_tools import MpiiEvalCallback
# from h36m_tools import H36MEvalCallback

def datasetpath(dataset):
    if dataset == "Penn_Action":
        dataset = "PennAction"

    return os.getcwd() + "/datasets/" + dataset

logdir = './'
if len(sys.argv) > 1:
    logdir = sys.argv[1]
    mkdir(logdir)
    sys.stdout = open(str(logdir) + '/log.txt', 'w')

cfg = ModelConfig(mpii_dataconf.input_shape, pa17j3d, num_pyramids=8,
        action_pyramids=[], num_levels=4)

num_predictions = spnet.get_num_predictions(cfg.num_pyramids, cfg.num_levels)

start_lr = 0.001
weights_path = os.path.join(logdir, 'weights_posebaseline_{epoch:03d}.hdf5')

batch_size_mpii = 14
batch_size_ar = 2

"""Load datasets"""
mpii = MpiiSinglePerson(datasetpath('MPII'), dataconf=mpii_dataconf,
        poselayout=pa17j3d)

# h36m = Human36M(datasetpath('Human3.6M'), dataconf=human36m_dataconf,
#         poselayout=pa17j3d, topology='frames')f
示例#4
0
sys.path.append(os.path.join(os.getcwd(), 'exp/common'))
from datasetpath import datasetpath

from keras.models import Model
import time

logdir = './'
if len(sys.argv) > 1:
    logdir = sys.argv[1]
    mkdir(logdir)
    sys.stdout = open(str(logdir) + '/log.txt', 'w')

num_frames = 8
num_clips = 250
cfg = ModelConfig((num_frames,) + pennaction_dataconf.input_shape, pa16j2d,
        num_actions=[15], num_pyramids=6, action_pyramids=[1, 2, 3, 4, 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)


"""Load PennAction"""
penn_seq = PennAction(datasetpath('Penn_Action'), pennaction_dataconf,
        poselayout=pa16j2d, topology='sequences', use_gt_bbox=False,
        pred_bboxes_file='pred_bboxes_penn.json', clip_size=num_frames)


"""Build the full model"""
full_model = spnet.build(cfg)
示例#5
0
from deephar.utils import *

from keras.models import Model

sys.path.append(os.path.join(os.getcwd(), 'exp/common'))
from datasetpath import datasetpath

from generic import get_bbox_from_poses

logdir = './'
if len(sys.argv) > 1:
    logdir = sys.argv[1]
    mkdir(logdir)
    sys.stdout = open(str(logdir) + '/log.txt', 'w')

cfg = ModelConfig(dconf.input_shape, pa16j2d, num_pyramids=8, num_levels=4)
"""Load dataset"""
dpath = datasetpath('Penn_Action')
penn = PennAction(dpath,
                  dconf,
                  poselayout=pa16j2d,
                  topology='frames',
                  use_gt_bbox=False)
"""Build and compile the network."""
model = spnet.build(cfg)
model.load_weights(
    'output/mpii_spnet_51b_741a720/weights_mpii_spnet_8b4l_050.hdf5')
"""Squeeze the model for only one output."""
model = Model(model.input, model.outputs[-1])