RaviChandera's picture
Update app.py
be8f085
import streamlit as st
from transformers import pipeline
# Set page layout and style
st.set_page_config(
page_title="Sentiment Analysis",
layout="wide",
initial_sidebar_state="expanded",
)
st.markdown(
"""
<style>
.stTextInput > div > div > input {
background-color: #f5f5f5;
border-radius: 5px;
padding: 10px;
font-size: 16px;
}
.stButton > button:first-child {
background-color: #3366ff;
color: white;
font-size: 16px;
padding: 10px 20px;
border-radius: 5px;
border: none;
}
</style>
""",
unsafe_allow_html=True,
)
# Set up sentiment analysis pipeline
pipe = pipeline("sentiment-analysis")
# Streamlit app
st.title("Sentiment Analysis")
text = st.text_area("Enter text")
if st.button("Analyze"):
if text:
out = pipe(text)
st.subheader("Sentiment Analysis Result:")
for result in out:
sentiment = result["label"]
score = result["score"]
st.write(f"- Sentiment: {sentiment}, Score: {score:.2f}")
else:
st.warning("Please enter some text.")