LATEST UPDATES
latest

Creating UI for your ML model using Gradio

VGG16 model for classifying images
More often than not, you will have a Machine Learning course showing you how to prepare the data, create the model, and evaluate it. You'll have a number in the end, it can be anything from RMSE to loss, accuracy, to tell you how your model performed, and that would be the end of it. But that is not the end of it, because you have another equally important step left, deployment. Now, you may not actually deploy your model to production, but you can definitely test it by creating an UI for others to be able to use it.

So I use Gradio to create the UI?
Yes, what gave it away?! Using Gradio, you can generate an easy-to-use, customizable UI for your TensorFlow or PyTorch models, arbitrary Python functions, or API with only a few lines of code. You can mix and match components to support any combination of inputs and outputs, and integrate the UI directly into your Python notebook, or share a link with anyone. What better, the core library of Gradio is free and open-source!

Gradio is built to integrate with Tensorflow, PyTorch, Jupyter, Google Colab, Matplotlib, and scikit-learn. Setting up is pretty easy and can be done using pip. The Gradio interface automatically generates a public link you can share with anyone for them to be able to interact with your model on your computer remotely from their own devices.

Can you show me how it all works?
Sure! Here's a simple example of a VGG16 model being used to classify images. Once you have run the code, you will get a UI like the one below:
create ui for ml model using gradio
You can upload/drag-and-drop and image on the left, click on submit, and the predictions will show on the right:
vgg16 classification of images
The Gradio website has a number of other examples including one where you use the MNIST dataset to get predictions on your hand-written digits. The URL generated is valid for a certain amount of time, if you want them to be permanently available you can get in touch with them. Isn't that simple? Well, other than creating the models part, it sure is. So go ahead, give it a try, but don't forget to show us some Social Media love by sharing this on Facebook.
« PREV
NEXT »