Getting started with Gradio
In this section, we will learn about the bare minimum setup needed to spin up a Gradio application:
- Install Gradio using
pip
:pip install gradio
Please also ensure you update the following two packages to the newest version:
click
anduvicorn
:pip install -U click
pip install -U uvicorn
- Create a Jupyter Notebook cell and write or copy the following code in the cell:
import gradio
def greet(name):
return "Hello " + name + "!"
demo = gradio.Interface(
fn = greet,
inputs = "text",
outputs = "text"
)
demo.launch()
Executing it will not pop out a new web browser window. Instead, the UI will be embedded inside the Jupyter Notebook result panel.
Of course, you can copy and paste the local URL – http: //127.0.0 .1:78 60
– to any local browser to view it.
Be aware that the next time you execute the code...