Launch Streamlit Demo
Build Streamlit apps in Amazon SageMaker Studio
This notebook's CI test result for us-west-2 is as follows. CI test results in other regions can be found at the end of the notebook.
Developing web interfaces to interact with a Machine Learning (ML) model is a tedious task. With Streamlit, developing demo applications for your ML solution is easy. Streamlit is an open-source Python library which makes it easy to create and share web apps for ML and data science. This notebook outlines how to host Streamlit apps in SageMaker Studio by walking through a demo step-by-step.
As an example, we will be using a custom Amazon Rekognition demo, which will annotate and label an uploaded image. This will serve as as a starting point, and it can be generalized to demo any custom ML model. This code has been tested on the Python 3 (Base Python 3.0) image in SageMaker Studio.
Step 1: Create SageMaker Studio using JupyterLab 3.0
This solution has been tested on SageMaker Studio with JupyterLab 3. Older versions might not support features to host the app. By default SageMaker Studio comes with JupyterLab 3. To check the version and change it if running an older version, use the AWS management console by changing the Domain settings in Amazon SageMaker.
Step 2: Install Dependencies
Step 3: Run Streamlit Demo and Create Shareable Link
View the Amazon Rekognition demo by running the command below in the System Terminal.
sh run.sh
Note: while developing, it might be helpful to automatically rerun the script when app.py is modified on disk. To do so we can modify the runOnSave configuration option by adding the --server.runOnSave true flag to the streamlit run command.
Conclusion
This example showed an end-to-end example of hosting a Streamlit demo for an object detection task using Amazon Rekognition. We modified the URL pattern in our web browser to initiate a session through the AWS Jupyter Proxy. This demo allows you to upload any image and visualize the outputs from Amazon Rekognition. The results will also be processed and you can download a CSV file with all the bounding boxes through the app. Extended this work to annotate and label your own dataset, or modify the code to showcase your custom model!
Notebook CI Test Results
This notebook was tested in multiple regions. The test results are as follows, except for us-west-2 which is shown at the top of the notebook.