예제 #1
0
def main():
    parser = argparse.ArgumentParser(
        description='Model Runner for team rwightman')
    parser.add_argument('bagfile', type=str, help='Path to ROS bag')
    parser.add_argument('--alpha',
                        type=float,
                        default=0.1,
                        help='Path to the metagraph path')
    parser.add_argument('--graph_path',
                        type=str,
                        help='Path to the self contained graph def')
    parser.add_argument('--metagraph_path',
                        type=str,
                        help='Path to the metagraph path')
    parser.add_argument('--checkpoint_path',
                        type=str,
                        help='Path to the checkpoint path')
    parser.add_argument('--debug_print',
                        dest='debug_print',
                        action='store_true',
                        help='Debug print of predicted steering commands')
    args = parser.parse_args()

    def get_model():
        model = RwightmanModel(alpha=args.alpha,
                               graph_path=args.graph_path,
                               metagraph_path=args.metagraph_path,
                               checkpoint_path=args.checkpoint_path)
        # Push one empty image through to ensure Tensorflow is ready.
        # There is typically a large wait on the first frame through.
        model.predict(np.zeros(shape=[480, 640, 3]))
        return model

    def process(model, img):
        steering_angle = model.predict(img)
        if args.debug_print:
            print(steering_angle)
        return steering_angle

    model = get_model()

    print calc_rmse(lambda image_pred: model.predict(image_pred),
                    gen(args.bagfile))
예제 #2
0
            return self.mean_angle[0]

        else:
            img = img1 - self.img0
            img = rescale_intensity(img,
                                    in_range=(-255, 255),
                                    out_range=(0, 255))
            img = np.array(img, dtype=np.uint8)  # to replicate initial model
            self.state.append(img)
            self.img0 = img1

            X = np.concatenate(self.state, axis=-1)
            X = X[:, :, ::-1]
            X = np.expand_dims(X, axis=0)
            X = X.astype('float32')
            X -= self.X_mean
            X /= 255.0
            return self.model.predict(X)[0][0]


if __name__ == "__main__":
    parser = argparse.ArgumentParser(description='Model Runner for team rambo')
    parser.add_argument('bagfile', type=str, help='Path to ROS bag')

    args = parser.parse_args()

    model = Model("tanel/final_model.hdf5", "tanel/X_train_mean.npy")
    print calc_rmse(lambda image_pred: model.predict(image_pred),
                    gen(args.bagfile))