Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,16 +1,21 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
|
| 3 |
from transformers import pipeline
|
| 4 |
|
| 5 |
sentiment = pipeline("sentiment-analysis")
|
| 6 |
|
| 7 |
def get_sentiment(input_text):
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
-
demo = gr.Interface(fn = get_sentiment,
|
| 11 |
-
inputs = 'text',
|
| 12 |
-
outputs = ['text'],
|
| 13 |
-
title = 'Sentiment Analysis Demo (ζ
η·εζη€Ίη―)',
|
| 14 |
-
description = "Analyze the sentiment based on given input (positive or negative) ζ
η·εζ"
|
| 15 |
-
)
|
| 16 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
sentiment = pipeline("sentiment-analysis")
|
| 5 |
|
| 6 |
def get_sentiment(input_text):
|
| 7 |
+
result = sentiment(input_text)
|
| 8 |
+
labels = [item['label'] for item in result]
|
| 9 |
+
scores = [item['score'] for item in result]
|
| 10 |
+
return labels, scores
|
| 11 |
+
|
| 12 |
+
demo = gr.Interface(
|
| 13 |
+
fn=get_sentiment,
|
| 14 |
+
inputs="text",
|
| 15 |
+
outputs=[gr.Textbox(label="Label"), gr.Textbox(label="Score")],
|
| 16 |
+
title = 'Sentiment Analysis Demo (ζ
η·εζη€Ίη―)',
|
| 17 |
+
description = "Analyze the sentiment based on given input (positive or negative) ζ
η·εζ"
|
| 18 |
+
examples=[["I love Computational Chemistry."], ["This movie is terrible."]],
|
| 19 |
+
)
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
demo.launch()
|