- About
- Progress and TODO
- Download Trained Weights
- Get the Dataset
- Steps to Train
- To Detect Using the Trained Model
- References
This project aims to detect traffic light in real time using deep learning as a part of autonomous driving technology.
- Implementation for all the traffic light types are done. But the final model is still being trained almost every day to make it better. Check the Download Trained Weights section to get your desired weight files and try the model on you system.
- Detecting red (circular)
stop
sign. - Detection green (circular)
go
sign. - Train on for night time detection => Working but not perfect. Better updates to come soon.
- Detecting
warningLeft
sign. - Detecting
goLeft
sign. - Detecting
stopleft
sign. - Detecting
warning
sign. - Carla support => This one is a bit tricky.
Download the trained weights from here.
best_model_12.pt
: Trained for 67 epochs on all the traffic signs. Current mAP is 0.919
This project uses the LISA Traffic Light Dataset.. Download the dataset from Kaggle here.
-
The current train/test split is 90/10. The input image size is 608x608. So, it might take a lot of time to train if you train on a nominal GPU. I have trained the model on Google Colab with Tesla T4 GPU/P100 GPU. One epoch took with all the classes around 1 hour on a Tesla T4 GPU. Also, check the
cfg
folder and files before training. You have to use the cfg files corresponding to the number of classes you are training on. If you want to change the number of classes to train on, then you have to change the cfg file too. The current model has been trained on all 6 classes, so, the cfg file isyolov3-spp-6cls.cfg
. -
Prepare the data. Please do take a look at the paths inside the
prepare_labels.py
file and change them according to your preference and convenience.python prepare_labels.py
-
Create the train and validation text files (Current train/validation split = 90/10).
python prepare_train_val.py
-
To train on your own system (The current model has been trained for 30 epochs.)
- To train from scratch:
python train.py --data <your_data_folder>/traffic_light.data --batch 2 --cfg cfg/yolov3-spp-6cls.cfg --epochs 55 --weights "" --name from_scratch
- Using COCO pretrained weights:
python train.py --data <your_data_folder>/traffic_light.data --batch 4 --cfg cfg/yolov3-spp-6cls.cfg --epochs 55 --multi-scale --img-size 608 608 --weights weights/yolov3-spp-ultralytics.pt --name coco_pretrained
- To resume training:
python train.py --data <your_data_folder>/traffic_light.data --batch 2 --cfg cfg/yolov3-spp-6cls.cfg --epochs <num_epochs_must_be_greater_than_previous_training> --multi-scale --img-size 608 608 --resume --weights weights/<your_weight_file>.pt --name <name_to_be_saved_with>
- To train from scratch:
- Short answer: The image size in
cfg
file is not used. Only python executables' argument parserimg-size
argument is used.
- Download the weights here first, and paste them under the
weights
folder.python detect.py --source <path_to_your_test_video_file> --view-img --weights weights/<your_weight_file_name>.pt --img-size 608
- Recognizing Traffic Lights With Deep Learning.
- Self Driving Vehicles: Traffic Light Detection and Classification with TensorFlow Object Detection API.
- Detecting Traffic Lights by Single Shot Detection.
- A Hierarchical Deep Architecture and Mini-Batch Selection Method For Joint Traffic Sign and Light Detection.
- Accurate traffic light detection using deep neural network with focal regression loss.
- The YOLOv3 code has been take from the Ultralytics YOLOv3 repo and modified according to the use case.
- TL-SSD: Detecting Traffic Lights by Single Shot Detection.
- Detecting Traffic Lights in Real-time with YOLOv3.
- These may include links and citations for the data that I use for testing. You can also use these links to obtain the videos.
video1.mp4
: https://www.youtube.com/watch?v=yJrW8werMUs.video2.mp4
: https://www.youtube.com/watch?v=pU8ThDYZcCc.# Traffic-Light-Detection-Using-YOLOv3video3.mp4
: https://www.youtube.com/watch?v=iS5sq9IELEo.video4.mp4
: https://www.youtube.com/watch?v=GfWskqDjeTE.video5.mp4
: https://www.youtube.com/watch?v=7HaJArMDKgI.video6.mp4
: https://www.youtube.com/watch?v=NK_HNF1C8yA.video7.mp4
: https://www.youtube.com/watch?v=w-W9esW3eqI.video8.mp4
: https://www.youtube.com/watch?v=RPDYLA8Rh_M.video9.mp4
: https://www.youtube.com/watch?v=imeV3Pm-ZLE.