Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Emotion Recognition Model Training

This repository contains Python code for training a Convolutional Neural Network (CNN) to recognize emotions from facial images. The training process includes data augmentation for minority classes, model training, evaluation, and visualization of results (accuracy/loss plots and confusion matrix).

Table of Contents

Features

  • Data Augmentation: Augments the minority class ("disgusted" emotion) to balance the dataset and improve model performance.
  • CNN Model: Implements a deep Convolutional Neural Network for emotion classification.
  • Training & Validation: Trains the model using augmented data and validates its performance on a separate test set.
  • Callbacks: Utilizes EarlyStopping and ReduceLROnPlateau callbacks for efficient training.
  • Performance Metrics: Evaluates the model's accuracy and loss.
  • Visualizations: Generates plots for training/validation accuracy and loss, and a confusion matrix to visualize classification performance.
  • Model Saving: Saves the trained model in Keras format (.keras).
  • Cleanup: Automatically removes temporary augmented data directories after execution.

Prerequisites

Before running the code, ensure you have the following installed:

  • Python 3.8+
  • pip (Python package installer)

Dataset

The code expects a dataset organized into train and test directories, with subdirectories for each emotion class. The expected directory structure is as follows:

dataset/ ├── train/ │ ├── angry/ │ ├── disgusted/ │ ├── scared/ │ ├── happy/ │ ├── neutral/ │ ├── sad/ │ └── surprised/ └── test/ ├── angry/ ├── disgusted/ ├── scared/ ├── happy/ ├── neutral/ ├── sad/ └── surprised/

Place your dataset in a folder named dataset in the same directory as the train.py script.

Installation

  1. Clone the repository or download the train.py file.

  2. Install the required Python packages:

    pip install tensorflow numpy matplotlib scikit-learn seaborn
    • tensorflow: Used for building and training the deep learning model.
    • numpy: Used for numerical operations.
    • matplotlib: Used for plotting graphs and visualizations.
    • scikit-learn: Specifically for computing the confusion_matrix.
    • seaborn: For enhanced data visualizations, particularly the confusion matrix heatmap.

    Note: The script uses tensorflow.keras, which is included with TensorFlow. Ensure your TensorFlow installation includes Keras.

Usage

To train the emotion recognition model, simply run the train.py script from your terminal:

python train.py

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages