mytest / app.py
james666600's picture
Update app.py
e3ac475 verified
raw
history blame
389 Bytes
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()