πŸ€– LateAI
Home β€Ί Tutorials β€Ί Traffic Signal Classification
🚦

Traffic Signal Classification

Intermediate Β· 1-2 days
πŸ“Ά Intermediate ⏱ 1-2 days πŸ’° Free (software only) 🏷 CV Zone

πŸ“Œ Overview

Train a CNN to recognise the colour of traffic lights (red, yellow, green), which can serve as the perception stage of a self-driving system.

The project has three parts - data preparation, model training, and real-time prediction: collect or download a dataset of signal images, learn the classification with a convolutional network, then hook up a camera to judge the light in real time.

🧰 What you need

πŸ”§ Step by step

1

Prepare the dataset

Collect several images of red, yellow, and green lights

Cropping the ROI to a smaller image speeds up training

2

Pre-process the data

Resize to a uniform size (64x64, for example) and normalise the pixels

Split into training and validation sets; data augmentation is optional

3

Build the CNN

A standard classification stack of convolution, pooling, and dense layers

Three output neurons for red, yellow, and green

4

Train the model

Compile with cross-entropy loss and Adam, then train for several epochs

Watch the validation accuracy to guard against overfitting

5

Evaluate the model

Measure accuracy and a confusion matrix on the validation set

Analyse misclassified samples (lighting, size)

6

Predict in real time

Grab a frame, pre-process it, and run the model

Take a majority vote over several frames for a more stable result

πŸ’‘ Tips

View original β†— ← Back to LateAI home