File size: 545 Bytes
9625df9
 
 
140c111
9625df9
 
 
 
 
 
b993134
9625df9
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import gradio as gr
from transformers import pipeline

model = "fasherr/toxicity_rubert"
pipe = pipeline("text-classification", model=model)

def predict(text):
    res = pipe(text)
    return f"{res[0]['label']} - {res[0]['score']:.2%}"

site = gr.Interface(
    fn=predict,
    inputs=gr.Textbox(placeholder="Введите текст"),
    outputs="text",
    title="Классификатор токсичности",
    description="Определение токсичноти текста на русском языке"
)

site.launch()