import streamlit as st from transformers import pipeline st.title("Sentiment Analysis") @st.cache_resource def load_pipe(): return pipeline("sentiment-analysis") sentiment_analysis_classifier = load_pipe() user_input = st.text_area("Enter text to analyze:") if st.button("Analyze"): if user_input: result = sentiment_analysis_classifier(user_input)[0] label = result['label'] score = result['score'] st.write(f"**Sentiment:** {label}") st.progress(score) st.write(f"Confidence: {100*score:.2f}%") else: st.warning("Please enter some text.")