File size: 530 Bytes
483dd11
 
 
 
 
 
2c6eb42
483dd11
 
 
c06f677
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import streamlit as st
from transformers import pipeline

# Title and Subtitle
st.title('Sentiment Analysis App')

pipe=pipeline(model="dancingninjas/sentiment-model")
text=st.text_area('Enter your text')

if text:
    out = pipe(text)

    # Convert the model's output (0 or 1) to descriptive labels
    sentiment_label = "Positive" if out[0]['label'] == 'LABEL_1' else "Negative"

    # Display the sentiment label and probability
    st.write(f'Sentiment: {sentiment_label}')
    st.write(f'Probability: {out[0]["score"]:.4f}')