Course documentation

Introduction to Gradio

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

Introduction to Gradio

Ask a Question

In this chapter we will be learning about how to build interactive demos for your machine learning models.

Why build a demo or a GUI for your machine learning model in the first place? Demos allow:

  • Machine learning developers to easily present their work to a wide audience including non-technical teams or customers
  • Researchers to more easily reproduce machine learning models and behavior
  • Quality testers or end users to more easily identify and debug failure points of models
  • Diverse users to discover algorithmic biases in models

We’ll be using the Gradio library to build demos for our models. Gradio allows you to build, customize, and share web-based demos for any machine learning model, entirely in Python.

Here are some examples of machine learning demos built with Gradio:

  • A sketch recognition model that takes in a sketch and outputs labels of what it thinks is being drawn:
  • An extractive question answering model that takes in a context paragraph and a quest and outputs a response and a probability score (we discussed this kind of model in Chapter 7):
  • A background removal model that takes in an image and outputs the image with the background removed:

This chapter is broken down into sections which include both concepts and applications. After you learn the concept in each section, you’ll apply it to build a particular kind of demo, ranging from image classification to speech recognition. By the time you finish this chapter, you’ll be able to build these demos (and many more!) in just a few lines of Python code.

👀 Check out Hugging Face Spaces to see many recent examples of machine learning demos built by the machine learning community!