Traffic Sign Classification (GTSRB, 43 classes)

🚦 Try the live demo β€” runs entirely in your browser, no sign-up: https://noorullahzamindar-007.github.io/Portfolio/traffic-sign-demo/

A convolutional neural network that classifies German traffic signs into 43 classes β€” the kind of perception model used in driver-assistance and autonomous-driving systems. Built as a learning project by Noorullah Zamindar.

What it does

Give it a photo of a traffic sign and it returns the most likely of 43 sign types β€” speed limits (20–120 km/h), no passing, stop, yield, priority road, dangerous curves, road work, pedestrians, children crossing, roundabout, and more. Input images are resized to 50Γ—50 pixels and pixel values scaled to [0, 1], exactly as in training.

Model architecture

Sequential CNN, as built in the original notebook:

  1. Conv2D (64 filters, 3Γ—3, ReLU, same padding) + MaxPool (2Γ—2) + Dropout (0.5)
  2. Conv2D (64 filters, 3Γ—3, ReLU) + MaxPool (2Γ—2) + Dropout (0.5)
  3. Flatten β†’ Dense (128, ReLU) + Dropout (0.5) β†’ Dense (43, softmax)

Optimizer: Adam. Loss: sparse categorical cross-entropy. 5 epochs, batch size 128.

Training data

GTSRB β€” German Traffic Sign Recognition Benchmark (training split, 39,209 images across 43 classes, public dataset via the official benchmark distribution). 80% used for training (31,368 images) and 20% held out for validation (7,841 images), split with a seeded shuffle (seed 42).

Metrics (measured from this retraining run)

  • Validation accuracy: 0.9719 (97.19%) β€” 7,841 held-out images
  • Final training accuracy: 0.8399 (83.99%)
  • Per-epoch history is in metrics.json in this repo.

The original notebook run (Google Colab, same recipe) reached 0.9740 validation accuracy after 5 epochs; the numbers above are from this repo's own retraining, not copied from that run.

Limitations

  • Trained only on the GTSRB training images β€” German signs, mostly clean, centred, daylight photos. Performance drops on signs from other countries, heavy occlusion, night or bad-weather images, and signs at extreme angles.
  • Input must be a single sign, cropped and centred; the model does not detect or localise signs in a full scene.
  • Classes are imbalanced in GTSRB (some signs have ~200 images, others over 2,000), so rarer signs are recognised less reliably.
  • The official GTSRB final test set ships without public labels, so no test-set accuracy is reported here β€” the validation accuracy above is the honest held-out number.
  • Not safety-critical: do not use as the sole perception system in a vehicle.

How to use

import numpy as np
from PIL import Image
from tensorflow import keras

model = keras.models.load_model("traffic_sign_cnn.keras")

CLASS_NAMES = [...]  # 43 names, see metrics.json -> class_names

img = Image.open("sign.jpg").convert("RGB").resize((50, 50))
x = np.array(img, dtype=np.float32)[None] / 255.0
probs = model.predict(x)[0]
print(CLASS_NAMES[int(np.argmax(probs))], float(np.max(probs)))

Requires tensorflow>=2.18, numpy, pillow (see requirements.txt).

Class names (43)

Speed limit (20/30/50/60/70/80/100/120 km/h), End of speed limit (80 km/h), No passing, No passing for vehicles over 3.5 metric tons, Right-of-way at the next intersection, Priority road, Yield, Stop, No vehicles, Vehicles over 3.5 metric tons prohibited, No entry, General caution, Dangerous curve to the left, Dangerous curve to the right, Double curve, Bumpy road, Slippery road, Road narrows on the right, Road work, Traffic signals, Pedestrians, Children crossing, Bicycles crossing, Beware of ice/snow, Wild animals crossing, End of all speed and passing limits, Turn right ahead, Turn left ahead, Ahead only, Go straight or right, Go straight or left, Keep right, Keep left, Roundabout mandatory, End of no passing, End of no passing by vehicles over 3.5 metric tons.

Downloads last month
34
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Collection including Noor-Khan/traffic-sign-classification