Commit
·
3114278
1
Parent(s):
028424d
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,21 +3,19 @@ from transformers import pipeline
|
|
| 3 |
|
| 4 |
# Title and Subtitle
|
| 5 |
st.title('Sentiment Analysis App')
|
| 6 |
-
st.subheader('Enter text to analyze sentiment')
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
|
|
|
| 10 |
|
| 11 |
if text:
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
|
|
|
| 15 |
|
| 16 |
-
#
|
| 17 |
-
sentiment_label = "Negative" if results[0]['label'] == 'LABEL_1' else "Positive"
|
| 18 |
|
| 19 |
-
# Display sentiment label and probability
|
| 20 |
-
st.subheader('Sentiment Analysis Result:')
|
| 21 |
st.write(f'Sentiment: {sentiment_label}')
|
| 22 |
-
st.write(f'Probability: {
|
| 23 |
|
|
|
|
| 3 |
|
| 4 |
# Title and Subtitle
|
| 5 |
st.title('Sentiment Analysis App')
|
|
|
|
| 6 |
|
| 7 |
+
|
| 8 |
+
pipe=pipeline(model="dancingninjas/sentiment-model")
|
| 9 |
+
text=st.text_area('Enter your text')
|
| 10 |
|
| 11 |
if text:
|
| 12 |
+
out = pipe(text)
|
| 13 |
+
|
| 14 |
+
# Convert the model's output (0 or 1) to descriptive labels
|
| 15 |
+
sentiment_label = "Negative" if out[0]['label'] == 'LABEL_1' else "Positive"
|
| 16 |
|
| 17 |
+
# Display the sentiment label and probability
|
|
|
|
| 18 |
|
|
|
|
|
|
|
| 19 |
st.write(f'Sentiment: {sentiment_label}')
|
| 20 |
+
st.write(f'Probability: {out[0]["score"]:.4f}')
|
| 21 |
|