Spaces:
Runtime error
Runtime error
File size: 956 Bytes
ecc3201 e121820 ecc3201 79545fc a8cc435 ecc3201 a8cc435 6e21664 ecc3201 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
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()
|