ashishabraham22 commited on
Commit
a5a950d
1 Parent(s): 111d89f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -0
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from tensorflow.keras.models import load_model
3
+ import prepro
4
+ import numpy as np
5
+ import nltk
6
+
7
+
8
+ def classify(text):
9
+ nltk.download('stopwords')
10
+ model= load_model('nlp3.h5')
11
+ X= prepro.preprocess(text)
12
+ prediction = model.predict(np.array(X))
13
+ # return prediction
14
+ if(prediction<=0.4):
15
+ return "Looks like you are reading negative content. Some words sound negative in context."
16
+ elif(prediction>0.4 and prediction<=0.6):
17
+ return "Sounds Neutral. Speaks generally and not biased towards any value."
18
+ else :
19
+ return "Sounds Positive. Giving a good impression to start reading this stuff. "
20
+
21
+
22
+ iface= gr.Interface(
23
+ inputs=[gr.inputs.Textbox(lines=5, label="Context", placeholder="Type a sentence or paragraph here.")],
24
+ outputs=[gr.outputs.Textbox(label="Prediction")],
25
+ fn=classify,
26
+ title='WATCHA-READIN',
27
+ theme='dark-peach'
28
+ )
29
+
30
+ iface.launch(share=True)