Welcome to my Face Emotion Detection project! This application is designed to detect emotions in faces from uploaded images using a combination of Haar Cascade for face detection and a ViT (Vision Transformer) model for emotion prediction. The model has been trained on 5 emotion classes: Happy, Sad, Angry, Surprised, and Neutral.
Home Page
Test Image(emotion: Happy)
Result page
- Upload an image containing a face.
- The Haar Cascade algorithm will detect the face.
- The image, converted to a numpy array, is then passed to the ViT Transformer model.
- The model predicts the emotion of the detected face.
- I use a ViT Transformer model pretrained on Google's Patch 16 dataset with an image size of 224x224 pixels.
- The model is fine-tuned on a custom emotion dataset, which includes Kaggle's dataset and additional custom data, to accurately classify emotions.
To enhance model accuracy, I added a custom dataset that includes a combination of Kaggle's dataset and additional custom data. This expanded dataset allowed my model to better understand and classify a wider range of emotions. A val Accuracy of 90% was achieved.
This project is hosted on Render, which may impact loading times and stability. Due to the nature of hosting service, occasional crashes or slower response times may occur.
- FastAPI: For building the web application.
- Haar Cascade: For face detection.
- Vision Transformer (ViT): For emotion prediction.
- Google's Patch 16 Dataset: For pretraining the ViT model.
- Kaggle Dataset: Incorporated for comprehensive training.
To run this application locally, follow these steps:
- Clone this repository.
- Install the necessary dependencies using
pip install -r requirements.txt
. - Run the FastAPI app using
uvicorn app:app --reload
.
Explore the project's development and model training in detail by visiting my notebook repository here.
Contributions are welcome! If you have any suggestions or improvements, please open an issue or submit a pull request.
This project is licensed under the MIT License - see the License file for details.
Enjoy exploring and using the Face Emotion Detection application!