Based on the work of coldKnight/TrafficLight_Detection-TensorFlowAPI.
- create conda environment
conda create -n tf14 python=3.5
and activate itactivate tf14
- install tensorflow, for CPU
pip install tensorflow==1.4.0
of for GPUconda install cudnn=6.0 conda install cudatoolkit=8.0 pip install tensorflow-gpu==1.4.0
- clone tensorflow/models
git clone https://github.com/tensorflow/models/ --branch r1.4.0 --single-branch
and go to last commit that supports TensorFlow 1.4git reset --hard 1f34fcafc1454e0d31ab4a6cc022102a54ac0f5b
. - go into
cd models/research
and create protobuf files (if you have not installed protoc install it) by runningprotoc object_detection/protos/*.proto --python_out=.
or something like“C:\Program Files\protoc-3.4.0-win32\bin\protoc.exe” object_detection/protos/*.proto --python_out=.
on windows - install slim
pip install -e slim/.
and delfpip install -e delf/.
- copy the
object_detection
folder to your workspace - install some dependencies
pip install matplotlib==3.0.2 Pillow==5.4.1
- and some more if you want to run the notebook to generate TFRecord files
pip install jupyter==1.0.0 PyYAML==3.13 cython=0.29.4 opencv-python==4.0.0.21 tqdm==4.30.0
, runningpip install imgaug==0.2.7
might fail on windows, so you need to runconda install shapely=1.6.4
first
- Download labeled images by coldKnight
- copy
sim_training_data
folder intodata/image_data/
- run
simulation_data.ipynb
indata/
in order to generatesim_test.record
andsim_train.record
or download the TFRecord files we used
- select a model e.g.
ssd_mobilenet_v1_coco
and unpack it your workspace - download the corresponding configuration
- update configuration (these are the settings we chose, trained witha GeForce GTX 1050 Ti ~10h of training)
num_classes: 90 => num_classes: 4
height: 300 => height: 400
width: 300 => width: 400
batch_size: 24 => 8
num_steps: 200000 => num_steps: 25000
max_detections_per_class: 100 => max_detections_per_class: 10
max_total_detections: 100 => max_total_detections: 10
fine_tune_checkpoint: "PATH_TO_BE_CONFIGURED/model.ckpt" =>fine_tune_checkpoint: "ssd_mobilenet_v1_coco_2017_11_17/model.ckpt"
PATH_TO_BE_CONFIGURED => data
num_examples: 8000 => num_examples: 974
remove data_augmentation_options
as the dataset has already been augmented and max_evals: 10
as we want to test on all testdata.
- Download labeled images by coldKnight
- copy
real_training_data
folder intodata/image_data/
- run
real_data.ipynb
indata/
in order to generatereal_test.record
andreal_train.record
or download the TFRecord files we used
- reuse configuration from simulator
- update
PATH_TO_BE_CONFIGURED
andnum_examples
- copy
train.py
andeval.py
fromobject_detection
in the root of you workspace - start training
python train.py --logtostderr --train_dir=./trained_models --pipeline_config_path=ssd_mobilenet_v1_coco.config
- while traing you can evaulate the model on the test dataset by running `
python eval.py --logtostderr --pipeline_config_path=ssd_mobilenet_v1_coco.config --checkpoint_dir=trained_models --eval_dir=trained_models/eval/ --run_once=True
- show training progress
tensorboard --logdir=trained_models
- copy
export_inference_graph.py
fromobject_detection
in the root of you workspace - freeze the graph
python export_inference_graph.py --input_type image_tensor --pipeline_config_path ssd_mobilenet_v1_coco.config --trained_checkpoint_prefix trained_models/model.ckpt-25000 --output_directory frozen_graph
- fix
ValueError: Protocol message RewriterConfig has no "layout_optimizer" field.
by editing line 72 inobject_detection/exporter.py
. Changelayout_optimizer
tooptimize_tensor_layout
.