https://github.com/yashk2000/emotion-detector
A CNN based emotion detector
https://github.com/yashk2000/emotion-detector
cnn-keras computer-vision convolutional-neural-networks emotion-detector emotion-recognition opencv-python python-3
Last synced: about 1 year ago
JSON representation
A CNN based emotion detector
- Host: GitHub
- URL: https://github.com/yashk2000/emotion-detector
- Owner: yashk2000
- Created: 2020-02-05T16:41:11.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-06-22T16:34:51.000Z (almost 6 years ago)
- Last Synced: 2025-02-08T18:09:41.420Z (over 1 year ago)
- Topics: cnn-keras, computer-vision, convolutional-neural-networks, emotion-detector, emotion-recognition, opencv-python, python-3
- Language: Python
- Size: 5.41 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Emotion-Detector
This is a CNN based emotion detector.
It can detect 6 facial expressions:
- Angry
- Disgust
- Fear
- Happy
- Sad
- Surprise
- Neutral
The CNN has been trained on the [FER2013](https://www.kaggle.com/c/challenges-in-representation-learning-facial-expression-recognition-challenge/data) dataset available on Kaggle.
# 1) Building the dataset:
To build the dataset, run `buildDataset.py` to build the dataset. Provide the path to the dataset inside the file.
```bash
python buildDataset.py
```
# 2) Training:
To train the CNN, use the `trainRecognizer.py` class. You can train the model using checkpoints. When the model seems to be overfitting or underfitting, pause the training, adjust the script and resume training from the same checkpoint.
```bash
python trainRecognizer.py --checkpoints checkpoints
```
To resume from the epoch where the training wa stopped:
```bash
python trainRecognizer.py --checkpoints checkpoints --model checkpoints/epoch_40.hdf5 --start-epoch 40
```
# 3) Testing the model:
I used the model obtained at epoch 75 for all purposes. To test the model run `testRecognizer.py`.
```bash
python test_recognizer.py --model checkpoints/epoch_75.hdf5
```
# 4) Using the model on a real time feed:
To detect emotions in a real time feed from the camera, use the `emotionDetector.py` script. In order to detect multiple faces use the `emotionDetectorMultipleFaces.py` script.
```bash
python emotionDetector.py --cascade haarcascade_frontalface_default.xml --model checkpoints/epoch_75.hdf5
python emotionDetectorMultipleFaces.py --cascade haarcascade_frontalface_default.xml --model checkpoints/epoch_75.hdf5
```
Results:

PS: I think I am a robot and therefore the only emotion I have is neutral and it's the only screenshot I was able to upload.