Aymen016 / Emotion-Recognition-Using-Face-Detection

A deep learning-based project that detects human faces and predicts their emotions in real-time using OpenCV and a trained neural network model.

Repository from Github https://github.comAymen016/Emotion-Recognition-Using-Face-DetectionRepository from Github https://github.comAymen016/Emotion-Recognition-Using-Face-Detection

🎭 Emotion Recognition Using Face Detection πŸ€–

A deep learning-based project for recognizing emotions through facial expressions in real-time! This project leverages OpenCV for face detection and a trained deep learning model for emotion classification. Perfect for exploring AI applications in human emotion analysis!

Untitled design (2)


πŸš€ Features

  • Real-Time Face Detection: Detect faces from a live webcam feed using OpenCV's Haar Cascade Classifier.πŸ“Ή
  • Emotion Prediction: Recognize emotions such as Happy, Sad, Angry, Neutral, and more using a trained convolutional neural network (CNN).πŸ˜„ 😒 😑 😐
  • Efficient Preprocessing: Grayscale conversion, normalization, and resizing for optimal model input.πŸ”„
  • Interactive Output: Display detected faces and their predicted emotions directly on the webcam feed.πŸ’‘
  • Flask Web App: A web interface to interact with the emotion recognition model, providing a user-friendly way to test real-time emotion detection.🌐

πŸ“‚ Repository Structure

Emotion-Recognition-Using-Face-Detection/
β”œβ”€β”€ data/                             # Dataset folder
β”œβ”€β”€ static/                           # Static files (CSS, JS, etc.)
β”œβ”€β”€ templates/                        # HTML templates for Flask app
β”œβ”€β”€ uploads/                          # Uploaded files for processing
β”œβ”€β”€ runtime_emotion_detection.py      # Script for real-time detection
β”œβ”€β”€ model.py                          # Training and model definition
β”œβ”€β”€ my_model.h5                       # Pre-trained model
β”œβ”€β”€ haarcascade_frontalface_default.xml  # Haar Cascade file
β”œβ”€β”€ app.py                            # Main Flask app
β”œβ”€β”€ README.md                         # Project documentation
└── requirements.txt                  # Dependencies for the project

πŸ› οΈ Tools and Technologies

  • Programming Language: Python 🐍
  • Deep Learning Framework: TensorFlow/Keras
  • Computer Vision Library: OpenCV
  • Numerical Computing: NumPy
  • Visualization: Matplotlib (optional)
  • Face Detection: Haar Cascade Classifier

πŸ’» Installation and Setup

  1. Clone the Repository:

    git clone https://github.com/yourusername/Emotion-Recognition-Using-Face-Detection.git
    cd Emotion-Recognition-Using-Face-Detection
    
  2. Install Dependencies:
    Install the required libraries using pip:

    pip install -r requirements.txt
  3. Download Haar Cascade File: Ensure the haarcascade_frontalface_default.xml file is in the project directory. If not, download it from the [OpenCV GitHub repository] (https://github.com/opencv/opencv/tree/master/data/haarcascades).

  4. Run the Application: Start the real-time emotion recognition script:

  python real_time_emotion.py

πŸ“Š Model Overview

The emotion recognition model is a Convolutional Neural Network (CNN) trained on a dataset of facial expressions. It processes grayscale images resized to 48x48 pixels for efficient and accurate emotion classification.

Predicted Emotions:

  • Happy 😊
  • Sad 😒
  • Angry 😑
  • Neutral 😐
  • Surprise 😲

Model Accuracy:

The model achieves an accuracy of 75% on the FER-2013 test dataset. While this provides a solid foundation for recognizing emotions from facial expressions, there's room for improvement. We aim to fine-tune the model for better real-world performance.


🎯 Future Enhancements

  • ✨ Add More Emotions: Train the model to recognize additional emotions like Fear, Disgust, etc.
  • πŸ”§ Improve Accuracy: Fine-tune the model for better real-world performance.
  • πŸ‘₯ Multi-Face Detection: Extend the application to predict emotions for multiple faces simultaneously.
  • 🌐 Web Integration: Create a web-based interface for wider accessibility.

🧠 Dataset Used

The model was trained using the FER-2013 dataset, which contains labeled facial expressions.
Learn more about the dataset here.


πŸ“Έ Demo

Real-Time Emotion Detection in Action

The image taken: Screenshot 2024-11-27 222705

After emotion detection: Screenshot 2024-11-27 222626


πŸ“Έ Demo - Flask Web App

Real-Time Emotion Detection through the Flask interface

The web app interface: Screenshot 2024-12-02 012110 WhatsApp Image 2024-12-03 at 11 38 05 PM Screenshot 2024-12-02 022122 Screenshot 2024-12-02 022150


🀝 Contributions

Contributions are welcome! Feel free to fork the repository and submit pull requests with improvements, bug fixes, or new features.


πŸ‘¨β€πŸ’» About the Author

Aymen Baig
A passionate developer and aspiring Data Scientist specializing in Machine Learning and Natural Language Processing. Experienced in building lightweight and efficient chatbot systems for small businesses. Always open to collaborations and learning new technologies.

About

A deep learning-based project that detects human faces and predicts their emotions in real-time using OpenCV and a trained neural network model.

License:MIT License


Languages

Language:HTML 59.8%Language:Python 37.1%Language:CSS 1.6%Language:JavaScript 1.5%