a PyTorch implementation, using MobileNetV3 and SSDLite
the model was created with mobile deployment in mind, so it can be easily deployed on any machine with a webcam, following a few simple steps:
- (optional, but recommended) create a clean Miniconda environment:
conda create --name app python=3.8 conda activate app
- install requirements:
pip install -r requirements_lite.txt
- run the app:
python app.py
- (optional) the app can also be packed into a
.exe
file usingpyinstaller
:pip install pyinstaller pyinstaller --onefile -w app.py
- an antivirus exception may be needed for the
.exe
file. - the
.exe
file should be ~270MB if using a clean Miniconda environment.
- an antivirus exception may be needed for the
for training, use the environment.yml
virtual environment:
conda env create -f environment.yml
Training is done using 2 Kaggle datasets:
- face-mask-detection by andrewmvd
- face-mask-detection-dataset by wobotintelligence
data can be downloaded manually, or using the kaggle
API:
-
install the
kaggle
package:pip install kaggle
-
create your Kaggle API key (in the Kaggle settings)
-
place your Kaggle API key
.json
file in~/.kaggle/kaggle.json
-
download and extract the data:
kaggle datasets download wobotintelligence/face-mask-detection-dataset unzip face-mask-detection-dataset.zip -d data/wobotintelligence rm face-mask-detection-dataset.zip kaggle datasets download andrewmvd/face-mask-detection unzip face-mask-detection.zip -d data/andrewmvd rm face-mask-detection.zip
training hyperparameters can be changed via the config.py
file, for training run:
python main.py
or run main.ipynb
if you preffer using a jupyter notebook.
- we use the torchvision implementation of the SSDLite-320x320 object detection model with a MobileNetV3-Large backbone:
torchvision.models.detection.ssdlite320_mobilenet_v3_large
. - we use a pretrained backbone, the object detection model is trained from scratch.