Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import pipeline | |
| # 加载情感分析模型 | |
| classifier = pipeline("sentiment-analysis") | |
| # 定义处理用户输入的函数 | |
| def classify_text(text): | |
| # 使用模型进行情感分类 | |
| result = classifier(text) | |
| return result[0] | |
| # 创建Gradio界面 | |
| iface = gr.Interface(fn=classify_text, inputs="text", outputs="json") | |
| # 启动Gradio界面 | |
| iface.launch() | |