A deep learning model for recognizing and classifying traffic signs using PyTorch. This project demonstrates training a ResNet18 model on the German Traffic Sign Recognition Benchmark (GTSRB) dataset.
- Test Accuracy: 93.35%
- Model Architecture: ResNet18 with custom classification head
- Input Size: 224x224 pixels
- Number of Classes: 43
| Metric | Score |
|---|---|
| Precision (macro avg) | 0.88 |
| Recall (macro avg) | 0.87 |
| F1-score (macro avg) | 0.87 |
| Precision (weighted avg) | 0.94 |
| Recall (weighted avg) | 0.93 |
| F1-score (weighted avg) | 0.93 |
- Data preprocessing and augmentation
- Model training with early stopping
- Learning rate scheduling
- Model evaluation with detailed metrics
- Confusion matrix visualization
.
├── data/
│ └── processed/ # Processed dataset
│ ├── images/ # Extracted images
│ │ ├── train/ # Training images
│ │ ├── valid/ # Validation images
│ │ └── test/ # Test images
│ ├── labels.csv # Image paths and labels
│ └── label_names.csv # Class names
├── src/
│ ├── train_fixed.py # Training script
│ ├── evaluate.py # Model evaluation
│ └── process_pickle_data.py # Data preprocessing
├── best_model.pth # Best model weights
├── final_model.pth # Final trained model
└── requirements.txt # Python dependencies
-
Clone the repository
git clone <repository-url> cd traffic-sign-recognition
-
Set up a virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Train the model
python src/train_fixed.py
-
Evaluate the model
python src/evaluate.py
After training, you'll find:
- Training/validation loss and accuracy plots
- Confusion matrix saved as
confusion_matrix.png - Detailed classification report in the console
- The model was trained for 5 epochs with early stopping
- Data augmentation includes random rotations, flips, and color jitter
- The best model is saved as
best_model.pthbased on validation accuracy
This project is licensed under the MIT License - see the LICENSE file for details.