Integrations: Gradio for Quick and Easy Model Testing

Martin Isaksson
3 min readJan 7, 2022
PerceptiLabs and Gradio Integrations.

Many of you from our developer community have asked how to deploy, use, and even test your model once it has been exported from PerceptiLabs. So, we added a Gradio deployment target to PerceptiLabs’ Deploy View back in the 0.13 release. This feature not only deploys your TensorFlow model, but also generates a fully-working GUI in your web browser, through which you can test your model’s real-world inference within minutes.

Let’s take a closer look at this deployment target.

Why Gradio?

We chose Gradio as a testing GUI because it’s quick to generate, lightweight, and intuitive for even non-technical users.

The Gradio deployment target exports a TensorFlow model, and opens a browser-based app as shown in Figure 1:

Figure 1: Screenshot of the basic Gradio GUI.
Figure 1: Screenshot of the basic Gradio GUI.

The Gradio app makes it very easy to test and showcase the inference capabilities of your model. You can easily load different data and see how the model reacts to it. This makes it ideal to let other people try the model, in addition to your own experimentation. The Gradio app automatically customizes itself to the kind of model you are using, so the input and outputs you see are always relevant.

Best of all, any user can easily deploy and test a model with the click of a button.

How the Gradio Deployment Target Works in PerceptiLabs

After deploying your model to the Gradio target using PerceptiLabs, the Gradio app opens in your browser at 127.0.0.1:7860. Then, you drag and drop your data onto the Image box, click Submit, and the app runs your image through the model. The prediction is then shown under the Labels header to the right of the preview. For example, Figure 2 below shows the predicted label for a hand-written image of the number 2:

Figure 2: Screenshot of MNIST data fed into the Gradio app.
Figure 2: Screenshot of MNIST data fed into the Gradio app.

You can then click Clear to clear the data, and repeat the process using other data samples. You also have the option to click Screenshot, which is useful for generating screenshots of the app for review.

Gradio Use Cases

Our blog Integrations: FastAPI for Fast SaaS Application Deployments, described how the FastAPI deployment target provides a client/server model app for getting something running in a production-like environment. On the other hand, the Gradio deployment target is better for quick prototypes, testing, and verification.

The Gradio target is therefore useful for:

  • Quickly performing spot checks of the model on a few data samples to ensure it generally works.
  • Allowing non-technical users to easily drag their data onto the GUI to test the model’s predictions.
  • Trying to break the model (e.g., feeding the model with modified or outlier data samples to test its robustness).
  • Comparing models (e.g., running two deployed apps side-by-side and comparing their predictions on the same data samples).
  • Creating screenshots showing the data and predictions, which can be useful for facilitating team discussions and reviews about model performance.

Gradio Learning Resources

For more information, be sure to check out the Gradio Deployment Guide in PerceptiLabs’ documentation. It provides additional details on what’s exported and how to use it.

Give it a try, and let us know how it worked for you.

And if you don’t already have our free version of PerceptiLabs, be sure to check out our Quickstart Guide.

--

--

Martin Isaksson

Martin Isaksson is Co-Founder and CEO of PerceptiLabs, a startup focused on making machine learning easy.