Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import transformers
|
2 |
+
import gradio as gr
|
3 |
+
from transformers import pipeline
|
4 |
+
sentiment =pipeline("text-classification", model="tabularisai/multilingual-sentiment-analysis")
|
5 |
+
# Classify a new sentence
|
6 |
+
sentence = "I love this product! It's amazing and works perfectly."
|
7 |
+
result = sentiment(sentence)
|
8 |
+
def get_sentiment(text):
|
9 |
+
result = sentiment(text)
|
10 |
+
label = result[0]['label']
|
11 |
+
score = result[0]['score']
|
12 |
+
return label, score
|
13 |
+
interface = gr.Interface(fn=get_sentiment, inputs= "textbox", outputs=["text","text"])
|
14 |
+
interface.launch()
|