Jump to this page to view the live webapp.
This is a small scale application that takes a sentence as input and detects if it is a Positive or Negative sentiment. A Kaggle dataset containing 1.6 million tweets is preprocessed and used for training an XGBoost Classifier. The Flask app calls the model prediction on receiving input from the text field. This app is dockerized as a container and stored in Google Cloud Registry (GCR). The objective of this project is to understand and learn the fundamentals of Flask, Docker, and Google Cloud Platform.
sample_video.MP4
To clone this repository via HTTPS, use the below command in a new terminal.
git clone https://github.com/vishaln15/sentiment-analysis.git
Alternatively, we can clone this repository via SSH.
git clone git@github.com:vishaln15/sentiment-analysis.git
Change directory into this repository.
cd sentiment-analysis/
With Anaconda, we can create a new environment with Python 3.10.8 and install the requirements.
conda create -n ENV_NAME python=3.10
pip install -r requirements.txt
Install Docker for the platform that you are using. The docker container for this project was built on an Ubuntu 22.04.01 LTS platform.
To build this container on Linux, there were various bugs that needed to be dealt with. Run the following command on Linux platform to build the container.
docker buildx build --platform linux/amd64 -t sent_analysis .
To run the container locally in a development server, execute the following command.
docker run sent_analysis
Connect your machine with Google Cloud after creating credentials and installing gcloud-cli
.
After creating a container in Google Cloud Registry, submit the container build image to gcr by running the following command.
gcloud builds submit --tag gcr.io/PROJECT_ID/CONTAINER_NAME
Run the following command to deploy the app from cli.
gcloud run deploy --image gcr.io/sentiment-analysis-flask-app/container --platform managed