toxic-comments / app.py
jazbarr's picture
model testing
e817dcf verified
Raw
History Blame Contribute Delete
535 Bytes
from transformers import pipeline
pipe = pipeline("text-classification", model="jazbarr/jazbarr-toxicidad")
def analizar_texto(texto):
resultado = pipe(texto)[0]
label = resultado['label']
score = resultado['score']
if label == 'LABEL_1':
return f'This comment is toxic (score: {score})'
else:
return f'This comment is not toxic (score: {score}'
import gradio as gr
demo = gr.Interface(
fn=analizar_texto,
inputs=gr.Textbox(label='write a comment'),
outputs=gr.Textbox(label='result')
)
demo.launch()