datasciencedojo commited on
Commit
c275160
1 Parent(s): 9514c8f

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +16 -0
  2. requirements.txt +5 -0
app.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ classifier = pipeline("text-classification",model='bhadresh-savani/distilbert-base-uncased-emotion', return_all_scores=True)
5
+
6
+ def detect_emotions(emotion_input):
7
+ prediction = classifier(emotion_input,)
8
+ output = {}
9
+ for emotion in prediction[0]:
10
+ output[emotion["label"]] = emotion["score"]
11
+ return output
12
+
13
+ examples = [["I am excited to announce that I have been promoted"], ["Sorry for the late reply"]]
14
+
15
+ demo = gr.Interface(fn=detect_emotions, inputs=gr.Textbox(placeholder="Enter text here", label="Input"), outputs=gr.Label(label="Emotion"), examples=examples)
16
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ gradio
2
+ torch
3
+ timm
4
+ sentencepiece
5
+ transformers