demo / app.py
vishalkatheriya's picture
Update app.py
d6e2b8d verified
import streamlit as st
from transformers import pipeline
# Set up the sentiment analysis pipeline
pipe = pipeline("sentiment-analysis")
# Create a header for the app
st.set_page_config(page_title="Sentiment Analysis", page_icon=":chart_with_upwards_trend:", layout="wide")
st.title("Sentiment Analysis for Text")
# Add a text area for user input
text = st.text_area("Enter your text:", height=150)
# Add a button for processing the input
if st.button("Check Sentiment", key="check_button"):
if text:
with st.spinner('Analyzing...'):
out = pipe(text)
st.json(out)
else:
st.error("Please add text before checking sentiment!")
# Add some additional styling
st.markdown(
"""
<style>
.stTextInput>div>div>input {
border: 2px solid #007BFF;
border-radius: 8px;
padding: 10px;
font-size: 16px;
}
.stButton>button {
background-color: #007BFF;
color: white;
border-radius: 8px;
padding: 10px;
font-size: 16px;
border: none;
}
.stButton>button:hover {
background-color: #0056b3;
}
</style>
""", unsafe_allow_html=True
)