Skip to main content
Keras model parts provide neural network-based autopilots that predict steering and throttle from camera images.

Base Classes

KerasPilot

Abstract base class for all Keras-based pilots. Constructor:
Interpreter
default:"KerasInterpreter()"
Model interpreter (Keras, TFLite, TensorRT)
tuple
default:"(120, 160, 3)"
Input image shape (height, width, channels)
Methods:
(img_arr: np.ndarray, *other_arr) -> (angle, throttle)
Run inference on image and optional additional inputs. Returns steering angle and throttle.
(model_path: str) -> None
Load a trained model from file
(model_path, train_data, train_steps, ...) -> history
Train the model on provided dataset
() -> None
Compile the model with optimizer and loss function

Linear Pilots

KerasLinear

Linear regression pilot with continuous outputs. Constructor:
int
default:"2"
Number of outputs (typically 2: angle and throttle)
Architecture:
  • 5 convolutional layers (24, 32, 64, 64, 64 filters)
  • Dropout layers for regularization
  • 2 dense layers (100, 50 neurons)
  • Linear output layer per output
Loss Function: Mean Squared Error (MSE) Usage Example:

KerasCategorical

Categorical classification pilot that bins outputs. Constructor:
float
default:"0.5"
Maximum throttle range (0 to throttle_range)
Architecture:
  • 5 convolutional layers
  • Dropout layers
  • 2 dense layers
  • Softmax outputs: 15 bins for angle, 20 bins for throttle
Loss Function: Categorical Cross-Entropy Usage Example:

Recurrent Pilots

KerasMemory

Pilot with memory of previous steering/throttle commands. Constructor:
int
default:"3"
Number of previous commands to remember
int
default:"0"
Number of dense layers for memory processing
float
default:"0.0"
Initial throttle value for memory
Architecture:
  • Standard CNN layers for image
  • Additional dense layers for memory input
  • Concatenation of image and memory features
  • Linear outputs
Returns: Smoother steering outputs by considering recent control history Usage Example:

KerasLSTM

Long Short-Term Memory (LSTM) pilot for temporal sequences. Constructor:
int
default:"3"
Number of frames in sequence
int
default:"2"
Number of outputs
Architecture:
  • Time-distributed convolutional layers
  • 2 LSTM layers (128 units each)
  • Dense layers
  • Linear output
Usage Example:

Keras3D_CNN

3D Convolutional Neural Network for temporal sequences. Constructor:
int
default:"20"
Number of frames in sequence
Architecture:
  • 4 Conv3D layers with max pooling
  • Flatten and dense layers
  • Batch normalization and dropout

Multi-Input Pilots

KerasIMU

Pilot that uses camera image + IMU sensor data. Constructor:
int
default:"6"
Number of IMU inputs (accel_xyz + gyro_xyz)
Architecture:
  • CNN branch for image processing
  • Dense branch for IMU data
  • Concatenated features
  • Linear outputs
Usage Example:

KerasBehavioral

Behavioral cloning with behavior state input. Constructor:
int
default:"2"
Number of behavior state inputs
Architecture:
  • CNN branch for image
  • Dense branch for behavior state
  • Categorical outputs (like KerasCategorical)
Usage Example:

KerasLocalizer

Pilot with track localization output. Constructor:
int
default:"8"
Number of track location categories
Outputs:
  • Steering angle
  • Throttle
  • Track location (0 to num_locations-1)

Training

Training a Model

Optimizer Configuration

Supported Optimizers:
  • 'adam': Adam optimizer
  • 'sgd': Stochastic Gradient Descent
  • 'rmsprop': RMSProp

Configuration

Typical configuration in myconfig.py:

Integration Example