Recognising UK Traffic Signs with a CNN: From Custom Architecture to MobileNetV2

How convolutional neural networks classify road signs for driver-assistance and autonomous vehicle systems, comparing a purpose-built CNN against transfer learning with MobileNetV2 on a 43-class traffic sign dataset.

▶ Open the simulation

Why traffic sign recognition matters for driver assistance

Automatic traffic sign recognition sits at the core of Advanced Driver Assistance Systems (ADAS) and autonomous vehicles — a car that can't reliably read a speed limit sign or a give-way sign has no business deciding when to slow down on its own. UK signage follows the Traffic Signs Regulations and General Directions (TSRGD), broadly grouped into warning signs (triangular, red border), regulatory/prohibition signs (circular, red border), mandatory signs (circular, blue) and priority signs — categories that, along with most of Europe, trace back to the Vienna Convention on Road Signs.

Because labelled UK-specific sign imagery is scarce, this kind of project typically trains on the German Traffic Sign Recognition Benchmark (GTSRB) — 43 sign classes and roughly 50,000 images — since European sign designs are similar enough under the same convention to serve as a solid proxy dataset, with UK-specific fine-tuning layered on top when real UK imagery becomes available.

Preprocessing images for a small, consistent input

Every image is resized to a compact 48×48 pixels (small enough for fast inference, large enough to preserve the shapes and digits that distinguish one sign from another) and pixel values are normalised to the [0,1] range. A more targeted preprocessing step applies CLAHE (Contrast Limited Adaptive Histogram Equalisation) to the brightness channel after converting to LAB colour space — this boosts local contrast so a sign photographed in flat, overcast light is as legible to the model as one photographed in bright sun.

Because sign classes are naturally imbalanced (some signs, like generic speed limits, appear far more often on real roads than rare warning signs), class_weight='balanced' is computed and passed to training so the loss function penalises mistakes on rare classes more heavily, preventing the model from just learning to always predict the most common sign.

Data augmentation with a critical exception

To help the model generalise beyond the exact camera angles and conditions in the training set, images are randomly rotated (±15°), shifted, sheared, zoomed and brightness-adjusted during training. One standard augmentation is deliberately switched off: horizontal flipping. Flipping a directional sign — a left-turn arrow, a keep-right sign — produces a physically nonsensical or actively wrong label, since the mirrored image no longer represents a real sign a driver would encounter. This is a good general lesson for computer vision projects: augmentation choices need to respect the semantics of the specific domain, not just be copied from a generic image-classification pipeline.

Two architectures: a custom CNN and MobileNetV2

The project builds and compares two model families. The first is a purpose-built CNN with four convolutional blocks of increasing depth (32 → 64 → 128 → 256 filters), each followed by batch normalisation, ReLU activation, max-pooling and dropout, before a small dense classifier head. The second uses MobileNetV2 via transfer learning: a network pretrained on ImageNet, with its early layers frozen and only the last 30 layers plus a new classification head fine-tuned on traffic signs.

MobileNetV2 is specifically chosen for its depthwise separable convolutions and inverted residual blocks, which give it a fraction of the parameters of a conventional CNN of similar depth — critical for a model that ultimately needs to run in real time (targeting well above 30 frames per second) on modest, embedded automotive hardware rather than a data-centre GPU. Both models are trained with the Adam optimiser, categorical cross-entropy loss, and callbacks for early stopping, checkpointing the best-performing weights, and reducing the learning rate when validation loss plateaus.

Evaluation: accuracy alone isn't enough for a safety system

Beyond overall accuracy, the model is evaluated on top-3 and top-5 accuracy (is the correct sign among the model's top few guesses, useful context for a system that might combine CNN predictions with other sensor data) and a full 43×43 confusion matrix that reveals exactly which sign pairs get confused most often. For a safety-critical application, which errors happen matters as much as how many: confusing two similar warning signs is a much smaller problem than confusing a STOP sign with something else, or misreading a speed limit (30 vs 50 vs 80) in a way that could lead to an unsafe speed recommendation. Any real deployment pipeline would specifically audit the confusion matrix for these safety-critical sign pairs rather than relying on a single aggregate accuracy number.

Frequently Asked Questions

Why train on a German dataset (GTSRB) for a UK traffic sign recognition project?

Labelled, road-collected UK sign imagery at the scale needed for deep learning is scarce, while GTSRB offers roughly 50,000 well-labelled images across 43 classes. Since UK and German signage both follow the Vienna Convention on Road Signs and share similar shapes, colours and layout conventions, GTSRB serves as a strong proxy for pretraining, with UK-specific images used for fine-tuning once available.

Why is horizontal flip augmentation turned off for traffic sign recognition?

Many traffic signs are directional — a left-turn arrow flipped horizontally becomes a right-turn arrow, and a flipped keep-right sign becomes keep-left. Training on flipped versions of these signs would teach the model incorrect associations between shape and meaning, since the mirrored image no longer corresponds to any sign a driver would actually encounter on the road.

Why use MobileNetV2 instead of a bigger, more accurate CNN for this task?

A driver-assistance system needs to classify signs in real time from a moving vehicle, often on embedded hardware with limited compute and power budgets. MobileNetV2's depthwise separable convolutions dramatically cut the parameter count and inference latency compared to a conventional CNN of similar depth, making it far better suited to real-time, in-vehicle deployment even if a larger network might squeeze out slightly higher accuracy in a lab setting.

What did you find?

Add reproduction steps (optional)