def main(): actions = ["walking", "eating", "smoking", "discussion"] # TODO make this a runtime option # Uncomment th eliens actions.extend([ "directions", "greeting", "phoning", "posing", "purchases", "sitting", "sittingdown", "takingphoto", "waiting", "walkingdog", "walkingtogether" ]) # Parameters for dummy model. We only build the model to load the data. one_hot = False FLAGS = Object() FLAGS.data_dir = "../data/h3.6m/dataset" FLAGS.architecture = "basic" FLAGS.seq_length_in = 50 FLAGS.seq_length_out = 100 FLAGS.num_layers = 1 FLAGS.size = 128 FLAGS.max_gradient_norm = 5 FLAGS.batch_size = 8 FLAGS.learning_rate = 0.005 FLAGS.learning_rate_decay_factor = 1 summaries_dir = "./log/" FLAGS.loss_to_use = "sampling_based" FLAGS.omit_one_hot = True, FLAGS.residual_velocities = False, dtype = tf.float32 # Baselines are very simple. No need to use the GPU. with tf.Session(config=tf.ConfigProto(device_count={"GPU": 0})) as sess: model = seq2seq_model.Seq2SeqModel( FLAGS.architecture, FLAGS.seq_length_in, FLAGS.seq_length_out, FLAGS.size, # hidden layer size FLAGS.num_layers, FLAGS.max_gradient_norm, FLAGS.batch_size, FLAGS.learning_rate, FLAGS.learning_rate_decay_factor, summaries_dir, FLAGS.loss_to_use, len(actions), not FLAGS.omit_one_hot, FLAGS.residual_velocities, dtype=dtype) # Load the data _, test_set, data_mean, data_std, dim_to_ignore, dim_to_use = translate.read_all_data( actions, FLAGS.seq_length_in, FLAGS.seq_length_out, FLAGS.data_dir, not FLAGS.omit_one_hot) # Get all the data, denormalize and convert it to euler angles poses_data = {} for action in actions: enc_in, dec_in, dec_out = model.get_batch_srnn(test_set, action) enc_in = denormalize_and_convert_to_euler(enc_in, data_mean, data_std, dim_to_ignore, actions, not FLAGS.omit_one_hot) dec_in = denormalize_and_convert_to_euler(dec_in, data_mean, data_std, dim_to_ignore, actions, not FLAGS.omit_one_hot) dec_out = denormalize_and_convert_to_euler(dec_out, data_mean, data_std, dim_to_ignore, actions, not FLAGS.omit_one_hot) poses_data[action] = (enc_in, dec_in, dec_out) # Compute baseline errors errs_constant_frame = running_average(poses_data, actions, 1) # running_average_2 = running_average( poses_data, actions, 2 ) # running_average_4 = running_average( poses_data, actions, 4 ) mean_error = {} for i in [1, 3, 7, 9, 24]: mean_error[i] = 0 print() print("=== Zero-velocity (running avg. 1) ===") print("{0: <16} | {1:4d} | {2:4d} | {3:4d} | {4:4d} | {5:4d}".format( "milliseconds", 80, 160, 320, 400, 1000)) for action in actions: print("{0: <16} | {1:.2f} | {2:.2f} | {3:.2f} | {4:.2f} | {5:.2f}". format(action, errs_constant_frame[action][1], errs_constant_frame[action][3], errs_constant_frame[action][7], errs_constant_frame[action][9], errs_constant_frame[action][24])) for i in [1, 3, 7, 9, 24]: mean_error[i] += errs_constant_frame[action][i] print("{0: <16} | {1:.2f} | {2:.2f} | {3:.2f} | {4:.2f} | {5:.2f}". format("average", mean_error[1] / 15, mean_error[3] / 15, mean_error[7] / 15, mean_error[9] / 15, mean_error[24] / 15))
def main(): actions = define_actions( tf.app.flags.FLAGS.action ) # Parameters for dummy model. We only build the model to load the data. one_hot = False FLAGS = Object() FLAGS.data_dir = "./data/h3.6m/dataset" FLAGS.architecture = "tied" FLAGS.seq_length_in = 50 FLAGS.seq_length_out = 100 FLAGS.num_layers = 1 FLAGS.size = 128 FLAGS.max_gradient_norm = 5 FLAGS.batch_size = 8 FLAGS.learning_rate = 0.005 FLAGS.learning_rate_decay_factor = 1 summaries_dir = "./log/" FLAGS.loss_to_use = "sampling_based" FLAGS.omit_one_hot = True, FLAGS.residual_velocities = False, dtype = tf.float32 # Baselines are very simple. No need to use the GPU. with tf.Session(config=tf.ConfigProto( device_count = {"GPU": 0})) as sess: model = seq2seq_model.Seq2SeqModel( FLAGS.architecture, FLAGS.seq_length_in, FLAGS.seq_length_out, FLAGS.size, # hidden layer size FLAGS.num_layers, FLAGS.max_gradient_norm, FLAGS.batch_size, FLAGS.learning_rate, FLAGS.learning_rate_decay_factor, summaries_dir, FLAGS.loss_to_use, len( actions ), not FLAGS.omit_one_hot, FLAGS.residual_velocities, dtype=dtype) # Load the data _, test_set, data_mean, data_std, dim_to_ignore, dim_to_use = translate.read_all_data( actions, FLAGS.seq_length_in, FLAGS.seq_length_out, FLAGS.data_dir, not FLAGS.omit_one_hot ) # Get all the data, denormalize and convert it to euler angles poses_data = {} for action in actions: enc_in, dec_in, dec_out = model.get_batch_srnn( test_set, action ) enc_in = denormalize_and_convert_to_euler( enc_in, data_mean, data_std, dim_to_ignore, actions, not FLAGS.omit_one_hot ) dec_in = denormalize_and_convert_to_euler( dec_in, data_mean, data_std, dim_to_ignore, actions, not FLAGS.omit_one_hot ) dec_out = denormalize_and_convert_to_euler( dec_out, data_mean, data_std, dim_to_ignore, actions, not FLAGS.omit_one_hot ) poses_data[action] = (enc_in, dec_in, dec_out) # Compute baseline errors errs_constant_frame = running_average( poses_data, actions, 1 ) running_average_2 = running_average( poses_data, actions, 2 ) running_average_4 = running_average( poses_data, actions, 4 ) print() print("=== Zero-velocity (running avg. 1) ===") print("{0: <16} | {1:4d} | {2:4d} | {3:4d} | {4:4d}".format("milliseconds", 80, 160, 380, 400)) for action in actions: print("{0: <16} | {1:.2f} | {2:.2f} | {3:.2f} | {4:.2f}".format( action, errs_constant_frame[action][1], errs_constant_frame[action][3], errs_constant_frame[action][7], errs_constant_frame[action][9] )) print() print("=== Runnning avg. 2 ===") print("{0: <16} | {1:4d} | {2:4d} | {3:4d} | {4:4d}".format("milliseconds", 80, 160, 380, 400)) for action in actions: print("{0: <16} | {1:.2f} | {2:.2f} | {3:.2f} | {4:.2f}".format( action, running_average_2[action][1], running_average_2[action][3], running_average_2[action][7], running_average_2[action][9] )) print() print("=== Runnning avg. 4 ===") print("{0: <16} | {1:4d} | {2:4d} | {3:4d} | {4:4d}".format("milliseconds", 80, 160, 380, 400)) for action in actions: print("{0: <16} | {1:.2f} | {2:.2f} | {3:.2f} | {4:.2f}".format( action, running_average_4[action][1], running_average_4[action][3], running_average_4[action][7], running_average_4[action][9] ))