Spaces:
Runtime error
Runtime error
Javier Beltrán
commited on
Commit
•
ecc3201
1
Parent(s):
269e804
Add application file
Browse files
app.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
def predict(text):
|
5 |
+
pipe = pipeline("text-classification", model="Newtral/xlm-r-finetuned-toxic-political-tweets-es")
|
6 |
+
prediction = pipe(text, return_all_scores=True)[0]
|
7 |
+
return {"Toxic": prediction[0]["score"], "Very Toxic": prediction[1]["score"]}
|
8 |
+
|
9 |
+
interface = gr.Interface(predict, gr.inputs.Textbox(), gr.outputs.Label(num_top_classes=2),
|
10 |
+
capture_session=True, interpretation=None,
|
11 |
+
title="Is your favorite Spanish politician toxic on Twitter? Test it here!")
|
12 |
+
|
13 |
+
interface.launch()
|
14 |
+
|
15 |
+
|
16 |
+
|