Object Detection and Background removal with Detectron2

Low Y S
2 min readMay 22, 2021

--

Removal of background is a common step of pre-processing for images prior to feature extraction to reduce noise reduction. Machine learning techniques are able to substitute traditional techniques such as thresholding. It also serves as a reliable method to remove background of images regardless of lighting or angle of image. The post provides a step-by-step process of utilizing Facebook’s Detectron2 to remove background of images.

References: https://github.com/facebookresearch/detectron2

This is a series of Medium posts made by 4 NUS SCALE master students (MSc. in Industry 4.0) who are taking ISY5004 Intelligent Sensing Systems. Here’s a snapshot of what we’ll be sharing:

Step 1: Install required modules

Step 2: Run pre-trained detectron2 model (COCO dataset)

Pick an image of interest which background is to be removed.

A detectron2 config and a detectron2 DefaultPredictor will then be use to run inference on the image above.

Access the outputs

The ‘Visualizer’ function is used to draw the identified objects in the image.

Step 4a : Utilize mask from outputs to remove background of images

One of theimages with background removed

Step 4b: Cropping detected object without background

Cropped image without background

After obtaining the cropped images without background, it can now be passed into a model for it to search for similar furniture matches. The following link details how my group member had utilized deep learning models as a feature extractor to look for similar furnitures.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Low Y S
Low Y S

Written by Low Y S

Digital enthusiast exploring developments in AI and automations.

No responses yet

Write a response