A real-time facial expression recognition system through webcam streaming and CNN.
This project aims to recognize facial expression with CNN implemented by Keras. I also implement a real-time module which can real-time capture user's face through webcam steaming called by opencv. OpenCV cropped the face it detects from the original frames and resize the cropped images to 48x48 grayscale image, then take them as inputs of deep leanring model. Moreover, this project also provides a function to combine users' spoken content and facial expression detected by our system to generate corresponding sentences with appropriate emoticons.
fer2013 is the dataset I chose, which is anounced in Kaggle competition in 2013.
I provide my work environment for references.
CPU : i7-9750H GPU : nvidia GTX 1660ti 6G RAM : 16G
OS : Windows 10 1909
Keras 2.3.1
opencv 4.2.0
Tensorflow GPU 2.1.0
I strongly recommend you to use Anaconda
, which is a package manager and provides python virtual environment.
After you install Anaconda, you can create a virtual environment with python 3.5.4.
conda create -n env-name python=3.5.4
you can also check if your env. has been created by,
conda info --envs
You should activate your virtual environment in different way corresponding to your operating system. For example, In Ubuntu, you can activate your virtual environment by,
source activate env-name
And,
source deactivate
to exit the virtual environment.
The following instructions will lead you to install dependencies, and I suggest you to fllow the order.
Note that the version Anaconda
provided may not be the latest one.
conda install opencv
If you fail to install opencv due to python version conflicts, try this command instead,
conda install -c menpo opencv4=4.2.0
the version 4.2.0 can be replaced with the lateset one, but in this project, I use opencv 4.2.0
.
pip install tensorflow-gpu
Keras is a high-level wrapper of Theano and Tensorflow, it provides friendly APIs to manipulate several kinds of deep learning models.
pip install --upgrade keras
pandas
can help you to preprocess data if you want train your own deep learning model.
conda install pandas
h5py
is used to save weights of pre-trained models.
conda install h5py
After installing dependencies, you can move to root
directory and simply type this command,
python main.py
after running the script open the web browser and go to 0.0.0.0 and port number is 5000.
Just open the Camera.py
file and in the line
self.video = cv2.VideoCapture(0)
Replace 0
with File Directory
self.video = cv2.VideoCapture("File name")
Please give me a star if you like my project.