https://github.com/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.
https://github.com/aymen016/emotion-recognition-using-face-detection
gpu-acceleration haar-cascade-classifier keras-tensorflow matplotlib numpy opencv python
Last synced: 3 months ago
JSON representation
A deep learning-based project that detects human faces and predicts their emotions in real-time using OpenCV and a trained neural network model.
- Host: GitHub
- URL: https://github.com/aymen016/emotion-recognition-using-face-detection
- Owner: Aymen016
- License: mit
- Created: 2024-11-26T21:15:53.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-12-24T15:15:20.000Z (6 months ago)
- Last Synced: 2025-01-26T15:28:49.335Z (5 months ago)
- Topics: gpu-acceleration, haar-cascade-classifier, keras-tensorflow, matplotlib, numpy, opencv, python
- Language: HTML
- Homepage:
- Size: 71.8 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 🎭 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!**

---
## 🚀 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
```bash
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**:
```bash
git clone https://github.com/yourusername/Emotion-Recognition-Using-Face-Detection.git
cd Emotion-Recognition-Using-Face-Detection2. **Install Dependencies**:
Install the required libraries using pip:
```bash
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:
```bash
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](https://www.kaggle.com/datasets/msambare/fer2013).---
### 📸 Demo
Real-Time Emotion Detection in Action
> The image taken:
> After emotion detection:
---
### 📸 Demo - Flask Web App
Real-Time Emotion Detection through the Flask interfaceThe web app interface:



---
### 🤝 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.- **GitHub**: [Aymen Baig](https://github.com/Aymen016/)
- **LinkedIn**: [Aymen Baig](https://www.linkedin.com/in/aymen-baig-700a06284/)