This project is a Flask-based web application that integrates multiple machine learning models, offering various features including sentiment analysis, image classification, and a chatbot interface using GPT-2.
- Users can input text, and the application will utilize Hugging Face’s sentiment analysis pipeline to predict whether the sentiment is positive or negative, along with a confidence score.
- Users can upload an image, and the application will classify it into one of 1,000 ImageNet categories using a pretrained DenseNet121 model. The top 5 predictions, along with their confidence scores, will be displayed.
- Users can chat with a GPT-2-based chatbot that generates conversational responses to user input.
- Python 3.x
- Pip
-
Clone the Repository:
git clone https://github.com/your-username/your-repository.git cd your-repository
-
Create and Activate a Virtual Environment (Optional but recommended):
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install Dependencies: Install the required Python libraries using the
requirements.txt
file.pip install -r requirements.txt
-
Download ImageNet Classes: Ensure the
imagenet_classes.txt
file is present in the root directory of the project. You can download it from here. -
Run the Flask Server: Start the Flask application.
python app.py
-
Access the Application: The application will be available at
http://127.0.0.1:5000/
.
.
├── app.py # Main Flask application
├── commons.py # Helper functions for image preprocessing and prediction
├── templates
│ ├── index.html # HTML form for user inputs
│ └── result.html # HTML to display results
├── imagenet_classes.txt # ImageNet class labels for image classification
├── requirements.txt # Project dependencies
└── README.md # Project README file
- Navigate to the homepage.
- Select Sentiment Analysis from the dropdown.
- Input text and click Submit.
- The sentiment prediction and confidence score will be displayed.
- Select Image Classification from the dropdown.
- Upload an image and click Submit.
- The top 5 predictions with their probabilities will be displayed.
- Select Chat from the dropdown.
- Type a message and submit it.
- A response generated by the GPT-2 model will be displayed.
- Add support for more ML models and features.
- Improve the chatbot's conversational accuracy by upgrading to a more advanced model (e.g., GPT-3 or GPT-4).
- Enhance the user interface for a more modern and seamless experience.
- Improve code maintainability by modularizing components further and adhering to best practices.