Gradio is an open source Python library for quickly wrapping machine-learning models, data-science workflows, and application functions in customizable web interfaces. Users can submit text, images, or audio and view results interactively. section 1.3 section 10.0
A minimal Gradio application
Define a Python function, pass it to gr.Interface with matching input and output types, and call launch(): import gradio as gr def my_chatbot(message): return "Hello, " + message interface = gr.Interface(fn=my_chatbot, title="Hello, Gradio!", inputs="text", outputs="text") interface.launch() Gradio renders the input and output text boxes, passes submitted input to the function, and displays its return value. section 10.1.1
A Gradio workflow commonly connects:
- A model function to input and output components, such as Image, Textbox, or Audio. section 4.4.2 section 10.4
- A computer-vision function that receives an image as a NumPy array, converts it to a PIL image, and returns a masked result. section 4.4.2
- A query engine or language model to produce text responses through a simple interface or a stateful chatbot. section 7.3.10 section 11.2.6
Listing 10.1 A simple Gradio example
import gradio as gr
def my_chatbot(message):
return "Hello, " + message
interface = gr.Interface(fn = my_chatbot, #1
title = "Hello, Gradio!", #2
inputs = "text", #3
outputs = "text") #4
interface.launch()
Inspect the complete minimal Interface example, including the wrapped function, title, text components, and launch call. section 10.1.1
Use launch() for local access, authentication, local-network access, or temporary public sharing. Shared links depend on the running local process, expire after 72 hours, and Hugging Face Spaces provides a longer-term hosting option. section 10.1.5 section 10.4


