Spaces:
Running
Running
Upload app.py
Browse filesuploading app.py
app.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
##Package
|
2 |
+
from transformers import pipeline
|
3 |
+
import gradio as gr
|
4 |
+
|
5 |
+
pipe_new = pipeline(task="text-classification",
|
6 |
+
model="nlptown/bert-base-multilingual-uncased-sentiment")
|
7 |
+
|
8 |
+
def sentiment_score(text):
|
9 |
+
return pipe_new(text)[0]['label']
|
10 |
+
# Create title, description and article strings
|
11 |
+
title = "Sentiment Abalysis"
|
12 |
+
description = "This model predicts the sentiment of the review as a number of stars (between 1 and 5) using nlptown/bert-base-multilingual-uncased-sentiment model"
|
13 |
+
# article = "This model predicts the sentiment of the review as a number of stars (between 1 and 5) using nlptown/bert-base-multilingual-uncased-sentiment model"
|
14 |
+
|
15 |
+
|
16 |
+
demo = gr.Interface(fn=sentiment_score,
|
17 |
+
inputs="text",
|
18 |
+
outputs="text",
|
19 |
+
title=title,
|
20 |
+
description=description)
|
21 |
+
|
22 |
+
# Launch the app!
|
23 |
+
demo.launch()
|
24 |
+
|
25 |
+
|