Object Detection and Segmentation using Detectron2

alpha2phi
2 min readMar 7, 2021

Python application for real time object detection and segmentation.

Photo by Cory Schadt on Unsplash

Overview

In previous article I walked through with you on using YOLOv5 for real time object detection. In this article let’s develop a Python application for real time object detection using Detectron2, which is a Facebook AI Research’s next generation software system that implements state-of-the-art object detection algorithms.

The Application

The application uses opencv-python and Detectron2 pre-trained model to capture camera images and try to detect the objects.

  • Git clone the repository.
  • Run python setup.py install
  • Install Detectron2 based on Python version and GPU availability
  • Type d2 to start the application
  • Type q to exit the application
Real Time Object Detection

The Code

OpenCV is used to capture camera images. The application captures camera images in the main process, and spawns a separate process to detect objects in the image frame.

The application should work without GPU, but for better performance you should use a GPU machine.

The image with detected objects will be displayed in a separate frame.

You can find the full listing of the code below.

Detectron2 Resources

Training a Custom Model

alpha2phi

Software engineer, Data Science and ML practitioner.

Recommended from Medium

Lists

See more recommendations