File size: 412 Bytes
58627d4
 
 
 
757b64b
58627d4
 
 
 
 
cd9cf9e
58627d4
cd9cf9e
58627d4
 
17692e5
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/toxic-gte-small-2")

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

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