This project implements a self-driving car using behavioral cloning techniques. The main components of the project include the model training in a Jupyter notebook and a Python script to run the trained model and control the car.
- Behavioural_cloning.ipynb: Jupyter notebook containing the implementation of the behavioral cloning model.
- Drive.py: Python script to run the trained model and control the car in a simulated environment.
This Jupyter notebook includes the following steps:
- Data Collection: Using a simulator to collect driving data.
- Data Preprocessing: Processing the images and steering angles for training.
- Model Architecture: Building a convolutional neural network (CNN) to predict steering angles from images.
- Model Training: Training the CNN with the processed data.
- Model Evaluation: Evaluating the model performance on a validation set.
- Model Saving: Saving the trained model for later use in the driving script.
This Python script uses the trained model to drive the car in a simulated environment. It includes:
- Model Loading: Loading the pre-trained model.
- Real-Time Prediction: Capturing images from the simulator, preprocessing them, and predicting the steering angle using the model.
- Control Commands: Sending control commands (steering angle, throttle) to the simulator.
To run this project, you need the following dependencies:
- Python 3.x
- Keras
- TensorFlow
- NumPy
- OpenCV
- Flask (for the driving script)
- A self-driving car simulator (e.g., Udacity's Self-Driving Car Simulator)
You can install the required Python packages using:
pip install -r requirements.txt
Open the Behavioural_cloning.ipynb
notebook and run all the cells to train the model. The trained model will be saved as model.h5
.
Run the driving script using the following command:
python Drive.py model.h5
Make sure the simulator is running and configured to the correct mode (e.g., autonomous mode) to receive the control commands from the script.
This project was inspired by the behavioral cloning project from the Udacity Self-Driving Car Nanodegree program.