Dharma20 commited on
Commit
f46ab08
1 Parent(s): 5df86ad

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -0
app.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ from fastai.text.all import*
3
+ import gradio as gr
4
+
5
+ learn = load_learner('nlp_model.pkl')
6
+
7
+ labels = learn.dls.vocab
8
+
9
+ examples = ["I can't believe you lied to me again! This is unacceptable!",
10
+ "Got a surprise gift today, feeling overjoyed!"]
11
+
12
+
13
+
14
+ def classify_text(text):
15
+ pred,pred_idx,probs = learn.predict(text)
16
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
17
+
18
+
19
+ interface = gr.Interface(fn=classify_text,
20
+ inputs = gr.inputs.Texbox(placeholder="Enter Text here", label='Input text',lines=5)),
21
+ outputs=gr.outputs.Label(num_top_classes=4, label='Emotion inthe Text'),
22
+ verbose=True,
23
+ title="Emotion Classifier",
24
+ theme='soft')
25
+
26
+ interface.launch()
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+