File size: 405 Bytes
3224a6c
d4861e2
3224a6c
d4861e2
3224a6c
 
d4861e2
3224a6c
d4861e2
3224a6c
 
 
d4861e2
 
3224a6c
d4861e2
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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()