pandalow commited on
Commit
2384f37
·
1 Parent(s): c57d156

Add application file

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+
5
+ def sentiment_analysis(text:str)->str:
6
+ analysis_tools = pipeline("text-classification", model = "boltuix/bert-emotion",device='cuda')
7
+ result = analysis_tools(text)
8
+
9
+ return f"the label: {result[0]['label']} and the score: {result[0]['score']}"
10
+
11
+
12
+
13
+ demo = gr.Interface(fn = sentiment_analysis,
14
+ inputs=['text'],
15
+ outputs = ['text'],
16
+ title="Emotion Detection",
17
+ description="Based on the bert-emotion to detect the emotion in your text",
18
+ examples=[
19
+ ['I hate you'],
20
+ ['You are so kind'],
21
+ ['我想我们可以在一起']
22
+ ]
23
+ )
24
+
25
+ demo.launch()