File size: 343 Bytes
58627d4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import gradio as gr
from setfit import SetFitModel


model = SetFitModel.from_pretrained("johnpaulbin/beanbox-toxic")

def inf(inpt):
    out = model.predict_proba([inpt])
    
    if out[0][0] > out[0][1]:
        return "Not toxic"
    else:
        return "Toxic!"

iface = gr.Interface(fn=inf, inputs="text", outputs="text")
iface.launch()