File size: 622 Bytes
554dae3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import gradio as gr
from setfit import SetFitModel

model = SetFitModel.from_pretrained("setfit-italian-hate-speech")

dictionary={'0':'not-hateful',
'1':'hateful',}


def greet(text, dictionary=dictionary):
  preds = model(text)
  return dictionary[response[0]['label']]

demo = gr.Interface(fn=greet, 
  inputs="text", 
  outputs="text", 
  title="Italian Hate Speech",
  description="Detect Hate Speech",
  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!"]],
  cache_examples=False)

demo.launch()