This projects detect human face emotion with input of image, video or real-time detection. We are using OpenCV to detect and crop the face, and using ResNet101/VGG19 built & trained with PyTorch to predict the face"s emotion
- Python3.6
- OpenCV
- PyTorch
To get a local copy up and running follow these simple steps.
- Clone the repo
git clone https://github.com/KTAN119/Face_Emotion_Detection
- Install required packages
pip install -r requirement.txt
The following files are required to run the program:
- Cascade file. The cascade file can be obtained from here or here
- PyTorch weight file. The weights for a trained emotion classifier is required to predict the faces" emotions. This file is not provided due to the large file size.
- To Detect Image
python emotion_detection.py --input_type "image" --img_file INPUT_IMAGE_FILE_PATH --output_image_directory OUTPUT_IMAGE_DIRECTORY_PATH --weight RESNET101_WEIGHT_PATH --cascade_file CASCADE_FILE_PATH
- To Detect Video
python emotion_detection.py --input_type "video" --video_file INPUT_VIDEO_FILE_PATH --output_video_directory OUTPUT_VIDEO_DIRECTORY_PATH --weight RESNET101_WEIGHT_PATH --cascade_file CASCADE_FILE_PATH
- Real-time Detection
python emotion_detection.py --input_type "real-time" --weight RESNET101_WEIGHT_PATH --cascade_file CASCADE_FILE_PATH
Done by Tan Kim Wai and Melvin Kok
Sample image from Jesse Burke Sample video from here