import streamlit as st from transformers import pipeline import os streamlit_data_dir = "/app/.streamlit" # Load the sentiment analysis pipeline with your fine-tuned model @st.cache_resource def load_model(): # Replace "johnnas12/sentiment-bert" with your actual model repository ID if different model_id = "johnnas12/sentiment-bert" sentiment_pipeline = pipeline("sentiment-analysis", model=model_id) return sentiment_pipeline sentiment_analyzer = load_model() st.title("Eco-Friendly Tweet Sentiment Analyzer") user_input = st.text_area("Enter your eco-friendly tweet here:") if st.button("Analyze Sentiment"): if user_input: result = sentiment_analyzer(user_input) label = result[0]['label'] score = result[0]['score'] if label == 'LABEL_1': st.write(f"Sentiment: Its Positive tweet") st.write(f"Confidence Score: {score:.4f}") else: st.write(f"Sentiment: Its Negative tweet") st.write(f"Confidence Score: {score:.4f}") else: st.write("Please enter some text to analyze.")