This project aims to classify emotions in text using a DistilBERT-based model. It includes both a Jupyter notebook for training and a Django API for serving predictions.
Follow the steps below to set up and run the project.
- Python 3.10.3 (Anaconda or Miniconda recommended)
- Jupyter Notebook
- Git
-
Clone the repository:
git clone https://github.com/FotieMConstant/emotions-in-text-classification.git cd emotions-in-text-classification
-
Create and activate a virtual environment (optional but recommended):
conda create --name myenv python=3.10.3 conda activate myenv
-
Install project dependencies:
pip install -r requirements.txt
-
Run the Jupyter Notebook:
jupyter notebook
-
Open and run the
train_model.ipynb
notebook. This will generate the production model (dbert_model.h5
).
-
Navigate to the Django API directory:
cd emotion_api
-
Run the Django development server:
python manage.py runserver
-
The API will be accessible at
http://localhost:8000/api/predict/
.
You can make predictions by sending a POST request to the API endpoint with the text you want to classify.
Example using curl:
curl -X POST -H "Content-Type: application/json" -d '{"text": "Your text here"}' http://localhost:8000/api/predict/
- You can equally just use postman to make the request
This project is licensed under the MIT License - see the LICENSE file for details.