Performs real-time face-based image prediction on gender, age, and facial expression with Neural Networks.
Gender, age, and facial expression prediction are the critical areas of various real-world applications, such as face recognition applications, discovery about a specific person, and an indication of an individual's intentions within a situation. This project used Deep Convolutional Neural Network such as ResNet50 and modified VGG-16 models for training.
OpenCV | Tensorflow | Numpy | Time | Random |
---|
Install the required packages by executing the following command.
$ pip install -r requirements.txt
- main.py : main program to execute real-time webcam face prediction
- model:
- Gender_model.h5 : deep learning model to classify gender
- Age_model.h5 : deep learning model to estimate age
- Emotion_model.h5 : deep learning model to predict facial expression (Due to large size of files, download it from this drive)
- haarcascade_frontalface_default.xml : detect face bounds
Available at : this drive link
This folder includes training data, trained models, and colab notebook from preprocessed data until deploy models from scratch.
- Download prerequisites; the procedure is in Dependencies section
- Run main.py in IDE (for alternative, you can run in the cloud with colab notebook that is listed on Deploy demo (alternative choice) section)
- After the webcam has turned on. On the left upper side, it shows the fps speed of your webcam
- It will detect your face and predict your gender, age, and facial expression. There are also some additional dummy features.
- For alternatives, you can execute it on a cloud (google colab) here
- Execute Preparation section
- Choose which type to execute the demo (Webcam image/video)
- Input your name and execute it
- The webcam should turn on by the time
- If modules cannot be imported after being downloaded, try clicking Ctrl+Shift+P -> Select python interpreter -> Change to recommended, and restart the IDE
- If the TensorFlow package cannot be downloaded, try to enable long paths. Open the procedures in this link. In case of long path does not exist, try to enable it with this link
- On main.py, if the webcam does not work, try changing
cap = cv2.VideoCapture(0)
on line 89 with different numbers like -1 or 1 or 2 instead of 0. Moreover, make sure to allow webcam permissions on the IDE you used.