Configs2026年3月31日·1 分钟阅读

Gradio — Build ML Demos & AI Apps in Python

Python library for building interactive ML demos and AI web apps. Chat interfaces, file upload, image/audio/video I/O. Share with public link. 42K+ stars.

TO
TokRepo精选 · Community
快速使用

先拿来用,再决定要不要深挖

这里应该同时让用户和 Agent 知道第一步该复制什么、安装什么、落到哪里。

pip install gradio
import gradio as gr

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

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

Open http://localhost:7860 — shareable with a public link via share=True.


介绍

Gradio is the standard Python library for building interactive ML demos and AI web applications. Create chat interfaces, image generators, audio processors, and data tools with a few lines of Python — no frontend code needed. Used by Hugging Face, Stability AI, and thousands of ML projects. Automatically generates a web UI and optional public share link. 42,000+ GitHub stars, Apache 2.0.

Best for: ML engineers and researchers who need a quick web interface for their models Works with: Any Python ML library — PyTorch, TensorFlow, Hugging Face, OpenAI, Anthropic, Ollama


Key Features

Pre-Built Components

30+ I/O components: Textbox, Chatbot, Image, Audio, Video, File, DataFrame, Plot, Code, Markdown, and more.

Chat Interface

Production-ready chat UI in 3 lines:

gr.ChatInterface(fn=my_llm_function).launch()

Streaming

Real-time streaming for LLM responses, audio, and video.

Blocks API

Full layout control for complex multi-component apps:

with gr.Blocks() as demo:
    with gr.Row():
        input = gr.Textbox()
        output = gr.Textbox()
    btn = gr.Button("Submit")
    btn.click(fn=process, inputs=input, outputs=output)

Sharing

demo.launch(share=True) generates a public URL — share your app instantly without deployment.

Hugging Face Spaces

Deploy Gradio apps to Hugging Face Spaces for free permanent hosting.


FAQ

Q: What is Gradio? A: A Python library for building ML demos and AI web apps with interactive UIs. Chat, images, audio, video — no frontend code needed. 42K+ stars, used by Hugging Face.

Q: How is Gradio different from Streamlit? A: Gradio is ML-focused with specialized components (image/audio/video I/O, model inference). Streamlit is broader for data apps. Gradio has native Hugging Face Spaces integration.


🙏

来源与感谢

Created by Gradio. Licensed under Apache 2.0. gradio-app/gradio — 42,000+ GitHub stars

相关资产