/Traffic-Light-Detection

Traffic Light Detection and Classification using TensorFlow Object Detection API

Primary LanguageJupyter Notebook

Traffic Light Detection

Implemented with TensorFlow Object Detection API.

Tested on LaRA dataset.

Model inference example:

alt-text

Check out the rendered video in Youtube or BaiduPan

LaRA Traffic Lights Recognition (TLR) Public Benchmarks

On-board vehicle acquisition in a dense urban environment:

  • 11179 frames (8min 49sec, @25FPS)
  • 640×480 (RGB, 8bits)
  • Paris (France)

Links:

To make TFRecord files for Tensorflow tranning, read this

Performance

Here records an informal test performance on 592 unseen images:

  • Model = SSD MobileNet, pre-trained on COCO
  • Infer time per image = 9 ms
  • Green light AP@0.5IOU = 0.385
  • Red light AP@0.5IOU = 0.725
  • Yellow light AP@0.5IOU = 0.385
  • Precision mAP@0.5IOU = 0.620

Running on Tesla P40 GPU

Training total loss:

alt-text

Get the tensorflow models lib

Do git clone https://github.com/tensorflow/models.git and update directory in .sh files

Follow the instructions at this page for installing some simple dependencies.

Location of pre-trained models: pre-trained models zoo

Download the required model tar.gz files and untar them into models/ directory with tar -xvzf name_of_tar_file.

Creating TFRecord files:

python data_conversion.py --input_yaml lara/annotations_train.yaml --output_path lara/train.record
python data_conversion.py --input_yaml lara/annotations_test.yaml --output_path lara/test.record

Training, Evaluating, and Tensorboarding

sh train.sh <faster_rcnn | ssd_inception | ssd_mobilenet>
sh evaluate.sh <faster_rcnn | ssd_inception | ssd_mobilenet>
tensorboard --logdir=models --port=8052

note you'd better not run train & evaluate together because they will use up GPU memory

Saving Weights for Inference

sh freeze.sh <faster_rcnn | ssd_inception | ssd_mobilenet> <model checkpoint version num>

Infer Results, Visualize, and Make Video

using the TrafficLightDetection-Inference.ipynb