Installation

Install Gradio using pip:

pip install gradio

Quickstart

Here's a simple Gradio app:

import gradio as gr

def greet(name):
    return "Hello " + name + "!"

demo = gr.Interface(fn=greet, inputs="text", outputs="text")
demo.launch()

Interfaces

Gradio provides several types of interfaces:

  • Interface: For simple input-output functions
  • TabbedInterface: For combining multiple interfaces
  • Parallel: For running multiple models in parallel

Components

Gradio comes with many built-in components:

  • Textbox: For text input/output
  • Slider: For numerical input
  • Image: For image input/output
  • Audio: For audio input/output

Deployment

Deploy your Gradio app easily:

demo.launch(share=True)  # Get a public URL
# Or deploy to Hugging Face Spaces:
# https://huggingface.co/spaces