This repository contains a PyTorch implementation of a traffic sign detection system using Faster R-CNN. This code can train on the COCO-formatted object detection dataset and evaluate the model's performance.
- PyTorch
- torchvision
- OpenCV (cv2)
- pycocotools
- albumentations
- numpy
- Extracting Frames from YouTube Videos with FFMpeg: Before training the model, videos can be sourced from YouTube, and frames can be extracted using FFMpeg.
- Labeling Frames with LabelImg: For annotating these frames, you'd use LabelImg. This ensures the dataset's richness and accuracy.
- Data Augmentation with Albumentations: Uses the Albumentations library for on-the-fly data augmentation, enhancing the model's ability to generalize across various traffic scenarios.
- Faster R-CNN Implementation: Utilizes torchvision's Faster R-CNN with a choice between ResNet50 and MobileNet backbones for the detection task.
- TrafficSignDataset: A custom dataset class that loads COCO-formatted datasets. It includes utilities to get image annotations, visualize them, and split the dataset into training and test sets.
- The training loop uses Adam optimizer with a learning rate of 0.001.
- The model can be saved to disk after training and can be loaded for evaluation.
- Provides utilities for computing and printing the mean Average Precision (mAP) of the model on the test set.
- Place your COCO-formatted dataset in the same directory as the script.
- Update the
root
andannotation
paths in theTrafficSignDataset
instantiation in themain()
function accordingly. - By default, the code is set to train mode (
Train=True
). Set it toFalse
if you want to load a pre-trained model and evaluate it.