Spaces:
Runtime error
Runtime error
File size: 600 Bytes
ecc3201 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
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()
|