Spaces:
Runtime error
Runtime error
Commit
·
efb3a3f
1
Parent(s):
214013d
Update app.py
Browse files
app.py
CHANGED
@@ -1,10 +1,13 @@
|
|
|
|
1 |
from transformers import pipeline
|
2 |
|
3 |
-
|
4 |
nlp = pipeline("sentiment-analysis")
|
5 |
|
6 |
def scoring(text):
|
7 |
results = nlp(text)
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
|
|
4 |
nlp = pipeline("sentiment-analysis")
|
5 |
|
6 |
def scoring(text):
|
7 |
results = nlp(text)
|
8 |
+
sentiment = results[0]['label'] # Get the sentiment label (e.g., 'LABEL_1' or 'LABEL_2')
|
9 |
+
score = results[0]['score'] # Get the sentiment score
|
10 |
+
return f"Sentiment: {sentiment}, Score: {score}"
|
11 |
+
|
12 |
+
iface = gr.Interface(fn=scoring, inputs="text", outputs="text")
|
13 |
+
iface.launch()
|