def main(): parser = ArgumentParser() parser.add_argument('-i', dest='input_data', default='freiburg1_xyz.sqlite3', help='input data set') parser.add_argument('-t', dest='test_size', default=10000, type=int, help='test data size') parser.add_argument('-b', dest='batch_size', default=100, type=int, help='batch size for testing') parser.add_argument('-c', dest='checkpoint', default='KinectPose2/KinectPose-100000') args = parser.parse_args() input_width, input_height, input_channel = 640, 480, 1 output_size = 7 if os.path.isfile(args.checkpoint + '.index') and \ os.path.isfile(args.checkpoint + '.meta'): print('preparing data loader...') data_loader = FreiburgData(args.input_data) print('loading pre-train model...') model = KinectPoseModel(input_width, input_height, input_channel, output_size, model_name='KinectPose', saving=False) with tf.Session() as sess: model.load(sess, args.checkpoint) batches = args.test_size / args.batch_size outputs = np.zeros(shape=[output_size], dtype=np.float32) for i in range(batches): p, n, l = data_loader.diff_depth_batch(args.batch_size) prediction = model.predict(sess, p, n) outputs += np.sum(np.abs(prediction - l), axis=0) print('processing batch %d...' % (i)) print(prediction[0, :]) print(l[0, :]) p_image = p[0, :, :, 0] n_image = n[0, :, :, 0] plt.figure() plt.imshow(p_image, cmap='gray') plt.figure() plt.imshow(n_image, cmap='gray') plt.show() outputs /= args.test_size print(outputs) else: print('checkpoint not exists.')
def main(): parser = ArgumentParser() parser.add_argument('--input-db', dest='input_db', default='freiburg1_xyz.sqlite3', help='input dataset') parser.add_argument('--checkpoint', dest='checkpoint', default='KinectPose2/KinectPose-100000', help='checkpoint path') args = parser.parse_args() data = FreiburgData(args.input_db) logger.info(data.depth_images.shape) predicted_poses = predict_seq(data.depth_images, args.checkpoint, data.depth_labels[0, :]) fig = plt.figure() ax = fig.add_subplot(111, projection='3d') ax.plot(data.depth_labels[:, 0], data.depth_labels[:, 1], data.depth_labels[:, 2], 'g') ax.plot(predicted_poses[:, 0], predicted_poses[:, 1], predicted_poses[:, 2], 'r') ax.set_xlabel('$X$') ax.set_ylabel('$Y$') plt.show()
def main(): parser = ArgumentParser() parser.add_argument('--db', dest='db', default='freiburg1_xyz.sqlite3', help='input database') parser.add_argument('--batch-size', type=int, dest='batch_size', default=64, help='batch size for training') parser.add_argument('--max-epoch', type=int, dest='max_epoch', default=100000, help='max epoch for training') parser.add_argument('--output-epoch', type=int, dest='output_epoch', default=10, help='epoch for display and saving') parser.add_argument('--keep-prob', type=float, dest='keep_prob', default=0.8, help='keep probability for drop out') parser.add_argument('--decay-epoch', type=int, dest='decay_epoch', default=5000, help='decay learning rate epoch') args = parser.parse_args() data_loader = FreiburgData(args.db) input_width = 640 input_height = 480 input_channel = 1 output_size = 7 model = KinectPoseModel(input_width, input_height, input_channel, output_size, model_name='KinectPose', saving=True) with tf.Session() as sess: model.train_with_loader(sess, data_loader, batch_size=args.batch_size, output_period=args.output_epoch, decay_epoch=args.decay_epoch, keep_prob=args.keep_prob, max_epoch=args.max_epoch)
def main(): parser = ArgumentParser() parser.add_argument('--input-db', dest='input_db', default='freiburg1_360.sqlite3', help='input dataset') parser.add_argument( '--checkpoint', dest='checkpoint', default='saved_KP_320_240_3_diff10_c11/KinectPose-3400', help='checkpoint path') parser.add_argument('--diff', dest='diff', type=int, default='10', help='prediction frame diff') args = parser.parse_args() data = FreiburgData(args.input_db) logger.info(data.depth_images.shape) predicted_poses, acc = predict_seq(data.rgb_images, args.checkpoint, data.rgb_labels, diff=args.diff) # print(data.rgb_labels[0:10]) # print(predicted_poses[0:10]) print(acc) fig = plt.figure() ax = fig.add_subplot(111, projection='3d') ax.plot(data.depth_labels[:, 0], data.depth_labels[:, 1], data.depth_labels[:, 2], 'g') #depth????? ax.plot(predicted_poses[:, 0], predicted_poses[:, 1], predicted_poses[:, 2], 'r') ax.set_xlabel('$X$') ax.set_ylabel('$Y$') plt.show()
def main(): logging.basicConfig() logger = logging.getLogger('train') logger.setLevel(logging.INFO) parser = ArgumentParser() parser.add_argument('--db', dest='db', default='freiburg1_xyz.sqlite3', help='input database') parser.add_argument('--batch-size', type=int, dest='batch_size', default=256, help='batch size for training') parser.add_argument('--max-epoch', type=int, dest='max_epoch', default=10000, help='max epoch for training') parser.add_argument('--output-epoch', type=int, dest='output_epoch', default=10, help='epoch for display and saving') parser.add_argument('--keep-prob', type=float, dest='keep_prob', default=0.8, help='keep probability for drop out') parser.add_argument('--decay-epoch', type=int, dest='decay_epoch', default=1000, help='decay learning rate epoch') parser.add_argument('--input-type', dest='input_type', default='rgbd', help='type of input(channels)') args = parser.parse_args() data_loader = FreiburgData(args.db) input_width = 320 input_height = 240 if args.input_type == 'depth': input_channel = 1 logger.info('input type: depth') elif args.input_type == 'rgb': input_channel = 3 logger.info('input type: rgb') elif args.input_type == 'rgbd': input_channel = 4 logger.info('input type: rgbd') output_size = 3 model = KinectPoseModel(input_width, input_height, input_channel, output_size, kernel_size=3, model_name='KinectPose', saving=True) with tf.Session() as sess: model.train_with_loader(sess, data_loader, batch_size=args.batch_size, output_period=args.output_epoch, decay_epoch=args.decay_epoch, keep_prob=args.keep_prob, max_epoch=args.max_epoch, input_type=args.input_type)