A PHP Error was encountered

Severity: Warning

Message: fopen(/tmp/ci_sessionlrq9fseugsdhuclnvl5dun47svthfb7m): failed to open stream: No space left on device

Filename: drivers/Session_files_driver.php

Line Number: 176

Backtrace:

File: /var/www/html/application/controllers/Project.php
Line: 10
Function: __construct

File: /var/www/html/index.php
Line: 311
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: session_start(): Failed to read session data: user (path: /tmp)

Filename: Session/Session.php

Line Number: 143

Backtrace:

File: /var/www/html/application/controllers/Project.php
Line: 10
Function: __construct

File: /var/www/html/index.php
Line: 311
Function: require_once

Emotion Recognition in Python using OpenCV and TensorFlow | Prackash
Coders Packet

Emotion Recognition in Python using OpenCV and TensorFlow

By Divya Prackash Ravi

This Python code uses the webcam of the device to scan and analyze what kind of emotion the person is in right now.

This packet uses NumPy, TensorFlow, Matplotlib, and OpenCV library to work.

Download the libraries above using the following commands.

pip install numpy.

pip install opencv-python.

pip install matplotlib.

pip install tensorflow.

(note TensorFlow installation doesn't work well with Python version 3.9, use Python version 3.8 for this code)

For the dataset, you can download the original pixel data in CSV format in https://www.kaggle.com/deadskull7/fer2013.

After downloading the dataset store it in the same folder as the code.

For training the model, navigate to the current directory in the command line and enter the following command.

python emotions.py --mode train.

This will train the model and then you could run the prediction, alternatively if you have already trained it once you can then use the following command to run without training again.

python emotions.py --mode display.

With a simple 4-layer CNN model, the test accuracy could reach up to 63% in 50 epochs.

Algorithm used:

The haar cascade method is used to detect the faces in every frame of the webcam feed and the region of the image containing the face is then resized to 48x48 and is then passed as input to the CNN.

The network outputs a list of softmax scores for seven different classes of emotions and the emotion with the highest score is then displayed on the screen.

 

Download Complete Code

Comments

No comments yet

Download Packet

Reviews Report

Submitted by Divya Prackash Ravi (Prackash)

Download packets of source code on Coders Packet