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 |
---|---|
Image credits to Verywell Fit.
- Install MMDetection as outlined in this tutorial.
- Install
tqdm
in the virtual environment used to install MMDetection. - Clone this repository.
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.
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'.
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'.
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.