Origin of wine part 8

Nelson Punch
Software-Dev-Explore
2 min readNov 2, 2023
Photo by NOAA on Unsplash

Introduction

In order to turn my model into application, I can use Streamlit to create a web app.

Streamlit is a faster way to create a web application and deploy the app on a cloud server so that anyone can use it. In addition it is base on python lanuage entirely.

Streamlit app

Environment

It is a good idea to create an ioslated environment for my app at local machine. I can use either

for an isolated environment and install necessary libraries.

Model wrapper

A wrapper to wrap around my model. There are 2 reasons to create this model wapper.

  1. Load model and talk to the model within this wapper
  2. Provide interface for my application

It is important to import NLPTransformer class which was created before for the purpose of natural language processing since my model is a pipeline with NLPTransformer at first segment of the pipeline. As line 3 in code.

If I do not do so, an error will occur when pickle try to load the model.

An other important thing is NLPTransformer class will need to be written in an individual python file and be stored along with the model file within same folder.

App

Push to Github

Put the model, streamlit app and model wrapper files under the same folder and then use git to do version control, track all files and push to Github.

Create a repository on Github. Follow streamlit instuction on how to delploy app with Github.

requirement.txt is a necessary file that need to be created in order to deploy app to streamlit cloud server. To automatically generate requirement.txt, pipreqs library can be used for the purpose.

The github would look similar to this.

Live web app

Here

--

--