s297941863's picture
Create app.py
3224a6c verified
raw
history blame
377 Bytes
from transformers import pipeline
import gradio as gr
# 加载预训练的情感分析模型
classifier = pipeline("sentiment-analysis")
# 定义分类函数
def classify_text(text):
result = classifier(text)
return result[0]
# 创建 Gradio 界面
iface = gr.Interface(
fn=classify_text,
inputs="text",
outputs="label"
)
# 启动应用
iface.launch()