Built to order

Facial Emotion Detection using CNN

A deep-learning system that detects faces in real time and classifies emotions — happy, sad, angry, fear, surprise, neutral — using a CNN trained on FER2013. The Streamlit app shows live emotion labels with confidence bars, plus an analytics view of emotion distribution over a session.

AI & Machine Learning PythonMachine LearningComputer VisionDeep LearningCNNTensorFlowOpenCVStreamlitSoftware
Facial emotion detection project thumbnail showing a face detected with emotion label and confidence bars overlaid.
More project photos (3)

The problem

The Facial Emotion Detection system is a deep-learning final-year project that finds faces in a live webcam feed and classifies the emotion on each face — happy, sad, angry, fear, surprise, disgust or neutral — using a convolutional neural network trained on the FER2013 dataset (35,887 grayscale 48×48 face images). Branded EmoSense, the Streamlit application overlays live emotion labels with confidence bars on the video feed and includes an analytics view showing the distribution of emotions across a session. With a trained model, training notebooks and real-time inference all included, this is one of the most viva-friendly deep-learning projects a student can present.

This is a built-to-order project: every deliverable is prepared fresh for you — full source code, trained model, report PDF, PPT and viva Q&A — so nothing looks recycled.

SYSTEM FLOW

4 components 4 connections

Live flow
Drag to explore
100%
sensorWebcam

Captures live video frames for face detection.

Follow the working sequence

How it works

  1. The webcam frame is captured and faces are detected with OpenCV's DNN face detector.
  2. Each detected face is cropped, converted to grayscale, resized to 48×48 and normalized to match FER2013's input format.
  3. The preprocessed face is passed through the trained CNN: stacked convolution + batch-normalization + max-pooling blocks, followed by dense layers with dropout and a 7-way softmax output.
  4. The softmax probabilities become the emotion label (argmax) and the confidence bars shown in the UI.
  5. Predictions are smoothed over a short sliding window to avoid flicker between adjacent emotions.
  6. The analytics view aggregates per-session statistics — emotion distribution, dominant emotion, average confidence — rendered as charts.

Project features

  • Real-time face detection with OpenCV DNN / Haar cascade, then CNN emotion classification
  • CNN trained on FER2013: 35,887 images, 7 emotion classes, ~65–70% validation accuracy
  • Live webcam inference at 15–25 FPS on CPU with per-face emotion labels
  • Confidence bars for every prediction — shows model certainty, not just the top class
  • EmoSense Streamlit app: live detection view + session analytics dashboard
  • Emotion-over-time graph and distribution pie chart for a full demo session
  • Snapshot capture: save frames with predicted emotions for the report
  • Training notebook included — retrain, tune hyperparameters, plot learning curves
  • Data augmentation pipeline (rotation, shift, zoom, flip) to reduce overfitting
  • Multi-face support: detects and classifies several faces in one frame

What is included

  • Complete, commented Python source code (training + inference + app)
  • Pre-trained CNN model weights (.h5) — no GPU training needed on your machine
  • Jupyter training notebook with augmentation, learning curves and confusion matrix
  • Project report PDF (literature survey, CNN architecture, experiments, results, conclusion)
  • PPT presentation for final review
  • Viva Q&A preparation document (convolution math, FER2013 details, overfitting controls)
  • Installation and run guide

Advantages

  • Real-time face detection (OpenCV DNN / Haar cascade) followed by CNN emotion classification — happy, sad, angry, fear, surprise, neutral, disgust.
  • CNN trained on FER2013: 35,887 images across 7 emotion classes, with ~65–70% validation accuracy reported transparently.
  • Live webcam inference at 15–25 FPS on CPU with per-face emotion labels — no GPU needed for the demo.
  • Confidence bars for every prediction show model certainty, not just the top class — useful for the viva discussion on uncertainty.
  • EmoSense Streamlit app: live detection view plus a session analytics dashboard with emotion-over-time graphs and distribution pie charts.
  • Training notebook included (retrain, tune hyperparameters, plot learning curves), data-augmentation pipeline to reduce overfitting, and multi-face support in a single frame.

Disadvantages

  • ~65–70% validation accuracy means roughly one in three predictions is wrong — the confidence bars, not the headline label, are the honest signal.
  • FER2013 is web-scraped with known label noise and demographic bias; performance drops on faces unlike the training distribution.
  • Poor lighting, occlusions (masks, hands) and extreme angles degrade both face detection and classification.
  • Visually similar emotions (fear vs. surprise, sad vs. neutral) get confused more often — the report's confusion matrix documents this honestly.
Components & software requirements
  • Python 3.9+ (NumPy, Pandas, Matplotlib/Seaborn)
  • TensorFlow/Keras (CNN model definition, training, inference)
  • OpenCV (face detection, frame preprocessing)
  • Streamlit (EmoSense web application)
  • scikit-learn (confusion matrix, classification report metrics)
  • FER2013 dataset (35,887 labeled 48×48 grayscale faces)
Download free synopsis (PDF)

Enter your name and WhatsApp number — the synopsis PDF downloads immediately. We may send occasional project updates on WhatsApp; no spam.

Goodfellow et al. (2013), Challenges in Representation Learning: A report on three machine learning contests (introduces FER-2013), arXiv 2013

Get a quotation