Search Here

Custom Object Training using TensorFlow Object Detection API - Part 1

Welcome to the TensorFlow Object Detection API tutorial. In this tutorial and next few coming tutorials we're going to cover how to train your custom model using TensorFlow Object Detection API to detect your custom object. To train your model in a fast manner you need GPU (Graphics Processing Unit). If you don't have GPU in your computer/system than you can use Google Colab.



Custom Object Training using TensorFlow Object Detection API

What is Colab or Colaboratory?

Colaboratory is a free Jupyter notebook environment that requires no setup and runs entirely in the cloud. With Colaboratory you can write and execute code, save and share your analyses, and access powerful computing resources, all for free from your browser.

TensorFlow Object Detection API


Before going deep into this tutorial, I want to tell you that what we are going to achieve using TensorFlow Object Detection API. So, here we are going to detect "Cavity from Teeth" from a radio graphic image of teeth. To detect cavity (object) we are going to use pre-built/pre-trained models to train our custom object. There are list of pre-built/pre-trained Object Detection Models.


  1. ssd_mobilenet_v1_coco
  2. ssd_inception_v2_coco
  3. rfcn_resnet101_coco
  4. faster_rcnn_resnet101_coco
  5. faster_rcnn_inception_resnet_v2_atrous_coco


Now its time to getting stared with our Custom Object Detection Training using TensorFlow, Below are the steps which we need to perform as a pre-requisite before training.

Now its time to getting stared with our Custom Object Detection Training using TensorFlow, Below are the steps which we need to perform as a pre-requisite before training.


  1. Download the images from google that contain your object, the minimum number of images must be 100 and the ideal limit is greater than 500.
  2. After collecting images just named the images as a readable format like (1,2,3,... or image_name_1,image_name_2.... and so on).
  3. Image annotation, to annotate images you can use LabelImg tool. The purpose of annotation is to draw a bounding box around your object or objects from full picture. The LabelImg tool will automatically create a XML file that describe your object in the picture.
  4. After annotation, we will separate our data (Images + XML) into "train" and "test" folders. For example if we have 100 images, than the separation would be 80/20 (80 percent of images for training, 20 percent of images for testing). There is no hard and fast rule for separation, you can choose any percentage.
  5. By using these separation the next step is to create TensorFlow Records (TF Records). TensorFlow Object Detection API code will create "train.record" and "test.record" files for us. In coming tutorials we will discuss how to create TF Records in details.
  6. After creating TF Records, the next step is to setup ".config" file for the model (Which we have discussed above).
  7. The next step is Training
  8. Export graph (Inference Graph) from trained model.
  9. Detect custom object using our trained model.


These are the steps which we will follow in our coming tutorial. Now its time to implement our first step.

1- Download Images of your Interest


I recommend you Google Images and Bing to collect images, by using these you can filter your searched images by size (500X500) or whatever. Remember the images are not to small or not too large in sizes. You just need 100+ images.

In the next tutorial we will annotate the downloaded images.

Post a Comment

1 Comments