Spaces:
Sleeping
Sleeping
| 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() |