Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from setfit import SetFitModel
|
| 3 |
+
|
| 4 |
+
model = SetFitModel.from_pretrained("setfit-italian-hate-speech")
|
| 5 |
+
|
| 6 |
+
dictionary={'0':'not-hateful',
|
| 7 |
+
'1':'hateful',}
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def greet(text, dictionary=dictionary):
|
| 11 |
+
preds = model(text)
|
| 12 |
+
return dictionary[response[0]['label']]
|
| 13 |
+
|
| 14 |
+
demo = gr.Interface(fn=greet,
|
| 15 |
+
inputs="text",
|
| 16 |
+
outputs="text",
|
| 17 |
+
title="Italian Hate Speech",
|
| 18 |
+
description="Detect Hate Speech",
|
| 19 |
+
examples=[["Brutta e bugiarada da fare schifo"],["È quello ke ho sempre detto io ,e ha ki ruba tagliare la mano,ci penserebbero bene!"],["Mi piace la pizza ai peperoni!"]],
|
| 20 |
+
cache_examples=False)
|
| 21 |
+
|
| 22 |
+
demo.launch()
|