Skip to content

(Computer Vision - Object Detection) Facemask detection Streamlit app using BigML API to generate Predictions.

License

Notifications You must be signed in to change notification settings

pkhiev/BigML_facemask_detector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Face Mask Detection in Images utilizing BigML API

This facemask detector application leverages a neural network to perform object detection using the BigML API to determine whether people in an image are 1) Wearing a mask, 2) Not wearing a mask, or 3) Wearing a mask incorrectly.

app screenshot

Data source

The data was obtained from a public face mask detection dataset on Kaggle . The data contains 853 images pre-labeled with 3 object classes: with_mask, without_mask, and mask_weared_incorrect. Each image has a corresponding XML file with bounding boxes listed in PASCAL VOC format.

fig1

Figure 1. An example image from the dataset with bounding boxes around object labels.

BigML accepts object labels in JSON format, so the bounding box labels were converted from individual XML files into a single JSON document.

Preprocessing/Augmentations

The data set was divided into an 80/20 train/test split. The training images were resized to 640x640 to homogenize the data and to reduce model training time. The images were resized without maintaining aspect ratio to introduce more variation when training the model. This resized dataset was used to train the final model used in this project.

Additional models were generated using augmented data sets generated by applying different combinations of the following augmentations to the original data. However, utilizing augmented images as training data caused the model performance to be worse so they were excluded when training the final model:

Rotation: Between -10° and +10° Shear: ±5° Horizontal, ±5° Vertical Blur: Up to 2.5px

Object detector Model Training

The augmented image data and labels were uploaded to BigML as a composite source and a dataset was generated. A Deepnet (BigML’s optimized version of a deep neural network) classifier was trained on the training split using the Adam Gradient Descent Optimization Algorithm.

fig2

Figure 2. Screenshot of overall model performance.

The classifier was then evaluated using the test split. Figures 3 and 4 are screenshots showing an example ROC curve and a summary of the model evaluation using the test split data, respectively.

fig3

Figure 3. A screenshot of the ROC curve and model performance for detection of people wearing masks.

fig4

Figure 4. A summary of the models overall performance with generating predictions using the test split data.

Object detection web application

The application was deployed on the streamlit.io cloud from this GitHub repository. This application is powered using the BigML api to generate object detection predictions. This web application allows users to upload an image and have any detections displayed. Alternatively, a user can choose to use one of many example images.

fig5

Figure 5. The Face Mask Detection web application, deployed on streamlit.io cloud.

fig6

Figure 6. A sample output of mask detections from the application.

This blog post was used as a template for streamlit.io application.

About

(Computer Vision - Object Detection) Facemask detection Streamlit app using BigML API to generate Predictions.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages