Traffic Sign Recognition (Python Project)
- Python
- TensorFlow
- OpenCV
- NumPy
- Matplotlib
Overview
This project uses a lightweight neural network to recognize German traffic signs from low-res images. It follows a straightforward machine learning (ML) workflow: prepare, train, evaluate, and improve.
- 43 sign types, with extra variations added so less common signs weren't overlooked.
- Repeatable training steps with results saved to
outputs/. - Confusion matrix, per-class accuracy, and misclassified examples included.
Dataset
I used the German Traffic Sign Recognition Benchmark (GTSRB), a public set of photos covering 43 kinds of signs in real driving conditions. Some images are a bit blurry or partly cut off, which makes the task feel closer to real life.
Images were scaled down to 32x32 to keep the training light and fast. I also made small adjustments (tiny rotations and brightness changes) to help the model handle different lighting and angles without changing what the signs look like.
- Thousands of labeled photos across 43 sign types.
- Resized to 32x32; gentle edits for lighting/angle changes.
- Split into training, validation, and test sets for a fair check on new images.
Model Architecture
A compact CNN optimized for 32x32 inputs:
- Pattern-finding layers: spot edges and shapes, then combine them into sign features; dropout step helps it learn patterns instead of memorizing photos.
- Summary → decision: the network condenses each image to a short summary and then picks the best match from 43 labels.
- Right-sized and stable: small enough to train quickly on 32×32 images; uses early stop/learning-rate slowdown and class weighting so rarer signs aren't overlooked.
Why this design? Simple, fast, and accurate for tiny images.
Training Setup
Short training runs, simple checks, and a few safeguards to keep learning steady.
- Rounds: about 20–30 training rounds ("epochs"), stop early if it stops improving.
- Batch size: 64 images at a time.
- Progress check: keep a small set of images the model never sees during training to track real progress.
- Learning step: slow the learning if progress stalls to fine-tune near the end.
- Rare signs: give them a bit more weight so they aren’t ignored.
- Image tweaks: small rotations and brightness changes during training to handle different conditions.
- Saved results: charts/logs go to
outputs/in the code repo.
Results
- Average (per class): 92.9% across 43 signs.
- Strongest (≈100%): End of no passing by trucks; Dangerous curve (left); End of all limits; Stop; Yield.
- Lower: Pedestrians (50%); End of no passing (60%); Speed limit 20 (80%).
See the detailed accuracy report Click to expand
You can download the full per-class accuracy here:
Download per-class accuracy (CSV)