Vinayak2104 commited on
Commit
e1110fe
·
1 Parent(s): e86fcb6

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+
3
+ classifier = pipeline("text-classification",
4
+ model="senti")
5
+ def func(text):
6
+ pred=classifier(text)[0]['label']
7
+ if pred=='LABEL_0':
8
+ return 'sadness'
9
+ elif pred=='LABEL_1':
10
+ return 'joy'
11
+ elif pred=='LABEL_2':
12
+ return 'love'
13
+ elif pred=='LABEL_3':
14
+ return 'anger'
15
+ elif pred=='LABEL_4':
16
+ return 'fear'
17
+ elif pred=='LABEL_5':
18
+ return 'surprise'
19
+ import gradio as gr
20
+ descriptions = "This is an AI sentiment analyzer which checks and gets the emotions in a particular text. Just put in a sentence and you'll get the probable emotions behind that sentence"
21
+
22
+ app = gr.Interface(fn=func, inputs="text", outputs="text", title="Sentiment Analayser", description=descriptions)
23
+ app.launch(share=True)