Spaces:
Sleeping
Sleeping
Initial Commit
Browse files- app.py +18 -0
- hate_speech.h5 +3 -0
app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import tensorflow as tf
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
model = tf.keras.models.load_model('hate_speech.h5')
|
5 |
+
|
6 |
+
def score_comment(comment):
|
7 |
+
vectorized_comment = vectorizer([comment])
|
8 |
+
results = model.predict(vectorized_comment)
|
9 |
+
|
10 |
+
for idx, col in enumerate(df.columns[2:]):
|
11 |
+
if results[0][idx]>0.5:
|
12 |
+
return 'Hate Speech detected'
|
13 |
+
|
14 |
+
return 'No hate speech detected'
|
15 |
+
|
16 |
+
interface = gr.Interface(fn=score_comment,
|
17 |
+
inputs=gr.Textbox(lines=2, placeholder='Comment to score'),
|
18 |
+
outputs='text')
|
hate_speech.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:24dc46ba0841c81a61b48e9b04dbba3c2df4795daf5c4a06d405787ac106a326
|
3 |
+
size 77969552
|