import streamlit as st from transformers import pipeline # Model path model_path = "citizenlab/twitter-xlm-roberta-base-sentiment-finetuned" # Set Streamlit page config st.set_page_config(page_title="Sentiment Analysis App") # Load sentiment analysis model sentiment_classifier = pipeline("text-classification", model=model_path, tokenizer=model_path) # Title and user input st.title("Sentiment Analysis App") user_input = st.text_area("Enter a message:") # Function to add CSS style and icons def custom_css(): st.markdown( """ """, unsafe_allow_html=True, ) # Render the custom CSS custom_css() # Analyze sentiment button if st.button("Analyze Sentiment"): if user_input: # Perform sentiment analysis results = sentiment_classifier(user_input) sentiment_label = results[0]["label"] sentiment_score = results[0]["score"] st.write(f"Sentiment: {sentiment_label}") st.write(f"Confidence Score: {sentiment_score:.2f}")