This sub project folder holds our data, data wrangling, and machine learning models for Masky.
One contentious topic today in social media and playing out in our culture is the wearing of masks. We wanted to tackle this subject as best as possible with researching the facts, data, and cultural perception in regards to the pandemic. We also had a technical question/challenge of developing a machine learning model to categorize mask wearing in images.
We went on to survey the Kaggle Competetions so see how the community was solving similar problems. After looking at past solutions, investigating how Kaggle competitions are solving the problems, and our knowledge of machine learning algorithms - we ran into a distinction between classification and detection. Categorization? Yes, after testing possible machine learning solutions - we reframed the the problem as categorization oppsed to detection.
General Machine Learning Pipeline:
- take an image
- detect if a face exists
- if so then classify that face as mask or no mask.
Greater understanding https://www.quora.com/What-are-the-different-machine-learning-algorithms-for-image-classification-and-why-is-CNN-used-the-most
The distinction between classification and detection matters in the way we approach the problem, classification algorithms:
- Artificial Neural Network
- Convolutional Neural Network
- K Nearest Neighbor (KNN)
- Decision Tree
- Support-vector Machines
But we wanted not only to classify but also detect a face within an image, so we had to narrow down the algorithms to one that would assist us in both classifying and detection. But what is detection?
One class of Deep Learning algorithm stood out, the convolutional neural network (CNN, or ConvNet). We went ahead and started to learn and understand CNN and how to use Tensorflwo Keras with it.
Keras Conv2D and Convolutional Layers was such a jump off point to understanding Convolutional Layers
Stepping back and looking at the problem and understanding the basics of Computer Vision because how do we convert our knowledge and steps of us viewing a digital image and/or video to the computer viewing the digital image and/or video.
Let us take a look at this image….. And where we got our data: Prajna Bhandary on LinkedIn: Mask classifier Face Mask Detection Dataset | Kaggle
I want to insert one image and go through the complexity of the image and how that will also push us to CNN and similar algorithms. Also I want to go over the features of image and image dataset.
EDA
ML Data Wrangling.ipynb
Image Pre-processing
ML Face Detection.ipynb
Image files of faces with and without face mask.
data folder has four sub folders that house the image data we are using to train the model & using to test the model's predictions.
- processed has all the model images in two categories.
- external has completely septate images to test the finished model against.
OpenCV provides the CascadeClassifier class that can be used to create a cascade classifier for face detection. The constructor can take a filename as an argument that specifies the XML file for a pre-trained model.
OpenCV provides a number of pre-trained models as part of the installation. These are available on your system and are also available on the OpenCV GitHub project.
Download a pre-trained model for frontal face detection from the OpenCV GitHub project and place it in your current working directory with the filename ‘haarcascade_frontalface_default.xml‘.
BUT
MTCNN to the recuse Multi-task Cascaded Convolutional Networks (MTCNN) for Face Detection and Facial Landmark Alignment
Use a cascade classifier to detect a face in a webcam window, extract the face and pass it to a convolutional neural network to classify the image as "mask" or "no mask".
Included in our repository is our "requirements.txt" With this file in the repository, you can create the new environment by running:
python -m venv myenv
pip -r requirements.txt
- Machine Learning
- Deep Learning
- Convolutional Neural Network (CNN)
- Data Visualization
- Python 3
- numpy
- Pandas
- OpenCV
- MTCNN
- Tensorflow/Keras
- matplotlib
For a more detailed view of project tasks visit the Projects tab
A helpful checklist for the things that need to be accomplished:
- Improve the image pre-processing
- Add a proper venv and requirements file
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
- Fork this repository;
- Create your branch:
git checkout -b my-new-feature
; - Commit your changes:
git commit -m 'Add some feature'
; - Push to the branch:
git push origin my-new-feature
.
After your pull request is merged, you can safely delete your branch.
This project is licensed under the MIT License - see the LICENSE.md file for more information.