This is a desktop application that classifies emotions from text input using a pre-trained Transformer model. The application utilizes tkinter
for the GUI, Pillow
for image handling, and transformers
from Hugging Face for text classification.
- Text Input: Users can input text into a text entry widget.
- Emotion Classification: Upon clicking the classify button, the application employs a Transformer model to classify the input text into different emotions.
- Result Display: The classified emotions are displayed along with their corresponding confidence scores, visually represented using progress bars.
- Clear and User-Friendly Interface: The GUI is simple and intuitive, featuring a header, text entry, and result display sections.
- Python 3.6 or higher
- Required Python libraries:
os
,sys
,tkinter
,ttk
,Pillow
,transformers
-
Clone the Repository:
git clone https://github.com/KCprsnlcc/TextClassificationAnalysis.git cd TextClassificationAnalysis
-
Install Dependencies:
pip install -r requirements.txt
-
Ensure Model Directory: Ensure the pre-trained Transformer model is available in the
transformermodel/
directory. -
Place Logo: Ensure
logo.png
is in the base directory of the project.
-
Run the Application:
python main.py
-
Enter Text: Type the text you want to classify into the text entry widget.
-
Classify Emotion: Click the "Classify Emotion" button to see the classified emotions along with confidence scores.
-
Import Statements: Import necessary libraries and modules.
import os import sys import tkinter as tk from tkinter import ttk from PIL import Image, ImageTk from transformers import pipeline
-
Function Definitions:
- classify_emotion: Classifies the input text and updates the results.
- clear_results: Clears previous results.
- display_input_text: Displays the input text.
- update_results: Updates and displays new classification results.
- get_progress_color: Returns the color for the progress bar based on the score.
-
Environment Configuration: Disable specific TensorFlow operations.
os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0'
-
Load Model: Load the emotion classification pipeline from the local directory.
classifier = pipeline("text-classification", model=local_model_directory, top_k=None)
-
GUI Setup:
- Main Window: Configure the main window.
- Header Frame: Create a header frame with a logo and title.
- Text Entry: Create a text entry widget for user input.
- Classify Button: Create a button to trigger emotion classification.
- Result Frame: Create a frame to display classification results.
- Emotion Label: Label to display messages or status.
-
Start Main Event Loop: Start the tkinter main event loop to run the application.
root.mainloop()
- Hugging Face for providing the pre-trained Transformer models.
- Python for being the programming language of choice.
- tkinter for the GUI framework.
- Pillow for image handling capabilities.