Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,19 @@
|
|
1 |
import gradio as gr
|
2 |
from keras.layers import TextVectorization
|
3 |
import tensorflow as tf
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
MAX_FEATURES = 200000
|
6 |
vectorizer = TextVectorization(max_tokens=MAX_FEATURES,
|
7 |
output_sequence_length=1800,
|
8 |
output_mode='int')
|
|
|
|
|
9 |
model = tf.keras.models.load_model('pfilter.h5')
|
10 |
|
11 |
|
@@ -22,5 +30,5 @@ def score_comment(comment):
|
|
22 |
|
23 |
interface = gr.Interface(fn=score_comment,
|
24 |
inputs=gr.components.Textbox
|
25 |
-
(lines=2, placeholder='Comment to Score'),outputs
|
26 |
interface.launch(inline=False)
|
|
|
1 |
import gradio as gr
|
2 |
from keras.layers import TextVectorization
|
3 |
import tensorflow as tf
|
4 |
+
import pandas as pd
|
5 |
+
|
6 |
+
df = pd.read_csv('train.csv')
|
7 |
+
|
8 |
+
X = df['comment_text']
|
9 |
+
y = df[df.columns[2:]].values
|
10 |
|
11 |
MAX_FEATURES = 200000
|
12 |
vectorizer = TextVectorization(max_tokens=MAX_FEATURES,
|
13 |
output_sequence_length=1800,
|
14 |
output_mode='int')
|
15 |
+
vectorizer.adapt(X.values)
|
16 |
+
|
17 |
model = tf.keras.models.load_model('pfilter.h5')
|
18 |
|
19 |
|
|
|
30 |
|
31 |
interface = gr.Interface(fn=score_comment,
|
32 |
inputs=gr.components.Textbox
|
33 |
+
(lines=2, placeholder='Comment to Score'), outputs='text')
|
34 |
interface.launch(inline=False)
|