Step by Step TensorFlow Object Detection API Tutorial — Part 3: Creating Your Own Dataset

Daniel Stang
2 min readOct 8, 2017

--

At this point you have selected a pre-trained model and adapted an existing dataset into a single TFRecord file. However, what if the dataset you found doesn’t quite match the situation you’ll use your object detection model in and you want the best performance possible? Or maybe you weren’t able to find any good datasets to use? Then the next step would be to create your own dataset.

Throughout this tutorial I’ve been building an object detection model that will be able to determine the state of a traffic light. The pre-trained model I started with only determined if there was a traffic light in the image and couldn’t determine if the light was green, yellow, or red. I then found the Bosch Small Traffic Lights Dataset which seemed perfect for my needs. However after training my model on the Bosch Dataset, the performance in the exact environment I wished to use it in (shown below) was good but not great. Thus I decided to create my own dataset so I could squeeze that last bit of performance out of my model.

Left: Udacity Test Track for Self-Driving Car Nanodegree. Right: Bosch Small Traffic Light Dataset.

LabelImg

LabelImg is a tool that makes it very easy to annotate images. There are plenty of other tools you can choose from but LabelImg seems to be one of the most popular and for good reason!

To install it, open a terminal window and

git clone https://github.com/tzutalin/labelImg.git

Once it’s downloaded follow the installation instructions for your version of Python. For Python 3 this is (ensure you are in the folder you just cloned):

sudo apt-get install pyqt5-dev-tools
sudo pip3 install lxml
make qt5py3

To start the program

python labelImg.py

Once you are in, it’s pretty straight forward to use. Just open a directory of images you wish to annotate, select a save directory, and begin annotating!

Note that LabelImg saves the annotations in the same format as the PASCAL VOC dataset. As mentioned in the previous post, this means that TensorFlow has already provided a way to easily generate a TFRecord file based on this format.

At this point we have a pre-trained model and two datasets, next post I’ll show you how to start training!

--

--