Spaces:
Runtime error
Runtime error
File size: 1,149 Bytes
51767de c34fb10 51767de c34fb10 8132cb4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | 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.")
|