This project is a deep learning-based Emotion Recognition System that identifies emotions from grayscale images. It classifies images into one of seven possible emotions:
- Angry
- Disgust
- Fear
- Happy
- Neutral
- Sad
- Surprise
The model is built using a Convolutional Neural Network (CNN) and the user can interact with it using a simple Streamlit web application.
- Image Upload: Upload any image to predict the emotion.
- Real-Time Prediction: The app processes and predicts emotions instantly.
- Seven Emotion Classes: The model is trained to recognize the following seven emotions.
- Interactive Web App: Streamlit-based web app for a simple and user-friendly experience.
├── streamlit_app.py # Streamlit app for image upload and emotion prediction
├── emotion_cnn_model_v2.h5 # Pre-trained model file
├── README.md # Project documentation
visit:https://emotiontracer-gcnunrfu2dm9ybualqdthn.streamlit.app/
-
Run the Streamlit App
streamlit run streamlit_app.py
-
Upload an Image
- Click the "Upload an image" button and choose an image file (JPG, JPEG, or PNG).
-
View the Results
- The app will predict the emotion in the image and display the emotion name and confidence score.
-
Image Preprocessing
- Converts the image to grayscale.
- Resizes the image to 48x48 pixels.
- Normalizes pixel values to the range [0, 1].
-
Prediction
- The pre-trained CNN model predicts the probability of each of the seven emotions.
- The emotion with the highest probability is selected as the predicted emotion.
- Python: Core programming language.
- TensorFlow/Keras: Used to create and train the CNN model.
- Streamlit: For building the interactive web application.
- Pillow (PIL): For image processing.
Install the following packages:
- streamlit
- tensorflow
- numpy
- pillow
- Input: Grayscale images of size 48x48
- Architecture: Convolutional Neural Network (CNN) with multiple Conv2D, MaxPooling, BatchNormalization, and Dropout layers.
- Classes: 7 emotion classes: Angry, Disgust, Fear, Happy, Neutral, Sad, and Surprise.
The model achieved a Test Accuracy: 51.10%.
Below is the confusion matrix showcasing the model's performance:
These are examples of images where the model correctly identified the emotion Angry:
These are examples of images where the model misclassified the emotion Angry as other emotions:
- The confusion matrix shows that Angry is frequently confused with Surprise and Happy, suggesting overlap in visual cues for these emotions.
- Despite these misclassifications, the model performs well for most images.
- In defence of poor accuracy i can say proudly say I myself would have made the same mistakes.
The dataset used for training and evaluation can be found here: FER2013 on Kaggle
Feel free to contact me regarding any improvements, issues and errors. Happy Coding.