import streamlit as st from transformers import pipeline, AutoConfig # Initialize the sentiment analysis pipeline pipe = pipeline('sentiment-analysis') # App Title st.title("AI in Marketing | AI Driven | Text to Sentiment Analysis App | by Darren Field") #st.text("Enter your text and click the 'Analyze Sentiment' button to submit.") # Get the model name model_name = pipe.model.name_or_path # Get more detailed information about the model config = AutoConfig.from_pretrained(model_name) # Text input area text = st.text_area('Enter text including your sentiment.') # Submit button if st.button('Analyze Sentiment'): if text: out = pipe(text) st.json(out) # Check if sentiment is positive and display balloons if out[0]['label'] == 'POSITIVE': st.balloons() st.success("Positive sentiment detected! 🎉") else: st.info("Sentiment is not positive.") else: st.warning("Please enter some text before analyzing.")