Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
sentiment_classifier = pipeline("text-classification", return_all_scores=True)
|
5 |
+
|
6 |
+
def classifier(text):
|
7 |
+
pred = sentiment_classifier(text)
|
8 |
+
return {p["label"]: p["score"] for p in pred[0]}
|
9 |
+
|
10 |
+
with gr.Blocks() as demo:
|
11 |
+
with gr.Row():
|
12 |
+
with gr.Column():
|
13 |
+
input_text = gr.Textbox(label="Input Text")
|
14 |
+
with gr.Row():
|
15 |
+
classify = gr.Button("Done")
|
16 |
+
with gr.Column():
|
17 |
+
label = gr.Label(label="Predicted Sentiment")
|
18 |
+
|
19 |
+
classify.click(classifier, input_text, label)
|
20 |
+
demo.launch()
|