s297941863 commited on
Commit
d4861e2
·
verified ·
1 Parent(s): 69ab8ee

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -11
app.py CHANGED
@@ -1,20 +1,17 @@
1
- from transformers import pipeline
2
  import gradio as gr
 
3
 
4
- # 加载预训练的情感分析模型
5
  classifier = pipeline("sentiment-analysis")
6
 
7
- # 定义分类函数
8
  def classify_text(text):
 
9
  result = classifier(text)
10
  return result[0]
11
 
12
- # 创建 Gradio 界面
13
- iface = gr.Interface(
14
- fn=classify_text,
15
- inputs="text",
16
- outputs="label"
17
- )
18
 
19
- # 启动应用
20
- iface.launch()
 
 
1
  import gradio as gr
2
+ from transformers import pipeline
3
 
4
+ # 加载情感分析模型
5
  classifier = pipeline("sentiment-analysis")
6
 
7
+ # 定义处理用户输入的函数
8
  def classify_text(text):
9
+ # 使用模型进行情感分类
10
  result = classifier(text)
11
  return result[0]
12
 
13
+ # 创建Gradio界面
14
+ iface = gr.Interface(fn=classify_text, inputs="text", outputs="json")
 
 
 
 
15
 
16
+ # 启动Gradio界面
17
+ iface.launch()