Javier Beltrán
UI details
79545fc
raw
history blame
956 Bytes
import gradio as gr
from transformers import pipeline
pipe = pipeline("text-classification", model="Newtral/xlm-r-finetuned-toxic-political-tweets-es")
def predict(text):
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(placeholder="Paste a tweet here", label="Tweet text", lines=5),
gr.outputs.Label(num_top_classes=2, label="This tweet is..."),
capture_session=True, interpretation=None,
title="Is your favorite Spanish politician toxic on Twitter? Test it here!",
description="Paste a tweet text from a Spanish politician in the textbox below. We will predict its degree of toxicity in 2 scales of severity. Made with <3 by Newtral-Tech.",
theme="darkgrass")
interface.launch()