project_AI / app.py
Ammarzahid's picture
Create app.py
9a96982
raw
history blame
738 Bytes
import streamlit as st
from transformers import pipeline
model_path = "citizenlab/twitter-xlm-roberta-base-sentiment-finetunned"
st.set_page_config(page_title="Sentiment Analysis App")
sentiment_classifier = pipeline("text-classification", model=model_path, tokenizer=model_path)
st.title("Sentiment Analysis App")
user_input = st.text_area("Enter a message:")
if st.button("Analyze Sentiment"):
if user_input:
# Perform sentiment analysis
results = sentiment_classifier(user_input)
sentiment_label = results[0]["label"]
sentiment_score = results[0]["score"]
st.write(f"Sentiment: {sentiment_label}")
st.write(f"Confidence Score: {sentiment_score:.2f}")
# Run the Streamlit app