Spaces:
Sleeping
Sleeping
import streamlit as st | |
from transformers import pipeline | |
def load_model(): | |
model_path = "citizenlab/twitter-xlm-roberta-base-sentiment-finetunned" | |
return pipeline("text-classification", model=model_path, tokenizer=model_path) | |
sentiment_classifier = load_model() | |
st.title("Sentiment Analysis Web App") | |
st.write("Enter text to analyze its sentiment (Positive/Negative).") | |
user_input = st.text_area("Enter your text here:") | |
if st.button("Analyze Sentiment"): | |
if user_input.strip(): | |
result = sentiment_classifier(user_input) | |
label = result[0]['label'] | |
score = result[0]['score'] | |
st.write(f"**Sentiment:** {label}") | |
st.write(f"**Confidence Score:** {score:.2f}") | |
else: | |
st.write("Please enter some text to analyze.") | |