This project focuses on building a deep learning model to detect facial emotions from images. The model categorizes emotions into four classes: happy, sad, neutral, and surprise. The project leverages transfer learning using the VGG16 model and hyperparameter tuning to achieve optimal performance.
Facial emotions constitute a significant part of human communication. Understanding these emotions can enhance human-computer interaction, improve health diagnostics, and enable intuitive AI systems. The goal of this project is to train a model that accurately classifies human emotions based on facial expressions.
The dataset consists of three folders: train, validation, and test. Each folder contains images categorized into four subfolders:
- happy: Images of people with happy expressions.
- sad: Images of people with sad expressions.
- neutral: Images of people with neutral expressions.
- surprise: Images of people with surprised expressions.
-
Data Preprocessing:
- Images are resized to 48x48 pixels and normalized.
- Data augmentation techniques like random flipping and rotation are applied.
-
Model Architecture:
- The project uses the VGG16 model pre-trained on ImageNet as the base model.
- Additional layers are added for fine-tuning, including dense layers, batch normalization, and dropout layers.
-
Hyperparameter Tuning:
- The
keras_tunerlibrary is used to optimize the number of neurons in dense layers. - The
Hyperbandalgorithm is employed to find the best configuration.
- The
-
Training:
- The model is trained using the Adam optimizer with a learning rate scheduler (
ReduceLROnPlateau). - Early stopping is used to prevent overfitting.
- The model is trained using the Adam optimizer with a learning rate scheduler (
-
Evaluation:
- The model's performance is evaluated on the test set using accuracy, confusion matrix, and classification reports.
- The final model achieved a test accuracy of approximately 72%.
- The confusion matrix and classification report highlight the model's performance across all emotion classes.
- Training and validation accuracy/loss plots are generated to monitor the model's performance over epochs.
- A heatmap of the confusion matrix is plotted to visualize the classification results.
- Clone the repository and navigate to the project directory.
- Ensure the dataset is downloaded and placed in the
Facial_emotion_imagesfolder. - Run the
FINAL_SUBMISSION.ipynbnotebook to train and evaluate the model.
- Python 3.10
- TensorFlow 2.x
- Keras
- Keras Tuner
- Matplotlib
- Seaborn
- NumPy
- PIL
- The VGG16 model is pre-trained on the ImageNet dataset.
- The dataset used for this project was provided via Olympus.
- Extend the model to detect additional emotions.
- Experiment with other transfer learning models like ResNet or EfficientNet.
- Deploy the model as a web application for real-time emotion detection.
- Optimize the model for faster inference on edge devices.
- Update tests to use F1-score