DrishtiSharma commited on
Commit
479d51b
1 Parent(s): e25b9d2

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import gradio.inputs
3
+ import pandas as pd
4
+ import numpy as np # linear algebra
5
+ import os #interacting with input and output directories
6
+ import tensorflow as tf #framework for creating the neural network
7
+ from tensorflow.keras.preprocessing.sequence import pad_sequences
8
+ import pickle
9
+ with open('tokenizer.pickle', 'rb') as handle:
10
+ tokenizer = pickle.load(handle)
11
+ # loading
12
+ def fn(X_test):
13
+ sentiment = ['Do you really dislike the movie so much?','Hmm...your thoughts are neutral about the movie.','Wow! Your a big fan.']
14
+ sequence_test = tokenizer.texts_to_sequences([X_test])
15
+ padded_test = pad_sequences(sequence_test, maxlen= 52)
16
+ Xtest=padded_test
17
+ model = tf.keras.models.load_model(os.path.join(os.getcwd(), 'deepverse.h5'))
18
+ X = [Xtest for _ in range(len(model.input))]
19
+ a=model.predict(X, verbose=0)
20
+ return sentiment[np.around(a, decimals=0).argmax(axis=1)[0]]
21
+ description = "Give a review of a movie that you like(or hate, sarcasm intended XD) and the model will let you know just how much your review truely reflects your emotions. "
22
+ here = gr.Interface(fn,
23
+ inputs= gradio.inputs.Textbox( lines=1, placeholder=None, default="", label=None),
24
+ outputs='text',
25
+ title="Sentiment analysis of movie reviews",
26
+ description=description,
27
+ theme="peach",
28
+ allow_flagging="auto",
29
+ flagging_dir='flagging records')
30
+ here.launch(inline=False, share = True)
31
+
32
+
33
+
34
+