kbiondo / docker_sentiment_analysis

A dockerized application that performs sentiment analysis.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dockerized Sentiment Analysis application

This repo is for developing a Dockerized sentiment analysis application that I built in this repo. Most directories have a README file to describe the purpose of the directory and for me to take notes. Most of the code is commented so I can remember how things are working and to note learning lessons from this project. Feel free to copy any of this code for your own projects with an acknowledgement.

Development Steps

  1. Build a Docker container that serves the sentiment analysis model as the ml_service. This model should only have to be loaded once when the container starts up.
  2. Build a Docker container that serves the UI through which users can submit a sentence. This service is called the ui_service The UI will then send a request to the model container and show the related sentiment score.
  3. Use docker-compose to bring up both services and link them together.

Steps to run Dockerized sentiment analysis application locally

  1. From the root of this repo, run docker-compose build to build the images for the ml_service and the ui_service. This will take a couple of minutes, especially since tensorflow is a large package.
    1. Run docker images. You should see images called sentiment_analysis_ml_service (for the ml_service) and sentiment_analysis_ui_service (for the ui_service).
  2. Start up the ml_service in the background by running docker-compose up -d ml_service.
    1. If you run docker ps, you should see a container running with the name ml_service.
    2. If you go to http://localhost:8000/, you should see the message "ML model service is running!".
  3. Start up the ui_service by running docker-compose up ui_service.
    1. You should the logs for starting up the container for the ui_service in your Terminal window.
    2. In a new Terminal window if you run docker ps, you should see a container running with the name ui_service.
    3. If you go to http://localhost:8001/, you should see the web UI displayed.
  4. Visit http://localhost:8001/ and type in sentences that you would like to get the sentiment for!
  5. Clean-up:
    1. Run docker rm -f ui_service ml_service to stop and remove the containers.
    2. Run docker ps -a to verify that there are no containers running.

Alternative

  1. Run docker-compose up from the root of the repo. This will build images for both services and start them up. The logs for both services will print to your Terminal window.
  2. Go to http://localhost:8001/ to use the application.

Future Development

  1. Add a Docker container running a SQL database that stores user queries. Maybe the last 5 queries can be displayed on page showing the sentiment classification for a user's sentence.

About

A dockerized application that performs sentiment analysis.


Languages

Language:CSS 66.6%Language:Python 21.4%Language:JavaScript 4.0%Language:Jupyter Notebook 2.7%Language:HTML 2.7%Language:Dockerfile 1.5%Language:Shell 1.2%