Skip to content

Human silhouette extractor using MMDetection instance segmentation models.

License

Notifications You must be signed in to change notification settings

vincentleooo/human-silhouette-extractor

Repository files navigation

Human Silhouette Extractor Using MMDetection License: MIT

This is a tool to extract silhouettes from images or videos using MMDetection through instance segmentation as opposed to the more commonly used semantic segmentation. It uses the first model shown in the SCNet page by default. Currently providing out-of-the-box support for the Decoupled Light SOLO model as well for faster performance with the caveat that the silhouettes are far less refined in the edges.

An example for images is shown below.

Original Image Silhouette
walking walking-output

Image credits to Verywell Fit.

Setup

  1. Install MMDetection as outlined in this tutorial.
  2. Install tqdm in the virtual environment used to install MMDetection.
  3. Clone this repository.

Usage

The use of the tools will mainly be through the CLI. If this is the first time running, the scripts will download the model checkpoint to the checkpoints folder.

Video Extractor

This will use video_extractor.py.

$ python video_extractor.py -h

usage: video_extractor.py [-h] [-i INPUT] [-o OUTPUT] [-m | --multiple | --no-multiple] [--threshold THRESHOLD] [--model MODEL]

Video Silhouette Extractor Using Various Instance Segmentation Models

optional arguments:
  -h, --help            show this help message and exit
  -i INPUT, --input INPUT
                        The path to the image file.
  -o OUTPUT, --output OUTPUT
                        Output path. Make sure the directory exists.
  -m, --multiple, --no-multiple
                        Toggles detecting multiple people.
  --threshold THRESHOLD
                        Threshold for inference detector. Default: 0.3.
  --model MODEL         Inference detector model choice. Default: 'scnet-r50-fpn'. Options: 'd-solo-light', 'scnet-r50-fpn'.

Image Extractor

This will use image_extractor.py.

$ python image_extractor.py

usage: image_extractor.py [-h] [-i INPUT] [-o OUTPUT] [-m | --multiple | --no-multiple] [--threshold THRESHOLD] [--model MODEL]

Image Silhouette Extractor Using Various Instance Segmentation Models

optional arguments:
  -h, --help            show this help message and exit
  -i INPUT, --input INPUT
                        The path to the image file.
  -o OUTPUT, --output OUTPUT
                        Output path. Make sure the directory exists.
  -m, --multiple, --no-multiple
                        Toggles detecting multiple people.
  --threshold THRESHOLD
                        Threshold for inference detector. Default: 0.3.
  --model MODEL         Inference detector model choice. Default: 'scnet-r50-fpn'. Options: 'd-solo-light', 'scnet-r50-fpn'.

Acknowledgement

We would like to acknowledge the MMDetection, SCNet, and SOLO team for their great work, and also the insights gained from a long-closed issue in MMDetection. Everything in the configs folder is attributed to MMDetection.

About

Human silhouette extractor using MMDetection instance segmentation models.

Topics

Resources

License

Stars

Watchers

Forks

Languages