Skip to content

Breaktroughf1/Emotion-Detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Emotion Detection from Facial Expressions

This project detects human emotions from facial expressions using a Convolutional Neural Network (CNN) model. The project uses the FER-2013 dataset for training and testing and includes a real-time emotion detection system using a webcam.

Table of Contents

Installation

  1. Clone the repository:

    git clone https://github.com/NoealRajeev/emotion-detection.git
    cd emotion-detection
  2. Create and activate a virtual environment (optional but recommended):

    python -m venv venv
    source venv/bin/activate  # On Windows use `venv\Scripts\activate`
  3. Install the required packages:

    pip install -r requirements.txt

Dataset

The project uses the FER-2013 dataset. You can download it from Kaggle. After downloading, place the dataset in the data/ directory following the structure described in the Directory Structure section.

Data Preparation

The data preparation script preprocesses the dataset by resizing the images and normalizing the pixel values. Run the script to prepare the data:

  python src/data_preparation.py

This will generate train_images.npy, train_labels.npy, test_images.npy, and test_labels.npy files in the data/ directory.

Training the Model

To train the CNN model, run the training script:

  python src/train_model.py

The trained model will be saved in the models/ directory as emotion_detection_model.h5.

Real-Time Emotion Detection

To run the real-time emotion detection using your webcam, execute the following script:

  python src/real_time_detection.py

This will open a window showing the webcam feed with the predicted emotion displayed.

Directory Structure

emotion-detection/
├── data/
│   ├── test/
│   │   ├── angry/
│   │   ├── disgust/
│   │   ├── fear/
│   │   ├── happy/
│   │   ├── neutral/
│   │   ├── sad/
│   │   ├── surprise/
│   ├── train/
│   │   ├── angry/
│   │   ├── disgust/
│   │   ├── fear/
│   │   ├── happy/
│   │   ├── neutral/
│   │   ├── sad/
│   │   ├── surprise/
│   ├── train_images.npy
│   ├── train_labels.npy
│   ├── test_images.npy
│   ├── test_labels.npy
├── models/
│   └── emotion_detection_model.h5
├── notebooks/
├── src/
│   ├── __init__.py
│   ├── data_preparation.py
│   ├── train_model.py
│   └── real_time_detection.py
├── .gitignore
├── README.md
└── requirements.txt

Feel free to fork this project, raise issues, or contribute to it. Happy coding!

Acknowledgements

  • Kaggle for providing the FER-2013 dataset.
  • TensorFlow for the machine learning framework.

Explanation

  • Installation: Instructions to clone the repository, set up a virtual environment, and install dependencies.
  • Dataset: Information on where to download the dataset and how to place it in the directory.
  • Data Preparation: Instructions to run the data preparation script.
  • Training the Model: Steps to train the CNN model.
  • Real-Time Emotion Detection: Steps to run the real-time emotion detection script.
  • Directory Structure: Detailed layout of the project directory.
  • Acknowledgements: Credits to sources and tools used in the project.

About

This project is designed to detect human emotions from facial expressions using a Convolutional Neural Network (CNN). It uses the FER-2013 dataset for training and performs real-time emotion detection using a webcam.

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages