Spaces:
Runtime error
Runtime error
File size: 1,100 Bytes
c65b7e4 b5b9bf6 4aabba6 c65b7e4 3b7ba86 b5b9bf6 c65b7e4 b5b9bf6 c65b7e4 b5b9bf6 c65b7e4 b5b9bf6 c65b7e4 b5b9bf6 c65b7e4 e743a6a b5b9bf6 |
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 |
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.") |