Implementation of a traffic light detector for the udacity sdc nanodegreee using tensorflow object detection API
You should first download the Bosch Small Traffic Lights Dataset, and rearrange the folder structure as following:
data
├── train.yaml
├── test.yaml
├── additional_train.yaml
├── rgb
│ ├── train
│ ├── test
│ ├── additional
│ │ ├── 2015-10-05-10-52-01_bag
│ │ │ ├── 24594.png
│ │ │ ├── 24664.png
│ │ │ └── 24734.png
...
Note that the image paths contained in the test.yaml files should be modified to the relative path to the data folder.
You can find the tensorflow object detection API here, and follow the installation instruction here.
python create_tf_record.py
download faster_rcnn_resnet101_coco_2017_11_08 and ssd_mobilenet_v1_coco_2017_11_17 model files from here, put the model files in models folder as following:
models
├── faster_rcnn_resnet101_coco_2017_11_08
│ ├── frozen_inference_graph.pb
│ ├── ...
├── ssd_mobilenet_v1_coco_2017_11_17
│ ├── frozen_inference_graph.pb
│ ├── ...
├── faster_rcnn_resnet101_traffic_lights
├── ssd_mobilenet_v1_traffic_lights
python object_detection/train.py --logtostderr \
--pipeline_config_path=config/ssd_mobilenet_v1_traffic_lights.config \
--train_dir=models/ssd_mobilenet_v1_traffic_lights
python object_detection/train.py --logtostderr \
--pipeline_config_path=config/faster_rcnn_resnet101_traffic_lights.config \
--train_dir=models/faster_rcnn_resnet101_traffic_lights
python object_detection/export_inference_graph.py \
--input_type image_tensor \
--pipeline_config_path config/ssd_mobilenet_v1_traffic_lights.config \
--trained_checkpoint_prefix models/ssd_mobilenet_v1_traffic_lights/model.ckpt-30727 \
--output_directory models/ssd_mobilenet_v1_traffic_lights/export
python object_detection/export_inference_graph.py \
--input_type image_tensor \
--pipeline_config_path config/faster_rcnn_resnet101_traffic_lights.config \
--trained_checkpoint_prefix models/faster_rcnn_resnet101_traffic_lights/model.ckpt-25445 \
--output_directory models/faster_rcnn_resnet101_traffic_lights/export
python object_detection/export_inference_graph.py \
--input_type image_tensor \
--pipeline_config_path config/faster_rcnn_inception_v2_traffic_lights.config \
--trained_checkpoint_prefix models/faster_rcnn_inception_v2_traffic_lights/model.ckpt-28506 \
--output_directory models/faster_rcnn_inception_v2_traffic_lights/export
python object_detection/eval.py --logtostderr \
--checkpoint_dir=models/faster_rcnn_resnet101_traffic_lights/export \
--eval_dir=models/faster_rcnn_resnet101_traffic_lights/eval \
--pipeline_config_path=config/faster_rcnn_resnet101_traffic_lights.config
python object_detection/eval.py --logtostderr \
--checkpoint_dir=models/ssd_mobilenet_v1_traffic_lights/export \
--eval_dir=models/ssd_mobilenet_v1_traffic_lights/eval \
--pipeline_config_path=config/ssd_mobilenet_v1_traffic_lights.config
run detection_test.ipynb
python prepare_classifier_data.py
run train_classifier.ipynb
python freeze_graph.py --input_graph=models/classifier/graph.pb \
--input_checkpoint=models/classifier/model.ckpt \
--input_binary=true \
--output_graph=models/classifier/frozen_graph.pb \
--output_node_names=prediction
python test_tl_classifier.py input output