Skip to content

This project deploys an 87% accurate sentiment analysis model using LSTM with TensorFlow. The model is served through a Flask web service, containerized with Docker, and orchestrated with Kubernetes. A user interface, implemented with HTML and CSS, enhances the interaction. MySQL on AWS RDS logs predictions.

Notifications You must be signed in to change notification settings

gunaxprofessional/Sentiment-Analysis-Model-Deployment-Pipeline

Repository files navigation

Sentiment Analysis Model Deployment Pipeline

This project demonstrates the deployment of a sentiment analysis model using LSTM, a web service, and a deployment pipeline with Docker and Kubernetes. The sentiment analysis model is built using TensorFlow, and the web service is implemented in Python with Flask. The MySQL database is hosted on AWS RDS. Below is a comprehensive guide on setting up and running the entire system.

Demo:

image

Table of Contents

  1. AI Model Development
  2. Web Service Creation
  3. MySQL Database Interaction
  4. Containerization with Docker
  5. Deployment with Kubernetes
  6. Documentation
  7. Bonus Features

AI Model Development

The sentiment analysis model is developed using LSTM, achieving an accuracy of 87%. Python is used as the programming language, and TensorFlow serves as the machine learning framework.

Note: To obtain the model pickle file (sentiment_model.h5), run the notebook.ipynb provided in the repository.

Web Service Creation

A web service is implemented in Python using Flask to serve the sentiment analysis model. The service exposes an API endpoint allowing users to submit text snippets and receive model predictions. The service logs prediction requests and results in a MySQL database hosted on AWS RDS.

MySQL Database Interaction

For MySQL database interaction, the user needs to enter the following details:

  • Host
  • User
  • Password
  • Database Name

Use the sql.py Python file to retrieve information from the database.

Containerization with Docker

The AI model and the web service are containerized using Docker. The Dockerfile specifies the environment, dependencies, and how the application should run. The container exposes port 5002, and Gunicorn is used to run the Flask app.

Deployment with Kubernetes

The deployment is managed using Kubernetes. The deployment.yaml file defines a Deployment and a Service. The Deployment ensures the desired number of replicas (pods) are running, and the Service exposes the web service externally.

Documentation

Setup and Execution

Follow these steps to set up and run the project:

  1. Clone the Repository:

    git clone https://github.com/gunaxprofessional/Sentiment-Analysis-Model-Deployment-Pipeline.git
    cd Sentiment-Analysis-Model-Deployment-Pipeline
  2. Install Dependencies:

    pip install -r requirements.txt
  3. Run the Web Service Locally:

    python app.py

    Access the service at http://localhost:5002.

  4. Build Docker Image:

    docker build -t sentimentdockerimg .
  5. Run Docker Container:

    docker run -p 5002:5002 sentimentdockerimg

    Access the service at http://localhost:5002.

  6. Kubernetes Deployment:

    Apply the Kubernetes deployment configuration:

    kubectl apply -f deployment.yaml

    Start minikube:

    minikube start

    Monitor the deployment:

    kubectl get deployments
    kubectl get pods
    kubectl get services

    Access the service based on the external IP or NodePort provided.

    Open Kubernetes Dashboard:

    minikube dashboard

    Get Service URL:

    minikube service sentiment-analysis-service --url

Bonus Features

  • Front-End Interface:

    A simple front-end interface is added for user interaction. Access the interface at http://localhost:5002.

About

This project deploys an 87% accurate sentiment analysis model using LSTM with TensorFlow. The model is served through a Flask web service, containerized with Docker, and orchestrated with Kubernetes. A user interface, implemented with HTML and CSS, enhances the interaction. MySQL on AWS RDS logs predictions.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published