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()