Deploying Your Machine Learning Apps in 2021

Streamlit Sharing is here and is awesome.

Deploying Your Machine Learning Apps in 2021

It’s still 2020. I woke up to something in my inbox that left me wow-ed. If the promise were real, it would completely transform how I build and deploy machine learning apps henceforth.

To give you a bit of context, I had recently worked on a very basic project to predict the onset of diabetes based on diagnostic measures. When I build anything, the end goal is to make it accessible to the end-user. Always. After having some experience designing, developing, and deploying multiple ML apps, the process was more or less known to me. Once the model development has been completed, I first build an app wrapping the models, then dockerize the app, and finally deploy it to any cloud service providers.

But little did I know, the awesome team at Streamlit had other plans. I received a mail in my inbox this morning. And trust me, this changes everything about model deployment. It’s still 2020, but I can see what’s coming for 2021.

The mail was an invite to the freshly launched Streamlit Sharing platform that simplifies app deployment. Though still on beta, I couldn’t help but be excited about what’s coming for 2021. (Screenshot by Author)

Streamlit Sharing and The Promise

If you haven’t heard of Streamlit yet, it is a python library that makes building ML apps fast and easy. I’m not exaggerating when I say it takes only a few hours to build any machine learning app. Streamlit Sharing is a newly launched platform for sharing Streamlit apps. Now there already exist similar platforms such as Heroku and Netlify for easy deployment, but when built with Streamlit, this new platform might as well be your best bet. Streamlit calls it a “simple, sharable play button for machine learning code.” Let’s find out?

The promise for us, the data science folks, was quite simple. Push your code to GitHub, and point Streamlit to your repository and deploy your apps for free. So what’s the catch? Currently, sharing supports only apps that are public and open-source. If you need to deploy apps for private/internal use-cases, you need to wait for Streamlit Teams, currently under beta-development.

Now that we understand the tool, I’m super excited to get our hands on the platform.


How to Deploy the Machine Learning App

As I mentioned before, the example we will use here would be the diabetes prediction app built using Streamlit. Please refer to this GitHub repository for the complete code for the app. Make sure to add the requirements.txt file. A requirements file is nothing but the list of python packages and their versions used for the app. A simple pip freeze command on your terminal would give you exact details. Behind the scenes, this file helps Streamlit install all the dependencies required for the deployment.

Now that our repository is ready, I signed in to the Streamlit Sharing platform. When prompted, I authorized Streamlit to access my Github account. I filled in the details and clicked Deploy.

The simple process of deployment. (Screenshot by Author)

Wait… That’s it? My app was deployed for the world to see. I was wow-ed by how simple this process has become.

The whole deployment process took about 5 mins. And whenever I update the app and push the codes to my GitHub repository, the deployed app would be updated. This is crazy!

Screencast of the deployed app by Author

However, since the platform is still in beta, some resource constraints exist, such as 3 apps per user account, and some known limitations. The official documentation does a good job outlining more information, and the community is always helpful.

I strongly believe, by 2021, thanks to Streamlit, this is going to be the norm. You would rapidly prototype your ML apps using Streamlit and deploy them using Streamlit Sharing in a matter of hours. Honestly, I can’t wait to see more features getting added to Streamlit!


Now it’s Your Turn

I get it. Now that you’ve read this, you would love to develop and deploy your own machine learning app. Here’s a recap on how you can too.

  1. Build your usual ML models, and quickly wrap them into a Streamlit app.
  2. Push your code to GitHub. Make sure to include a requirements.txt file.
  3. Request for an invite for Streamlit Sharing. (In beta as I write this — should be available soon)
  4. Sign in to your Streamlit Sharing account and authorize it to access GitHub.
  5. Select the repository, branch, and code to be deployed. Click Deploy!
  6. (Optional) Share the link of your app in the responses here. I would love to see and share it as well.

This article is a part of my series on Machine Learning in Production:
- How I Build Machine Learning Apps in Hours
- How to Dockerize Any Machine Learning Application
- Deploying Your Machine Learning Apps in 2021

I hope you enjoyed reading as much as I enjoyed writing this for you. I write extensively about my experiences in data science here in Medium. Feel free to connect with me on LinkedIn, and I’d love to hear all kinds of feedback.