Emotion Detection App
I built an application that detects and classifies emotions in text inputs using a fine-tuned NLP model (1) — and you can try it live at the bottom of this page.
The app uses Hugging Face Transformers (2) and a Gradio interface (3) to classify text into six emotions: anger, fear, joy, love, sadness, and surprise.
- NLP models are mathematical algorithms designed to understand, interpret, and generate human language. They power applications like chatbots, language translation, and sentiment analysis.
- Hugging Face Transformers are advanced NLP models that enable computers to perform tasks like text generation, translation, and question answering. They provide a flexible, open-source library for implementing and fine-tuning these models.
- Gradio interfaces are user-friendly tools for creating interactive demos of machine learning models. They allow developers to build and share web-based interfaces that let users input data and see model predictions in real-time.
Motivation
The Emotion dataset on Hugging Face includes English Twitter messages labeled with six basic emotions: anger, fear, joy, love, sadness, and surprise.
I fine-tuned a pre-trained DistilBERT model on this dataset and built a user-friendly interface using Gradio, deployed on Hugging Face Spaces.
The prediction quality can be improved by fine-tuning with better resources (I used Google Colab for this project).
The project is modular and adaptable — you can modify it to explore other models and fine-tuning techniques.
Project Overview
- Tools & Technologies
- Hugging Face Transformers, Gradio, PyTorch, Pandas, Matplotlib
- Steps Involved
Dataset Selection and Exploration: Understanding the structure and distribution of the Emotion dataset.Model Selection: Using DistilBERT for its efficiency in text classification tasks.Model Fine-tuning: Enhancing the model's performance by training on the Emotion dataset.Model Evaluation: Assessing the model using accuracy, precision, recall, and F1-score.Uploading Model: Sharing the fine-tuned model on Hugging Face.Gradio Interface Development: Creating a user-friendly interface for the model.Deployment: Making the app accessible on Hugging Face Spaces.
All steps are consolidated in a single Jupyter Notebook, making it accessible and modifiable for anyone interested in emotion detection or similar NLP tasks.
Project Artefacts
- Fine-tuned model: Hugging Face
- Full source code: GitHub
- Full-screen app, or interact with it below: