File size: 389 Bytes
b4d301c
e3ac475
b4d301c
e3ac475
 
b4d301c
e3ac475
 
b4d301c
e3ac475
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import gradio as gr
from transformers import pipeline

# 直接加载 Hugging Face 模型
classifier = pipeline("text-classification", model="bert-base-uncased")

def predict(text):
    return classifier(text)

demo = gr.Interface(
    fn=predict,
    inputs=gr.Textbox(label="输入文本"),
    outputs=gr.Label(label="分类结果"),
    title="BERT 文本分类演示",
)
demo.launch()