aandrei404 commited on
Commit
681188b
·
1 Parent(s): d8af741

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import tensorflow as tf
3
+
4
+ model = tf.keras.models.load_model('toxicity.h5')
5
+
6
+ def score_comment(comment):
7
+ vectorized_comment = vectorizer([comment])
8
+ results = model.predict(vectorized_comment)
9
+
10
+ text = ''
11
+ for idx, col in enumerate(df.columns[2:]):
12
+ text += '{}: {}\n'.format(col, results[0][idx]>0.5)
13
+
14
+ return text
15
+
16
+ interface = gr.Interface(fn=score_comment,
17
+ inputs=gr.Textbox(lines=2, placeholder='Comment to score'),
18
+ outputs='text')
19
+
20
+ interface.launch()