The project shows, tutorial for NVIDIA's Transfer Learning Toolkit (TLT) + DeepStream (DS) SDK ie training and inference flow for detecting faces with mask and without mask on Jetson Platform.
By the end of this project; you will be able to build DeepStream app on Jetson platform to detect faces with mask and without mask.
Note: We do not use all the images from MAFA and WiderFace. Combining we will use about 6000 faces each with and without mask
Install dependencies and Docker Container
docker pull nvcr.io/nvidia/tlt-streamanalytics:v2.0_py3
docker run --gpus all -it -v "/path/to/dir/on/host":"/path/to/dir/in/docker" \
-p 8888:8888 nvcr.io/nvidia/tlt-streamanalytics:v2.0_py3 /bin/bash
git clone https://github.com/NVIDIA-AI-IOT/face-mask-detection.git
cd face-mask-detection
python3 -m pip install -r requirements.txt
Prepare input data set (On training machine)
Convert data set to KITTI format
cd face-mask-detection
python3 data2kitti.py --kaggle-dataset-path <kaggle dataset absolute directory path> \
--mafa-dataset-path <mafa dataset absolute directory path> \
--fddb-dataset-path < FDDB dataset absolute directory path> \
--widerface-dataset-path <widerface dataset absolute directory path> \
--kitti-base-path < Out directory for storing KITTI formatted annotations > \
--category-limit < Category Limit for Masked and No-Mask Faces > \
--tlt-input-dims_width < tlt input width > \
--tlt-input-dims_height <tlt input height > \
--train < for generating training dataset >
You will see following output log:
Kaggle Dataset: Total Mask faces: 4154 and No-Mask faces:790
Total Mask Labelled:4154 and No-Mask Labelled:790
MAFA Dataset: Total Mask faces: 1846 and No-Mask faces:232
Total Mask Labelled:6000 and No-Mask Labelled:1022
FDDB Dataset: Mask Labelled:0 and No-Mask Labelled:2845
Total Mask Labelled:6000 and No-Mask Labelled:3867
WideFace: Total Mask Labelled:0 and No-Mask Labelled:2134
----------------------------
Final: Total Mask Labelled:6000
Total No-Mask Labelled:6001
----------------------------
Note: You might get warnings; you can safely ignore it
Perform training using TLT training flow
Perform inference using DeepStream SDK on Jetson
/ds_configs/*
$vi config_infer_primary_masknet.txt
tlt-encoded-model, labelfile-path, model-engine-file, int8-calib-file
classifier-threshold, class-attrs
deepstream_config
files:
$ vi deepstream_app_source1_masknet.txt
model-engine-file, config-file
under primary-gie
$deepstream-app -c deepstream_app_source1_video_masknet_gpu.txt
deepstream_app_source1__camera_masknet_gpu.txt
deepstream_app_source1_video_masknet_gpu.txt
Note:
model-engine-file
is generated at first run; once done you can locate it in same directory as .etlt
model-engine-file
before first run; use tlt-converterPruned | mAP (Mask/No-Mask) (%) |
Inference Evaluations on Nano | Inference Evaluations on Xavier NX | Inference Evaluations on Xavier | ||
GPU (FPS) |
GPU (FPS) |
DLA (FPS) |
GPU (FPS) |
DLA (FPS) |
||
No | 86.12 (87.59, 84.65) | 6.5 | 125.36 | 30.31 | 269.04 | 61.96 |
Yes (12%**) | 85.50 (86.72, 84.27) | 21.25 | 279 | 116.2 | 508.32 | 155.5 |