Object detection using Machine Learning

Published on . Written by

Object detection using Machine Learning

Object detection is associated with computer vision and describes a system that can identify the presence of any desired body or object in an image. The output of an object detection process is an image bounded with boxes around the object we want to detect and describe the name of the object. This is one of the most powerful machine learning algorithms.


Skyfi Labs Projects
Autonomous driving cars have an embedded system that can perform object detection in real-time. For instance when the autonomous car’s system detects a human-shaped body crossing the road the car stops several feet before coming in contact with the human body.

Read more..

SLNOTE
Concepts used:

  1. Python programming language
  2. Basic understanding of Machine Learning algorithms

SLLATEST
Hardware and Software used:

  1. A suitable OS (Windows/Linux/Mac)
  2. A desktop or laptop
  3. Enough RAM to run the program without any interruption
  4. Python 3 or upwards installed on your system
Implementations:

First, install the following dependencies via pip

TensorFlow

pip3 install TensorFlow

OpenCV

pip3 install OpenCV-python

Keras

pip3 install keras

ImageAI

pip3 imageai –upgrade

Download RetinaNet file that will be used for image detection

Now when all the dependencies are installed, now create the necessary folders. For now, we need these following folders:

1. Object Detection : root folder

2. Models : pre-trained models

3. Input : stores image files on which we want to do object detection

4. Output : stores images with detected objects

  • Open your preferred text editor and create a file, for example detector.py
  • Import ObjectDetection class from ImageAI library.
  • Now create an instance of the class ObjectDetection like this – Detector = ObjectDetection()
  • Specify the path of the input image, output image and model
  • Now as we have instantiated ObjectDetection class, we can call different functions from this class. There is a functions setModelTypeAsRetinaNet(), setModelTypeAsYOLOv3() to call pre-trained models.
  • Now we will call any of these functions to call pre-trained models.
  • Now use the path setModelPath() which accepts the string which contains the path to the pre-trained model.
  • Next use the loadModel() function to load the model from the path we have used.
  • Use detectObjectFromImage() to detect the object. This function accepts two arguments. Input path and output image path. Input path is where our image is located and the output path is where the detected object is to be stored.
  • Now traverse through all items in the dictionary and you’ll get the desired detected
Conclusion:

Object detection is a fascinating field in machine learning, it is used in research purposes also. Object detection is the most common task of computer vision.  Some applications of object detection are facial recognition, this can also be used to count people for crowd statistics, also used to identify products or to check the quality of a product. Nowadays every smartphone comes with a feature that is called face unlock, object detection plays a very crucial role in this technology.


SLDYK
Kit required to develop Object detection using Machine Learning:
Technologies you will learn by working on Object detection using Machine Learning:


Any Questions?


Subscribe for more project ideas