or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

components.mdcore-applications.mdevents.mdexternal-integration.mdindex.mdlayouts.mdthemes.mdutilities.md
tile.json

tessl/pypi-gradio

Python library for easily interacting with trained machine learning models

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/gradio@5.44.x

To install, run

npx @tessl/cli install tessl/pypi-gradio@5.44.0

index.mddocs/

Gradio

Gradio is an open-source Python framework that enables developers to quickly build and deploy web applications for machine learning models, APIs, and arbitrary Python functions. It provides a simple, declarative interface for creating interactive demos and web apps without requiring JavaScript, CSS, or web hosting expertise.

Package Information

  • Package Name: gradio
  • Language: Python
  • Installation: pip install gradio
  • Python Requirements: >=3.10

Core Imports

import gradio as gr

Common pattern for building interfaces:

import gradio as gr

# For simple function interfaces
interface = gr.Interface(...)

# For custom layouts and interactions  
with gr.Blocks() as demo:
    # Add components and define interactions
    pass

Basic Usage

Simple Function Interface

import gradio as gr

def greet(name):
    return f"Hello {name}!"

# Create interface automatically
interface = gr.Interface(
    fn=greet,
    inputs="text",
    outputs="text",
    title="Greeting App"
)

interface.launch()

Custom Layout with Blocks

import gradio as gr

def process_text(text):
    return text.upper()

with gr.Blocks() as demo:
    gr.Markdown("# Text Processor")
    
    with gr.Row():
        input_text = gr.Textbox(label="Input")
        output_text = gr.Textbox(label="Output")
    
    submit_btn = gr.Button("Process")
    submit_btn.click(
        fn=process_text,
        inputs=input_text,
        outputs=output_text
    )

demo.launch()

Chat Interface

import gradio as gr

def chatbot_response(message, history):
    return f"You said: {message}"

chat_interface = gr.ChatInterface(
    fn=chatbot_response,
    title="Simple Chatbot"
)

chat_interface.launch()

Architecture

Gradio follows a component-based architecture with several key concepts:

  • Applications: High-level containers (Interface, Blocks, ChatInterface) that manage the overall app structure and serve web interfaces
  • Components: UI elements for input/output (Textbox, Button, Image, etc.) that handle data display and user interaction
  • Layouts: Container components (Row, Column, Tabs) that organize component positioning and visual structure
  • Events: Reactive system connecting user interactions to Python functions through declarative event handlers
  • Themes: Styling system with predefined themes and customization options for visual appearance
  • State Management: Mechanisms for maintaining data across interactions using State and session handling

This architecture enables rapid prototyping of ML interfaces while supporting production deployment with authentication, real-time updates, and cloud integration.

Capabilities

Core Applications

Foundation classes for building different types of Gradio applications, from simple function wrappers to complex multi-component interfaces.

class Interface:
    def __init__(self, fn, inputs, outputs, **kwargs): ...
    def launch(self, **kwargs): ...

class Blocks:
    def __enter__(self): ...
    def __exit__(self, *args): ...
    def launch(self, **kwargs): ...

class ChatInterface:  
    def __init__(self, fn, **kwargs): ...
    def launch(self, **kwargs): ...

class TabbedInterface:
    def __init__(self, interface_list, tab_names, **kwargs): ...
    def launch(self, **kwargs): ...

Core Applications

Input/Output Components

Comprehensive set of UI components for handling different data types including text, media files, forms, and specialized interfaces.

class Textbox:
    def __init__(self, value=None, label=None, **kwargs): ...

class Button:
    def __init__(self, value=None, **kwargs): ...
    def click(self, fn, inputs=None, outputs=None, **kwargs): ...

class Image:
    def __init__(self, value=None, **kwargs): ...

class Audio:
    def __init__(self, value=None, **kwargs): ...

class File:
    def __init__(self, value=None, **kwargs): ...

class Slider:
    def __init__(self, minimum=0, maximum=100, **kwargs): ...

class Dropdown:
    def __init__(self, choices=None, **kwargs): ...

Input/Output Components

Layout System

Container components for organizing UI elements into structured layouts with responsive design support.

class Row:
    def __enter__(self): ...
    def __exit__(self, *args): ...

class Column:
    def __enter__(self): ...
    def __exit__(self, *args): ...

class Tabs:
    def __enter__(self): ...
    def __exit__(self, *args): ...

class Tab:
    def __init__(self, label, **kwargs): ...
    def __enter__(self): ...
    def __exit__(self, *args): ...

Layout System

Event Handling

Reactive event system for connecting user interactions to Python functions with comprehensive event data and dependency management.

class EventData:
    def __init__(self, target, data): ...

def on(triggers, fn, inputs=None, outputs=None, **kwargs): ...

class SelectData(EventData): ...
class KeyUpData(EventData): ...
class LikeData(EventData): ...

Event Handling

Theme System

Comprehensive theming system with predefined themes and utilities for customizing visual appearance and branding.

class Theme:
    def __init__(self, **kwargs): ...

class Base(Theme): ...
class Default(Theme): ...
class Glass(Theme): ...
class Monochrome(Theme): ...

class Color:
    def __init__(self, *args, **kwargs): ...

class Font:
    def __init__(self, *args, **kwargs): ...

Theme System

Utilities and Helpers

Support functions and classes for progress tracking, notifications, examples, and integration with external systems.

class Progress:
    def __init__(self, track_tqdm=False): ...
    def __call__(self, iterable): ...

class Examples:
    def __init__(self, examples, inputs, **kwargs): ...

def Info(message): ...
def Warning(message): ...
def Success(message): ...

def update(**kwargs): ...
def skip(): ...

Utilities and Helpers

External Integration

Functions for loading models from Hugging Face, integrating with existing web frameworks, and working with external APIs.

def load(name, **kwargs): ...
def load_chat(name, **kwargs): ...
def load_openapi(url, **kwargs): ...

def mount_gradio_app(app, gradio_app, path): ...

class Request:
    def __init__(self, request): ...

External Integration