Javier Beltrán
Update interface
a8cc435
raw
history blame
751 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(placeholder="Paste a tweet here", label="Tweet text"),
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!",
theme="huggingface")
interface.launch()