This project implements a Real-Time Facial Emotion Recognition System using a Convolutional Neural Network (CNN). The system detects human faces from a webcam feed and predicts emotions such as Happy, Sad, Fear, Angry, Neutral, Disgust, and Surprise.
The project demonstrates concepts from Design and Analysis of Algorithms (DAA) , Signals processing and Machine Learning, focusing on optimization, computational efficiency, and deep learning-based image classification.
- To design an efficient algorithm capable of recognizing emotions from facial expressions.
- To apply CNN-based feature extraction and classification techniques.
- To perform real-time emotion detection using a webcam.
- To analyze performance using accuracy and loss metrics.
- Data Preprocessing
- Convert images to grayscale.
- Resize images to 48×48 pixels.
- Normalize pixel values.
- Model Design
- Convolutional Neural Network (CNN)
- Batch Normalization and Dropout layers
- Softmax classification layer.
- Training
- Optimizer: Adam
- Loss Function: Categorical Crossentropy
- Early Stopping & Learning Rate Scheduling used for optimization.
- Real-Time Detection
- Face detection using Haar Cascade.
- Emotion prediction using trained CNN model.
- Python
- TensorFlow / Keras
- OpenCV
- NumPy
- Matplotlib
- Training Accuracy: ~83%
- Validation Accuracy: ~66%
- Optimized using adaptive learning rate and early stopping.
- Human--Computer Interaction
- Mental health monitoring
- Smart classroom engagement systems
- Driver fatigue detection
- AI assistants and robotics
EmotionDetection/
│
├── training_notebook.ipynb
├── realtimedetection.py
├── final_emotion_model.keras
├── images/
└── README.md
- Install dependencies:
pip install --r requirements.py
pip install -tensorflow -opencv-python -numpy -matplotlib -sckit learn
- Run real-time detection:
python realtimedetection.py
- Press ESC to exit webcam.
The system applies: - Convolution operations for feature extraction. - Iterative optimization using gradient descent. - Adaptive stopping criteria for efficient convergence.
Time complexity primarily depends on convolution operations:
O(L × n²)
where L = number of layers and n = image dimension.
The proposed CNN model successfully classifies facial emotions in real time with stable convergence and good generalization performance.
Model Accuracy:
Model Loss Vs Epochs:
Niveditha Venkatesh\
MIT Licence