Real-Time Object detection API using Tensorflow and OpenCV

Daniel Ajisafe

Daniel Ajisafe

Lagos, Lagos

1 1
  • 0 Collaborators

The amount of visual data in the world today has grown exponentially in the last couple of years and this is largely due to lots of sensors everywhere. Building machine learning models that are capable of localizing and identifying objects in a single image remains a core challenge in computer vision. This API detects objects in an image and also performs real time object detection. Additionally, it can also be trained on a new dataset. ...learn more

Project status: Concept

Artificial Intelligence

Code Samples [1]

Overview / Usage

I discovered Google just released an object detection API. The API has been trained on Microsoft COCO dataset { A dataset of about 300,000 images of 90 commonly found objects} with different trainable detection models .
Selection of trainable detection models, including:

-Single Shot Multibox Detector (SSD) with MobileNet,
-SSD with Inception V2,
-Region-Based Fully Convolutional Networks (R-FCN) with Resnet 101,
-Faster RCNN with Resnet 101,
-Faster RCNN with Inception Resnet v2

The higher the mAp (minimum average precision), the better the model.

Methodology / Approach

I started by cloning the Tensorflow object detection repository on github. The API is an open source framework built on tensorflow making it easy to construct, train and deploy object detection models.

For this project [am on windows 10, Anaconda 3, Python 3.6], I was concerned with only the installation part and following the example which included

  • Installing required libraries e.g pillow, lxml etc that comes with installing the latest version of tensorflow using pip(latest version)
    -Downloading the latest version of protobuf compatible with my system for compilation on google protobuf releases
    -Cloning the tensorflow/models folder as a zip file
    -On my Anaconda prompt, ran this command for protobuf compilation without which the example wont work.
From tensorflow/models/research/

protoc object_detection/protos/*.proto --python_out=.

I preferred using Spyder as my editor so i made a copy of the notebook in the example and converted it to a python file. Using the pre-trained ssd_mobilenet_v1_coco model (which was fast, though had the least accuracy), I decided to test it out on my own images and the results were amazing !

Trick: test images were taken with my mobile phone and a digital camera. Resizing their dimensions helped the model’s detection. Since i also wanted real-time detection, i installed OpenCV to connect with my webcam.
And this was the result :
https://cdn-images-1.medium.com/max/600/1*J4rMK9ffat-gFKBwyN4_8Q.gif

Technologies Used

Windows 10,
Anaconda 3,
Python 3.6,
Protobuf 2.6
Python-tk
Pillow 1.0
lxml
OpenCV
tensorflow

Repository

https://github.com/am-sirdaniel/Real-Time-Object-detection-API

Comments (1)