This is a FACIAL EXPRESSION DETECTION project made using Convolutional Neural Networks and deployed using FLASK.
The CNN model is trained on approximately 27000 images that belong to seven basic facial expressions namely-
- ANGRY
- DISGUST
- FEAR
- HAPPY
- NEUTRAL
- SAD
- SURPRISE
The model was separately trained on 15 and 50 epochs respectively, achieving a maximum accuracy of 66.8 percent on validation set.
The model was trained on a GPU supported GOOGLE COLLAB NOTEBOOK as training on a simple CPU supported system was taking too much time.
The model was then deployed using FLASK framework on localhost.
The camera.py file contains the code for reading from webcam or file and for performing facial detection.The current mode is reading from a file
that can be changed to read from webcam.
It can be seen that the model misclassifes some of the expressions in the below video because of non-uniformity in the number of images available for training the model for each expression category.
The predictions along with the actual expression label in a video file can be viewed from this link:-
Link To Video
P.S
- Anyone interested in forking this project can do so. All the major requirements to run the model are provided in requirements.txt file.
- Also i would advise everyone to create a virtual environment first and install the requirements seperately in that environment.
- A GPU is a must for training as training on a cpu can take hours just for few epochs.I suggest the use of Google Collab.
- If you want to train the model locally the make sure you have the right .dll files and CUDA and CUDNN versions installed. I myself had a nightmare doing so. Also make sure the GPU drivers match the requiremnets of the tensorflow version you are using.
- I suggest Tensorflow 2.0.0 with gpu support.