How to connect UbiOps with Streamlit¶
In this example we will show you the following:
How to turn the mnist deployment from the image-recognition ready deployment into a live web app using Streamlit.
The deployment is configured as follows:
|Function||predict hand written digits|
|Input field||name: image, data_type: file|
|Output field||name = prediction, datatype = integer|
|name = probability, datatype = double precision|
How does it work?¶
Step 1: Login to your UbiOps account at https://app.ubiops.com/ and create an API token with project editor rights. To do so, click on Permissions in the navigation panel, and then click on API tokens. Click on [+]Add token to create a new token.
Give your new token a name, save the token in a safe place and assign the following roles to the token: project editor. These roles can be assigned on project level.
Note: If you already have the image-recognition deployment in your UbiOps environment, you can skip step 2 and step 3.
Step 2: Download the mnist-streamlit folder and open streamlit.ipynb. In the notebook you will find a space to enter your API token and the name of your project in UbiOps. Paste the saved API token in the notebook in the indicated spot and enter the name of the project in your UbiOps environment. This project name can be found in the top left of your screen in the WebApp. In the GIF above the project name is example.
Step 3: Run the
streamlit.ipynb file and the deployment will be automatically be deployed to your UbiOps environment
Step 4 Open the
mnist-streamlit.py and enter your project name and API token in the TODO fields. If you already had the mnist deployment in your UbiOps environment, change the deployment name to mnist.
Step 5 Run *streamlit run
mnist-streamlit.py and the web app will be created.