AI Object Detection Using only 10 lines of code ( ImageAI)

Original article can be found here (source): Deep Learning on Medium

AI Object Detection Using only 10 lines of code ( ImageAI)

By Priyal Walpita

This blog post would discuss Object Detection using the ImageAI Library with minimal lines of code. You can set up your own deep learning network, with pre-trained Coco best model and identify objects.

Introduction

What Is Object Detection ?

Object detection is something that is synonymous with Computer Vision which represents a system that can recognize the position which location of the target object or entity within the image.

The performance of the object detection mechanism is an image with bounding boxes around the points of interest and an indicator of the class instance of a particular object.

How Object Detection Used With The ImageAI Library ?

What Is ImageAI Library ?

ImageAI is a python based library that empowers programmers, researchers and students to create Deep Learning and Computer Vision self-contained applications and systems using short and few lines of code.

You can do the same using other pure AI/ML libraries , such as Tensor Flow, OpenCV and Keras etc.. But if you’ve attempted to make an image prediction using these libraries, you’ll end up with a large amount of lines of code that will produce a mess like setup. But to solve this problem, we can used the ImageAI Library to view it in fewer lines of codes.

Code explanation

If you are planing to do this in your local machine , please set up following tools.

Required Libraries

Python : https://python.org

Tensorflow : !pip3 install tensorflow

OpenCV : !pip3 install opencv-python

Keras : !pip3 install keras

ImageAI : !pip3 install imageai — upgrade

https://gist.github.com/priyalwalpita/2232510b86c775c2c29bc7d125f813f

The first two lines of code adding required libraries.

The other section set the OS path and load the COCO best pre-trained model. The COCO best pre-trained model is based on YOLO V3 with RestNet Convolutional Neural Network.

Then the model is running to detect objects which are in the pre-trained model and detected objects are persisted in the detections object. The next two segments of code are to output relevant binding boxes(x,y coordinates with each boxes hight and width ) and the last code segment display the detected picture with bounding boxes.