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:
- Web scrapping, feature extraction using CNN, and image searching.
- Object detection using YOLOv3.
- Object detection and background removal using Detectron2.
- Further improvement using various CNN models.
- Telegram bot and hosting on cloud.
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

Step 4b: Cropping detected object 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.