dancingninjas's picture
Update app.py
3114278
raw
history blame
534 Bytes
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 = "Negative" if out[0]['label'] == 'LABEL_1' else "Positive"
# Display the sentiment label and probability
st.write(f'Sentiment: {sentiment_label}')
st.write(f'Probability: {out[0]["score"]:.4f}')