This repository aims to implement NVIDIA's Behavioral Cloning Paper using PyTorch. However, instead of only generating steering commands to be able to also control the throttle, some modifications are made to the model. While the NVIDIA model is like;
And the throttle was controlled by;
...
throttle = 1.0 - steering_angle**2 - (speed/speed_limit)**2
...
The model I've modified is like;
Thus, It is possible to complete both of the tracks provided in the simulator fully relying on our neural network.
As the source of the data and inference environment, Udacity Self Driving Car Simulator is utilized since it seamlessly lets gathering the type of data we need. Term 1 Version 2 is used for development of this repository, so it is recommended.
A pretrained model is also available as driver_best.pt
if you want to skip right to driving.
- Launch the simulator and proceed to "Training Mode".
- Hit "R" key to chose the directory which the data is going to be saved to. After chosing the directory hit "R" key again to start data recoring. It is recommended to drive minimum 10 mins.
- When you're done with your data collection step hit "R" key again. And wait for data capture to end.
Above steps going to create a csv file and a folder full of "dashcam" images. !! To be able to drive in both tracks, foreseeably, data should be collected from both.
Run training script as below;
python3 Train.py -d <path_to_data_csv>
-t <training_set_fraction>
-e <epochs>
-b <batch_size>
-l <learning_rate>
-m <path_to_model>
To continue to train a previously saved model -m <path_to_model>
can be used. If not used, a new model will be initialized and trained from scratch.
Throughout your training, validation will also be performed and the model with the best validation loss will be saved as "driver_best.pt". At the end of the training a graph that shows your training and validation loss will be saved to project directory.
As you finished your training, you now can see your model drive.
- Launch the simulator in "Autonomous Mode".
- Then run
python3 drive_torch <path_to_model>