In this third part of the ML project miniseries, we’ll explore how to publish your newly created solar panel detection application using streamlit.
We’ve been working on building a tool to automatically detect solar panels from orthophotos. So far we’ve gone through how to collect and preprocess these images and use them to train a neural network model with fastai. In this part, we’ll focus on creating a web app PoC using
You’ve come all this way and built your very own solar panel segmentation model. Why not share it with your friends and colleagues?
Show off your hard work and learn how to create various data-related apps using
Streamlit is a relatively new, open-source app framework that lets data scientists and ML engineers create and publish apps quickly. And it’s done all in Python.
Now, if you’re not a Python guru or want something with a little more ‘React’ feel to it, don’t fret. There are multiple dashboard frameworks you can choose from. For instance, our personal favorite – R Shiny. There’s also Dash, Viola, and you have the ability to share a jupyter notebook or create something from scratch in flask.
Since its publication in 2019,
streamlithas seen significant interest – over 15.9k stars on Github! It continues to provide the Python community with functionality upgrades and regular maintenance. The library helps users create PoCs, apps, and dashboards as easily as possible, as quickly as possible, and all for free. It’s not unlike R Shiny – with the exception that R Shiny is a – you guessed it! – R package.
There’s this idea with
streamlitthat you should be able to write what you want to see when you want to see it. Keep that in mind when trying to understand the code.
You can run your app with a simple command:
streamlit run st_hello_world.pyin the terminal.
It’s cool to see something like this so fast. Especially with the lack of so-called boilerplate code. Every symbol serves some purpose! Now let’s try adding some interactivity to the app.
There are some people (like me!) for whom a decent scientific blog system/web app framework MUST allow easy work with latex equations. Fortunately, that’s a piece of cake in streamlit. Due to the way f-strings work in Python, we have a tiny bit of boilerplate code to include here:
By combining the features described above with a few more, we can create a functional demo app.
But first, I want to point out a few things:
label_funcfunction to be available in scope upon loading (recall part 2 of the miniseries). That’s why it’s defined like that.
And there we have it! A demo app that’s ready to be shared with the world. We’ve added ours on RStudio Connect. You can explore the Solar Panel Detection demo app for yourself.
It’s pretty easy to make a ‘Hello World’ with
streamlit. And in this tutorial, we’ve shared with you how to add a trained model. If you have any issues, be sure to check out the official tutorial.
While this method might be convenient for small applications to share with friends and colleagues, there’s another solution for enterprises – using RStudio Connect. So keep an eye out for a future post on how to upgrade your app deployment. In the meantime, feel free to contact us at [email protected] should you need any immediate assistance.
Using the new Python library streamlit, we were able to share our impressive solar panel identifier model with the world! We learned that this library is a great way to quickly visualize your Python experiments and a fairly friendly tool for beginners with great expressive power – a true Python package.
I guess that’s why its popularity is growing every month. And probably why you should be utilizing it more!
Sign up for our newsletter to get updates and receive our latest blogs in your inbox – like how to deploy streamlit apps on RStudio Connect!
This project was written under: