Skip to content

FER-ML is a CNN-based model that detects facial expressions in real-time when a picture is taken. It uses OpenCV for face detection and is trained on the FER-2013 dataset to classify emotions.

License

Notifications You must be signed in to change notification settings

sid-lakhani/fer-ml

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Emotion Detection with CNN

This project implements an emotion detection system using a webcam and a Convolutional Neural Network (CNN) for classification. It utilizes the FER-2013 dataset for training and OpenCV for real-time face and emotion detection. The detected emotions are classified into seven categories and displayed in real-time. You can capture an image and save it in the appropriate folder based on the predicted emotion.

Table of Contents

Project Structure

The repository is organized as follows:

repo/
│
├── src/
│   └── main.py                     # Main script for running the emotion detection
│
├── utils/
│   └── haarcascade_frontalface_default.xml  # Haar cascade file for face detection
│
├── dataset/                        # Contains the FER-2013 dataset (training and test images)
│   ├── train/                       # Training images organized by emotions
│   │   ├── angry/
│   │   ├── disgust/
│   │   ├── fear/
│   │   ├── happy/
│   │   ├── sad/
│   │   ├── surprise/
│   │   └── neutral/
│   └── test/                        # Test images organized by emotions
│       ├── angry/
│       ├── disgust/
│       ├── fear/
│       ├── happy/
│       ├── sad/
│       ├── surprise/
│       └── neutral/
│
└── emotions/                        # Folder to save captured images, organized by detected emotions
    ├── angry/
    ├── disgust/
    ├── fear/
    ├── happy/
    ├── sad/
    ├── surprise/
    └── neutral/

Installation

Follow these steps to set up the environment and run the project.

Prerequisites

  • Python 3.x
  • OpenCV (for face detection and real-time video processing)
  • TensorFlow (for building and training the CNN model)
  • NumPy (for data manipulation)

Install Dependencies

To install the required Python libraries, run the following command in the root of your project directory:

pip install -r requirements.txt

You can manually install the libraries if requirements.txt is not provided:

pip install opencv-python tensorflow numpy

Usage

After successfully setting up the environment, you can run the project using the following command:

  1. Make sure you are in the src/ directory:

    cd src
  2. Run the main script:

    python main.py

Instructions:

  • The program will open your webcam and start detecting your face.
  • The detected emotion will be displayed on the screen in real-time.
  • Press the spacebar to capture an image. The image will be saved in the corresponding emotion folder inside the emotions/ directory.
  • Press 'q' to quit the application.

About

FER-ML is a CNN-based model that detects facial expressions in real-time when a picture is taken. It uses OpenCV for face detection and is trained on the FER-2013 dataset to classify emotions.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages