Comparing several web UI tools for data science!

Photo by Cesar Carlevarino Aragon on Unsplash

Introduction

Machine learning models are exciting and powerful, but they aren’t very useful by themselves. Once a model is complete, it likely has to be deployed before it can deliver any sort of value. As well, being able to deploy a preliminary model or a prototype to get feedback from other stakeholders is extremely useful.

Recently, there has been an emergence of several tools that Data Scientists can use to quickly and easily deploy a machine learning model. In this article, we’re going to look at 4 alternatives that you can use to deploy a machine learning model: Gradio, Streamlit, Dash, and Flask.

Keep in mind that this is an opinionated article and is solely based off of my knowledge and experiences with these tools.

Summary: Which Should I Use?

Image created by Author

Gradio: Gradio is specifically built with machine learning models in mind. So if you want to create a web UI specifically for a machine learning model that you built, Gradio’s simple syntax and setup is the way to go.

Streamlit: Streamlit is useful if you want to get a dashboard up and running quickly, and have the flexibility to add lots of components and controls. As well, Streamlit allows you to build a web UI or a dashboard much faster than Dash or Flask.

Dash: Choose Dash if you want to be a production-ready dashboard for a larger company, since it’s mainly tailored for enterprise companies.

Flask: Choose Flask if you have knowledge of Python/HTML/CSS programming and you want to build your own solution completely from scratch.

Gradio

See website here.

Gradio is a powerful tool that is used to create machine learning model user interfaces. It is a python package that is perfectly compatible with several machine learning frameworks such as PyTorch and TenserFlow. It can also be used to create UIs around arbitrary general-purpose Python scripts.

The popularity of Gradio is increasing rapidly. It is being used by machine learning labs at large companies like Cisco and Amazon, as well as academic settings like Stanford medicine.

Pros:

  • Gradio offers several customizable UI components that are optimized for machine learning models. For example, Gradio provides easy-to-use drag-and-drop image classification that is highly optimized for the user.
  • It is very easy and fast to set up Gradio. It can be installed directly through pip. Moreover, creating interfaces in Gradio requires only a couple of lines of code.
  • Gradio creates shareable links which are probably the fastest way to get a deployed machine learning in front of users
  • Unlike the other packages, Gradio can be run anywhere from within a Jupyter/Colab notebook or a standalone Python script.

Cons:

  • Though Gradio has good documentation on the official website, it is hard to find information and enough examples about the specific features that it offers.
  • Gradio has a smaller community than some of the other packages, making it harder to find resources about it.
  • Gradio is specific towards building UIs for machine learning models, and less towards dashboards.

Streamlit

See website here.

Streamlit is another popular tool that is used to create user interfaces. It is an open-source Python library that is used to build powerful, custom web applications for data science and machine learning. Streamlit is compatible with several major libraries and frameworks such as Latex, OpenCV, Vega-Lite, seaborn, PyTorch, NumPy, Altair, and more.

Like Gradio, Streamlit is also popular and used among big industry leaders, such as Uber and Google X.

Pros:

  • Streamlit is accessible for everyone who understands Python. There is no requirement for HTML and CSS.
  • It has a wide range of UI components. It covers almost every common UI component such as checkbox, slider, a collapsible sidebar, radio buttons, file upload, progress bar, etc. Moreover, these components are very easy to use.
  • It supports multiple interactive visualization libraries such Latex, OpenCV, Vega-Lite, etc.

Cons:

  • While not difficult, Streamlit does require some time to learn its own syntax.
  • Streamlit is not that flexible. It is only based on Python, offers a limited set of widgets, and doesn’t integrate with Python Notebooks.
  • The data upload limit is only 50Mb.
  • There is limited support for video/animation.

Dash

See website here.

Dash is an open-source Python library used for creating reactive web applications. It is a user-interface library. Dash is a powerful tool for building analytical web applications.

Pros:

  • Dash can be used with various domains such as data exploration, data analysis, modeling, visualization, instrument control, and reporting.
  • It is very simple to use. It can be installed directly through pip.
  • Apart from Python, It can be used with R, Julia, and Jupyter.
  • Dash applications are reactive.
  • Dash is more customizable than Streamlit. Also, Dash offers better performance.
  • Dash has a better, regularly-updated, easy-to-follow documentation.

Cons:

  • Dash is more focused on the enterprise market and doesn’t include all of it’s available features in the open source version.
  • Dash is more verbose than Gradio or Streamlit; you have to write more code to create simple web applications compared to other frameworks.

Flask

See website here.

Flask is a python web framework used to build web applications. It offers several modules for web development that makes the developer’s job easier. Flask also has resources to deploy a machine learning model, though any front-end work must be done by the developer. This means that as a data scientist, you must also be comfortable with HTML, CSS, and JavaScript.

Pros:

  • As it is a framework, you can build everything from scratch according to your own requirements.
  • Using flask, it is easier to build customizable applications.
  • More generic web applications can be built using Flask.
  • Flask is very mature and stable; something you build with flask is more certain to continue working into the future.
  • There is extensive documentation about Flask and related libraries out there.

Cons:

  • Flask does not provide any sort of UI components for machine learning or data science applications.
  • Intermediate Python knowledge is required, as well knowledge of HTML, CSS, and JavaScript.
  • Building the solution from scratch can be resource intensive.

Thanks for Reading!

I hope you found this informative and useful when deciding on what tool to use! At the end of the day, I would choose what you feel most comfortable with. :)

As always, I wish you the best in your learning endeavors!

Not sure what to read next? I’ve picked another article for you:

A Complete 52 Week Curriculum to Become a Data Scientist in 2021

and another one!

Top 10 Python Libraries for Data Science in 2021

Terence Shin


Gradio vs Streamlit vs Dash vs Flask was originally published in Towards Data Science on Medium, where people are continuing the conversation by highlighting and responding to this story.