ResNet-18 transfer learning on the German Traffic Sign Recognition Benchmark (GTSRB) — 43 classes of real-world traffic signs. Built with PyTorch.
Traffic sign recognition is a core perception task in autonomous driving. A self-driving car must reliably classify signs under varying lighting, weather, angles, and occlusion — exactly the challenges present in the GTSRB dataset.
ResNet-18 (pretrained on ImageNet)
└── Replace final FC layer:
Linear(512) → Dropout(0.3) → Linear(256) → ReLU → Dropout(0.2) → Linear(43)
Full backbone fine-tuning (all layers trainable) with ImageNet-pretrained weights as initialization.
| Metric | Value |
|---|---|
| Test Accuracy | XX.XX% |
| Classes | 43 |
| Parameters | ~11.2M |
| Training Time | ~XXs (10 epochs, Apple MPS) |
pip install torch torchvision matplotlib numpy
# Train with defaults (10 epochs)
python traffic_sign_classifier.py
# Custom settings
python traffic_sign_classifier.py --epochs 15 --batch_size 128 --lr 0.0005Dataset downloads automatically (~600MB) on first run via torchvision.datasets.GTSRB.
- Transfer learning — ResNet-18 pretrained on ImageNet, fine-tuned on GTSRB
- Heavy augmentation — rotation, affine, color jitter, perspective (critical for real-world variance)
- Cosine annealing LR — smooth learning rate decay for better convergence
- ImageNet normalization — required for pretrained backbone compatibility
- Reproducibility — fixed seeds across all random generators
- Per-class analysis — identifies weak classes in an imbalanced dataset
The GTSRB dataset contains ~50,000 images of 43 German traffic sign classes. Key challenges:
- Images vary from 15×15 to 250×250 pixels
- Extreme lighting variation (day, night, shadows)
- Class imbalance (up to 10:1 ratio)
- Real-world noise, blur, and partial occlusion
├── traffic_sign_classifier.py Training & evaluation pipeline
├── outputs/
│ ├── best_model.pth Best model weights
│ ├── checkpoint.pth Full training checkpoint
│ ├── 01_samples.png Sample traffic signs
│ ├── 02_class_distribution.png Class balance analysis
│ ├── 03_training_curves.png Loss & accuracy curves
│ ├── 04_confusion_matrix.png 43×43 confusion matrix
│ ├── 05_wrong_predictions.png Most confident errors
│ ├── 06_correct_predictions.png Correct prediction samples
│ └── 07_per_class_accuracy.png Accuracy per sign type
└── README.md
- Python 3.10+
- PyTorch 2.x
- torchvision
- matplotlib, numpy
MIT





