Spaces:
Runtime error
Runtime error
Shruhrid Banthia
commited on
Commit
·
a93dc34
1
Parent(s):
a64fcd3
First
Browse files- app.py +34 -0
- deepverse.h5 +3 -0
- tokenizer.pickle +0 -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 |
+
|
deepverse.h5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f8f1f6dc6d025716f12fefe216f8786984a766bea583999cab9b97f5bc278ff6
|
| 3 |
+
size 11804512
|
tokenizer.pickle
ADDED
|
Binary file (729 kB). View file
|
|
|