Skip to content

Latest commit

 

History

History
104 lines (96 loc) · 4.66 KB

README.md

File metadata and controls

104 lines (96 loc) · 4.66 KB

Face recognition- Are you wearing a mask or not?

A Machine Learning algorithm capable of identifying people who are using a mask or similar.

This project aims to apply the knowledge acquired in the artificial intelligence and computational nanodregree by FIAP.

The script presented is a supervised machine learning, where a database (in this case images) is presented, providing a reference of what is "right" and "wrong", creating a model based on this data.

To assist in the application of the model, a model ready for face detection is used, and the trained model is applied to a detected face.

Requirements

  • Python 3.8 -> Developed with version 3.8, but has not been tested in other versions.
  • Tensorflow
    pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.12.0-py3-none-any.whl
    pip install --upgrade tensorflow
  • Keras
    pip install keras
  • Numpy
    pip install numpy scipy
  • Scikit Learn
    pip install scikit-learn
  • Imutils
    pip install imutils
  • Pillow
    pip install pillow
  • h5py
    pip install h5py
  • Matplotlib
    pip install matplotlib
For development I used Anancoda and Jupyter Notebook, but use the development tools you prefer.

Dataset

Training

You can train your model, just build your database and do the training on it.

Training variables

learning_rate: Initial learning rate.

The learning rate adjusts the optimization algorithm that determines the size of the step in each iteration, adapting it so that it has the minimum of loss. The standard learning rate is 0.001, but you can do a variable learning rate throughout the learning process, read more.

training_size: Number of times the model will train with the dataset.

The amount of training can vary according to your dataset. If your dataset is very large, you maybe able to get good results by doing the training a few times. Start with a value of around 2 ~ 5% of your dataset (for 1000 samples, train 20 ~ 50 times), and check the "Training cycle (Epoch) X Loss / Accuracy" graph to see if the model has met its objectives.

batch_size: The batch size defines the number of samples that will be propagated over the network. The algorithm takes the first N samples (from the 1st to the Nª) of the training dataset and trains the network. Then, he takes the second N samples (from (N+1)ª to (2*N)ª) and trains the network again. N is the batch_size.

It is recommended to use a batch size minor that number of all samples because requires less memory. Since you train the network using fewer samples, the general training procedure requires less memory. Usually the networks train faster with mini-lots.

images_path: Path with positive and negative images for training.

Image Application

To test the trained model using an image, run the script detect-by-image.py. To use your image, change the directory in the imageExamplePath variable of the script to the image path that you are going to use.

Before running the script:

After running the script:

Camera Application