Instructions to use Noor-Khan/traffic-sign-classification with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use Noor-Khan/traffic-sign-classification with Keras:
# !pip install -U keras tensorflow huggingface_hub # Keras needs TensorFlow installed to read "hf://" paths, so the tensorflow backend is selected here; # "jax" and "torch" also work for computation once TensorFlow is installed. import os os.environ["KERAS_BACKEND"] = "tensorflow" import keras model = keras.saving.load_model("hf://Noor-Khan/traffic-sign-classification") - Notebooks
- Google Colab
- Kaggle
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.
- Model type: CNN (Keras / TensorFlow), 1,035,627 parameters
- Task: image classification (multi-class, 43 classes)
- Language: images (German traffic signs)
- License: MIT
- Source code: https://github.com/NoorullahZamindar-007/Traffic-Sign-Classification
- Training script:
train.pyin this repo (reproduces the training exactly)
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:
- Conv2D (64 filters, 3Γ3, ReLU, same padding) + MaxPool (2Γ2) + Dropout (0.5)
- Conv2D (64 filters, 3Γ3, ReLU) + MaxPool (2Γ2) + Dropout (0.5)
- 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.jsonin 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