Spaces:
Runtime error
Runtime error
File size: 846 Bytes
39b0cd2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
import gradio as gr
from transformers import pipeline
RACISM_MODEL = "davidmasip/racism"
racism_analysis_pipe = pipeline("text-classification",
model=RACISM_MODEL, tokenizer=RACISM_MODEL)
def racism_analysis(text):
results = racism_analysis_pipe(text)
return results[0]["label"], round(results[0]["score"], 5)
gradio_ui = gr.Interface(
fn=racism_analysis,
title="Racism Detector (Spanish)",
description="Enter some text and check if model detects bullying.",
inputs=[
gr.inputs.Textbox(lines=5, label="Paste some text here"),
],
outputs=[
gr.outputs.Textbox(label="Label"),
gr.outputs.Textbox(label="Score"),
],
examples=[
["Eres mas alto que un pino y mas tonto que un pepino!"],
["Que divertida"]
],
)
gradio_ui.launch()
|