Introduction to Gradio
Get introduced to Gradio and the application we are going to build using Gradio!
What is Gradio?
Gradio is a powerful and user-friendly open-source Python library that simplifies the process of developing user interfaces for machine learning models. With Gradio, we can easily share machine learning models and create interactive apps that allow users to try out the demo in their browsers. Gradio is increasingly becoming popular because it allows us to easily wrap models in a user interface that can be deployed in just a few lines of code.
Here are just a few benefits of Gradio:
Abstracts away the complexities of building a user interface and deployment
Supports a variety of input and output types and simplifies the data and modelling pipelines
Allows non-technical users to interact with models in just a few lines of code
Learning Gradio through building an application
In this course, we will learn the different functionalities of Gradio by building an application together. In each lesson, we will first introduce new concepts, and then we will consolidate this knowledge by building upon our application to include more features. This way, we can apply what we learn and see the application improve with each lesson. Let’s have a look at the first application we’ll be building!
Property viewer application: Background
Finding the right property can be very difficult. There are many things to consider when choosing a suitable property for one’s needs. A typical property search includes some of these steps:
Examining historical sales to understand which suburbs fit one’s budget
Identifying key features that are important to the buyer from its listing description
Going through listing images and identifying what features the property has
Is the property on a quiet street or a busy road?
The list of things to consider can be endless. What if we could build an application that will help buyers navigate this process and identify whether a property is suitable for their needs? We‘re going to build an application in Gradio that will do exactly this!
Running code snippets in this course
There will frequently be code snippets that can be executed. This demonstrates how the Gradio application works and allows you to play around with it!
Each of these code snippets will build a Gradio application. Each script is contained in a main.py
file. At the bottom, there is a ‘Run’ button. Click the button and it creates the environment that builds the Gradio app. Once it is complete, the Gradio application will be displayed in the output.
Have a go at running this code snippet below!
import gradio as gr def greet(name): return "Welcome " + name + " to the Educative course ‘Introduction to Gradio’!" demo = gr.Interface( fn=greet, inputs=gr.Textbox(lines=2, placeholder="Name Here..."), outputs=gr.Textbox(), ) demo.launch(server_name="0.0.0.0", server_port=3000)
In this lesson, we have learned about Gradio and its benefits. We have also demonstrated Gradio’s usage through a basic example and introduced an application that we will build upon throughout this course.