A simple web application that detects emotions from text input using a pre-trained SVM model.
This application uses a Flask backend with an HTML/CSS frontend to analyze the emotions expressed in the user's text. It employs a Support Vector Machine (SVM) model for multi-label classification to detect various emotions like happiness, sadness, anger, etc.
- Text input for users to express their thoughts
- Emotion analysis using a pre-trained SVM model
- Display of detected emotions with appropriate responses
- Simple and intuitive user interface
- Python 3.6 or higher
- Flask
- NLTK
- scikit-learn
- pickle (for loading the model)
-
Make sure you have Python installed on your system.
-
Install the required packages:
pip install flask nltk scikit-learn -
Ensure your model files are in the root directory:
svm_model.pkl- Your trained SVM modelvectorizer.pkl- Your trained vectorizer (TfidfVectorizer or CountVectorizer)
-
Run the application:
python app.py -
Open your web browser and navigate to
http://127.0.0.1:5000/
emotion-detection-app/
│
├── app.py # Flask application
├── svm_model.pkl # Pre-trained SVM model
├── vectorizer.pkl # Pre-trained vectorizer
├── static/
│ └── styles.css # CSS styling
└── templates/
└── index.html # HTML template
- The user enters text in the input area and clicks "Analyze Emotions"
- The text is sent to the Flask backend
- The text is preprocessed (tokenization, cleaning, stopword removal, normalization)
- The preprocessed text is vectorized using the pre-trained vectorizer
- The SVM model predicts the emotions present in the text
- The detected emotions and an appropriate response are returned to the frontend
- The results are displayed to the user