I am very excited to show you how to detect the Object in the image by yourself using the pre-trained Tensorflow object detection Deep Learning model.

If you are entering into the Deep Learning object detection, then this post will very helpful.

TensorFlow is a Deep Learning numerical library developed by Google. And the TensorFlow team offering the pre-trained object detection model. So I am going to check and execute the model on my Mac OS.

No prior knowledge of TensorFlow is required for this tutorial. Becuase, Here I am not going to explain how to create your own object detection model. I just simply exploring the pre-trained TensorFlow object detection model and will execute the model.

My Output from the TensorFlow Object Detection pre-trained model:

Detecting Robot(Enthiran in Tamil) movie robot as Person:-)


Detecting IronMan Suit as Person:-)


 

Enough theory. I usually directly jump into the code instead of reading more, not all time:-). So let's do the object detection model.

Step1:

Python software is required. So download and install the latest python using the below link.

https://www.python.org/downloads/

I used Python 3(At the time of writing this tutorial).

Step2:

To install other python libraries we need pip. 

To check whether you have installed the pip or not using

pip --version

If the above command shows some version, you have installed the pip already.

If you have not installed pip, then download the pip using

https://bootstrap.pypa.io/get-pip.py

Save the file and run below command in the terminal.

python get-pip.py

To know more about pip use the below link.

https://pip.pypa.io/en/stable/installing/

Step3:
Download the object detection model from GitHub using 

https://github.com/tensorflow/models

I downloaded this file to my Desktop/oddl folder. Extract the file and rename it to models.

Step4:

The Tensorflow Object Detection API uses Protobufs to configure model and training parameters. Download the proto using

https://github.com/google/protobuf/releases/

or 

https://github.com/google/protobuf/releases/download/v3.5.1/protoc-3.5.1-osx-x86_64.zip


I downloaded this file to my Desktop/oddl folder. Extract the file and rename it to protoc.

Step5: 

Add the proto to the path using the below command.

export PATH=$PATH:/Users/ampersandacademy/Desktop/oddl/protoc/bin

Get protoc version using

protoc --version

Step6:

Tensorflow Object Detection API depends on the following libraries:

Protobuf 2.6
Pillow 1.0
lxml
tf Slim (which is included in the "tensorflow/models/research/" checkout)
Jupyter notebook
Matplotlib
Tensorflow

Execute the below command one by one on your terminal to install the necessary libraries.

pip install tensorflow
sudo pip install pillow
sudo pip install lxml
sudo pip install jupyter
sudo pip install matplotlib


Step7:

Before the framework can be used, the Protobuf libraries must be compiled. This should be done by running the following command from the tensorflow/models/research/ directory:

cd models/research/
protoc object_detection/protos/*.proto --python_out=.

Step8:

Run the model using the below command.

cd object_detection/
jupyter notebook

Step9:

The Jupyter will open in the browser. Click the object_detection_tutorial.ipynp file.

Step10:

Click the Run All and wait for few seconds to see the output.

The output will be like this.


Expected Problems:

Probelem1: 

If your Jupyter Notebook asks the password and you don't know, then rest the password. 

Reset Jupyter Notebook password using the below command on terminal.

jupyter notebook password

Problem2:

If you are not using the TensorFlow version 1.4 then it will raise an exception and will stop the execution.


So remove the version checking command from the above code.

Or upgrade the TensorFlow to latest version using

pip install --upgrade tensorflow

Summary:

In this tutorial, you learned, how to detect an object on the image by yourself using the TensorFlow pre-trained object detection Deep Learning model.

Software Version:
Python3
pip
TensorFlow 1.4

All the codes and demos in this tutorial are executed using the Mac OS Sierra. The same steps apply for all other platforms(Windows, Linux). However, I have not executed on other platforms.