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.
- 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
You can train your model, just build your database and do the training on it.
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.
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.