Skip to content

Repository files navigation

Steering Angle Prediction

Done by Vuk Antovic and Aleksandar Ivanovic. A CNN+LSTM model that predicts steering angles from dashcam footage and detects lane changes in real time. Trained on the Udacity self-driving car dataset.

How it works

The model takes a sequence of 5 consecutive frames, extracts spatial features from each using a shared CNN, then feeds those features into an LSTM to capture temporal context. The output is a single steering angle in the range [-1, 1].

Lane changes are detected by watching the rolling mean of predicted steering angles over a sliding window. If the mean exceeds a threshold for long enough, a lane change event is fired.

Setup

pip install -r requirements.txt

The dataset is downloaded automatically on first run via kagglehub.

Usage

# Train the model
python main.py --mode train

# Run tests on the test set
python main.py --mode predict

# Train then immediately run tests
python main.py --mode all

Additional flags:

--epochs N        number of training epochs (default: 10)
--lr FLOAT        learning rate (default: 0.001)
--start N         first frame index for tests (default: 0)
--count N         number of frames to run tests on (default: 200)

You can also run train.py and predict.py directly if you prefer.

Project structure

config.py       all paths and hyperparameters
dataset.py      data loading, preprocessing, sequence building
model.py        CNN+LSTM architecture
train.py        training loop
predict.py      tests and visualisation
lane_change.py  sliding-window lane change detector
main.py         entry point

Output

During tests, each frame is annotated with the predicted steering angle and a direction bar. Lane change events are highlighted with a red border and a text overlay. After test completes, a plot comparing predicted vs real data steering angles is saved as steering_plot.png.

Steering prediction output

Configuration

Everything lives in config.py.

About

Projekat iz predmeta DUuSAiUV, done by Vuk Antovic and Aleksandar Ivanovic

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages