Javier Beltrán
Add application file
ecc3201
raw
history blame
No virus
600 Bytes
import gradio as gr
from transformers import pipeline
def predict(text):
pipe = pipeline("text-classification", model="Newtral/xlm-r-finetuned-toxic-political-tweets-es")
prediction = pipe(text, return_all_scores=True)[0]
return {"Toxic": prediction[0]["score"], "Very Toxic": prediction[1]["score"]}
interface = gr.Interface(predict, gr.inputs.Textbox(), gr.outputs.Label(num_top_classes=2),
capture_session=True, interpretation=None,
title="Is your favorite Spanish politician toxic on Twitter? Test it here!")
interface.launch()