Face emotion recognition using convolutional neural networks
Aim of this project was to create a simple library to recognize one of 7 emotions (anger, contempt, disgust, fear, happy, sadness, surprise) of the person on the image using either pre-trained network by us or train it by yourself firstly.
As base algorithm for this project Convolutional Neural Networks have been used (modification of LeNet architecture, with dropout technique).
In order to use pre-trained network you can load saved network
network = nt.build_cnn('models/model.npz')
load image
faces = net_training.load_img("images/anger.jpg")
and evaluate this image with a given network
tab = net_training.evaluate(network, faces)
Optionally, if you want to train network by yourself you need to create a certain folder structure:
- Data
- Images
- 1 -- photo1.jpg -- photo2.jpg
- 2 -- photo1.jpg -- ...
- ...
- Labels
- 1 -- label.txt
- 2 -- label.txt
- ...
- Images
and execute function to train by providing specified paths
net_training.train_net(datadir, imagedir, labeldir, network)
anger = 100.00%
contempt = 0.00%
disgust = 0.00%
fear = 0.00%
happy = 0.00%
sadness = 0.00%
surprise = 0.00%
anger = 0.49%
contempt = 0.02%
disgust = 97.62%
fear = 1.47%
happy = 0.00%
sadness = 0.40%
surprise = 0.00%
anger = 0.00%
contempt = 0.00%
disgust = 0.00%
fear = 0.00%
happy = 0.00%
sadness = 0.08%
surprise = 99.92%
anger = 0.00%
contempt = 0.00%
disgust = 14.98%
fear = 0.00%
happy = 0.00%
sadness = 85.02%
surprise = 0.00%