Spaces:
Runtime error
Runtime error
Javier Beltrán
commited on
Commit
•
e121820
1
Parent(s):
6e21664
Initialize pipe only once and enlarge textbox
Browse files
app.py
CHANGED
@@ -1,12 +1,13 @@
|
|
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(placeholder="Paste a tweet here", label="Tweet text"),
|
10 |
gr.outputs.Label(num_top_classes=2, label="This tweet is..."),
|
11 |
capture_session=True, interpretation=None,
|
12 |
title="Is your favorite Spanish politician toxic on Twitter? Test it here!",
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
pipe = pipeline("text-classification", model="Newtral/xlm-r-finetuned-toxic-political-tweets-es")
|
5 |
+
|
6 |
def predict(text):
|
|
|
7 |
prediction = pipe(text, return_all_scores=True)[0]
|
8 |
return {"Toxic": prediction[0]["score"], "Very Toxic": prediction[1]["score"]}
|
9 |
|
10 |
+
interface = gr.Interface(predict, gr.inputs.Textbox(placeholder="Paste a tweet here", label="Tweet text", lines=10),
|
11 |
gr.outputs.Label(num_top_classes=2, label="This tweet is..."),
|
12 |
capture_session=True, interpretation=None,
|
13 |
title="Is your favorite Spanish politician toxic on Twitter? Test it here!",
|