Update app.py
Browse files
app.py
CHANGED
|
@@ -6,12 +6,19 @@ classifiers = pipeline(
|
|
| 6 |
model="distilbert/distilbert-base-uncased-finetuned-sst-2-english",
|
| 7 |
)
|
| 8 |
|
| 9 |
-
def
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
demo = gr.Interface(
|
| 13 |
-
fn=
|
| 14 |
inputs="textbox",
|
| 15 |
-
outputs=[
|
|
|
|
|
|
|
|
|
|
| 16 |
)
|
| 17 |
demo.launch()
|
|
|
|
| 6 |
model="distilbert/distilbert-base-uncased-finetuned-sst-2-english",
|
| 7 |
)
|
| 8 |
|
| 9 |
+
def predict_my_sentiment(name):
|
| 10 |
+
prediction = classifiers(name)[0]
|
| 11 |
+
label = prediction['label']
|
| 12 |
+
score = prediction['score']
|
| 13 |
+
|
| 14 |
+
return label,score
|
| 15 |
|
| 16 |
demo = gr.Interface(
|
| 17 |
+
fn=predict_my_sentiment,
|
| 18 |
inputs="textbox",
|
| 19 |
+
outputs=[
|
| 20 |
+
gr.Textbox(label="Sentiment Label"),
|
| 21 |
+
gr.Number(label="Confidence Score")
|
| 22 |
+
]
|
| 23 |
)
|
| 24 |
demo.launch()
|