|
| 1 | + |
1 | 2 | [//]: # (Image References)
|
2 | 3 | [left0000]: ./examples/left0000.jpg
|
3 | 4 | [left0003]: ./examples/left0003.jpg
|
|
9 | 10 | [real0000]: ./examples/real0000.png
|
10 | 11 | [real0140]: ./examples/real0140.png
|
11 | 12 | [real0701]: ./examples/real0701.png
|
12 |
| -[sim0003]: ./examples/sim0003.png |
13 |
| -[sim0011]: ./examples/sim0011.png |
14 |
| -[sim0027]: ./examples/sim0027.png |
15 | 13 |
|
16 | 14 | # Traffic Light Detection and Classification with TensorFlow Object Detection API
|
17 |
| ---- |
18 | 15 |
|
19 |
| -#### A brief introduction to the project is available [here](https://medium.com/@Vatsal410/traffic-light-detection-tensorflow-api-c75fdbadac62) |
| 16 | +The project is forked from https://github.com/coldKnight/TrafficLight_Detection-TensorFlowAPI.git |
20 | 17 |
|
21 |
| ---- |
| 18 | +A brief introduction to the project is available [here](https://medium.com/@Vatsal410/traffic-light-detection-tensorflow-api-c75fdbadac62) |
22 | 19 |
|
23 |
| -AWS AMI with all the software dependencies like TensorFlow and Anaconda (in the community AMIs) - `udacity-carnd-advanced-deep-learning` |
24 | 20 |
|
25 | 21 | ### Get the dataset
|
26 | 22 |
|
27 | 23 | [Drive location](https://drive.google.com/file/d/0B-Eiyn-CUQtxdUZWMkFfQzdObUE/view?usp=sharing)
|
28 | 24 |
|
29 |
| -### Get the models |
30 |
| - |
31 |
| -Do `git clone https://github.com/tensorflow/models.git` inside the tensorflow directory |
32 | 25 |
|
33 |
| -Follow the instructions at [this page](https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md) for installing some simple dependencies. |
| 26 | +### Get the tensorflow models lib |
34 | 27 |
|
35 |
| -**All the files have to be kept inside the `tensorflow/models/research/` directory - data/, config/, data_conversion python files, .record files and utilitites/ ,etc.** |
| 28 | +Do `git clone https://github.com/tensorflow/models.git` and update directory in .sh files |
36 | 29 |
|
| 30 | +Follow the instructions at [this page](https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md) for installing some simple dependencies. |
37 | 31 |
|
38 |
| -### Location of pre-trained models: |
| 32 | +Location of pre-trained models: |
39 | 33 | [pre-trained models zoo](https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/detection_model_zoo.md)
|
40 | 34 |
|
41 |
| -Download the required model tar.gz files and untar them into `/tensorflow/models/research/` directory with `tar -xvzf name_of_tar_file`. |
42 |
| - |
43 |
| -### Creating TFRecord files: |
44 |
| - |
45 |
| -`python data_conversion_udacity_sim.py --output_path sim_data.record` |
46 |
| - |
47 |
| -`python data_conversion_udacity_real.py --output_path real_data.record` |
48 |
| - |
49 |
| ---- |
50 |
| - |
51 |
| -## Commands for training the models and saving the weights for inference. |
52 |
| - |
53 |
| -## Using Faster-RCNN model |
54 |
| - |
55 |
| -### For Simulator Data |
56 |
| - |
57 |
| -#### Training |
58 |
| - |
59 |
| -`python object_detection/train.py --pipeline_config_path=config/faster_rcnn-traffic-udacity_sim.config --train_dir=data/sim_training_data/sim_data_capture` |
60 |
| - |
61 |
| -#### Saving for Inference |
62 |
| - |
63 |
| -`python object_detection/export_inference_graph.py --pipeline_config_path=config/faster_rcnn-traffic-udacity_sim.config --trained_checkpoint_prefix=data/sim_training_data/sim_data_capture/model.ckpt-5000 --output_directory=frozen_sim/` |
64 |
| - |
65 |
| - |
66 |
| -### For Real Data |
67 |
| - |
68 |
| -#### Training |
69 |
| - |
70 |
| -`python object_detection/train.py --pipeline_config_path=config/faster_rcnn-traffic_udacity_real.config --train_dir=data/real_training_data` |
71 |
| - |
72 |
| -#### Saving for Inference |
73 |
| - |
74 |
| -`python object_detection/export_inference_graph.py --pipeline_config_path=config/faster_rcnn-traffic_udacity_real.config --trained_checkpoint_prefix=data/real_training_data/model.ckpt-10000 --output_directory=frozen_real/` |
75 |
| - |
76 |
| ---- |
77 |
| - |
78 |
| -## Using Inception SSD v2 |
| 35 | +Download the required model tar.gz files and untar them into `models/` directory with `tar -xvzf name_of_tar_file`. |
79 | 36 |
|
80 |
| -### For Simulator Data |
81 | 37 |
|
82 |
| -#### Training |
83 |
| - |
84 |
| -`python object_detection/train.py --pipeline_config_path=config/ssd_inception-traffic-udacity_sim.config --train_dir=data/sim_training_data/sim_data_capture` |
85 |
| - |
86 |
| -#### Saving for Inference |
| 38 | +### Creating TFRecord files: |
87 | 39 |
|
88 |
| -`python object_detection/export_inference_graph.py --pipeline_config_path=config/ssd_inception-traffic-udacity_sim.config --trained_checkpoint_prefix=data/sim_training_data/sim_data_capture/model.ckpt-5000 --output_directory=frozen_models/frozen_sim_inception/` |
| 40 | +`python data_conversion.py --input_yaml data/training_data/annotations_train.yaml --output_path data/train.record` |
| 41 | +`python data_conversion.py --input_yaml data/training_data/annotations_eval.yaml --output_path data/eval.record` |
89 | 42 |
|
90 | 43 |
|
91 |
| -### For Real Data |
| 44 | +## Using Faster-RCNN / Inception SSD v2 / MobileNet SSD v1 model |
92 | 45 |
|
93 | 46 | #### Training
|
94 | 47 |
|
95 |
| -`python object_detection/train.py --pipeline_config_path=config/ssd_inception-traffic_udacity_real.config --train_dir=data/real_training_data` |
| 48 | +`sh train.sh <faster_rcnn | ssd_inception | ssd_mobilene>` |
96 | 49 |
|
97 |
| -#### Saving for Inference |
98 |
| - |
99 |
| -`python object_detection/export_inference_graph.py --pipeline_config_path=config/ssd_inception-traffic_udacity_real.config --trained_checkpoint_prefix=data/real_training_data/model.ckpt-10000 --output_directory=frozen_models/frozen_real_inception/` |
| 50 | +#### Saving Weights for Inference |
100 | 51 |
|
| 52 | +`sh freeze.sh <faster_rcnn | ssd_inception | ssd_mobilene> <model checkpoint version num>` |
101 | 53 | ---
|
102 | 54 |
|
103 |
| -## Using MobileNet SSD v1 |
104 |
| -(Due to some unknown reasons the model gets trained but does not save for inference. Ignoring this for now.) |
105 |
| - |
106 |
| -### For Simulator Data |
107 |
| - |
108 |
| -#### Training |
109 |
| - |
110 |
| -`python object_detection/train.py --pipeline_config_path=config/ssd_mobilenet-traffic-udacity_sim.config --train_dir=data/sim_training_data/sim_data_capture` |
111 |
| - |
112 |
| -#### Saving for Inference |
113 |
| - |
114 |
| -`python object_detection/export_inference_graph.py --pipeline_config_path=config/ssd_mobilenet-traffic-udacity_sim.config --trained_checkpoint_prefix=data/sim_training_data/sim_data_capture/model.ckpt-5000 --output_directory=frozen_models/frozen_sim_mobile/` |
115 |
| - |
116 |
| - |
117 |
| -### For Real Data |
118 |
| - |
119 |
| -#### Training |
120 |
| - |
121 |
| -`python object_detection/train.py --pipeline_config_path=config/ssd_mobilenet-traffic_udacity_real.config --train_dir=data/real_training_data` |
122 |
| - |
123 |
| -#### Saving for Inference |
124 |
| - |
125 |
| -`python object_detection/export_inference_graph.py --pipeline_config_path=config/ssd_mobilenet-traffic_udacity_real.config --trained_checkpoint_prefix=data/real_training_data/model.ckpt-10000 --output_directory=frozen_models/frozen_real_mobile/` |
126 |
| - |
127 |
| ---- |
128 | 55 |
|
129 | 56 | **Inference results can be viewed using the TrafficLightDetection-Inference.ipynb or .html files.**
|
130 | 57 |
|
131 | 58 | ### Camera Image and Model's Detections
|
132 | 59 | ![alt-text][left0000]
|
133 | 60 | ![alt-text][real0000]
|
134 |
| - |
135 |
| -![alt-text][left0140] |
136 |
| -![alt-text][real0140] |
137 |
| - |
138 |
| -![alt-text][left0701] |
139 |
| -![alt-text][real0701] |
140 |
| - |
141 |
| -![alt-text][left0003] |
142 |
| -![alt-text][sim0003] |
143 |
| - |
144 |
| -![alt-text][left0011] |
145 |
| -![alt-text][sim0011] |
146 |
| - |
147 |
| -![alt-text][left0027] |
148 |
| -![alt-text][sim0027] |
149 |
| - |
150 |
| ---- |
151 |
| - |
152 |
| -#### Some useful links |
153 |
| - |
154 |
| -- [Uploading/Downloading files between AWS and GoogleDrive](http://olivermarshall.net/how-to-upload-a-file-to-google-drive-from-the-command-line/) |
155 |
| - |
156 |
| -- [Using Jupyter notebooks with AWS](https://medium.com/towards-data-science/setting-up-and-using-jupyter-notebooks-on-aws-61a9648db6c5) |
0 commit comments