Skip to content
/ ML-APP Public

Flask application featuring sentiment analysis, image classification with DenseNet121, and a GPT-2 powered chatbot for conversational AI.

Notifications You must be signed in to change notification settings

oB3TAo/ML-APP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flask ML Application

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.

Features

1. Sentiment Analysis

  • 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.

2. Image Classification

  • 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.

3. Chatbot

  • Users can chat with a GPT-2-based chatbot that generates conversational responses to user input.

Setup

Prerequisites

  • Python 3.x
  • Pip

Installation Steps

  1. Clone the Repository:

    git clone https://github.com/your-username/your-repository.git
    cd your-repository
  2. Create and Activate a Virtual Environment (Optional but recommended):

    python3 -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install Dependencies: Install the required Python libraries using the requirements.txt file.

    pip install -r requirements.txt
  4. Download ImageNet Classes: Ensure the imagenet_classes.txt file is present in the root directory of the project. You can download it from here.

  5. Run the Flask Server: Start the Flask application.

    python app.py
  6. Access the Application: The application will be available at http://127.0.0.1:5000/.

File Structure

.
├── 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

Usage

Sentiment Analysis

  1. Navigate to the homepage.
  2. Select Sentiment Analysis from the dropdown.
  3. Input text and click Submit.
  4. The sentiment prediction and confidence score will be displayed.

Image Classification

  1. Select Image Classification from the dropdown.
  2. Upload an image and click Submit.
  3. The top 5 predictions with their probabilities will be displayed.

Chatbot

  1. Select Chat from the dropdown.
  2. Type a message and submit it.
  3. A response generated by the GPT-2 model will be displayed.

Future Improvements

  • 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.

About

Flask application featuring sentiment analysis, image classification with DenseNet121, and a GPT-2 powered chatbot for conversational AI.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published