Gradio

Build ML web interfaces quickly

Creating ML Interfaces with Gradio

Build and share machine learning interfaces with Gradio.

#

Installation

bash
pip install gradio transformers torch

#

Basic Interface

python
import gradio as gr
from transformers import pipeline

generator = pipeline("text-generation", model="gpt2")

def generate_text(prompt): return generator(prompt, max_length=100)[0]["generated_text"]

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

#

Features

  • Automatic UI generation
  • Share with public links
  • Multiple input/output types
  • Integration with HuggingFace Spaces