midprojectnlp / app.py
syedabdullah32's picture
Rename sentiment-analysisapp.py to app.py
baa3807
raw
history blame
473 Bytes
import streamlit as st
from transformers import pipeline
st.title("Sentiment Analysis App")
# Load sentiment analysis model from Hugging Face
sentiment_analyzer = pipeline("sentiment-analysis")
# User input
sample = st.text_area("Enter a sentence for sentiment analysis:")
# Predict and display result
if st.button("Predict"):
prediction = sentiment_analyzer(sample)[0]
st.success(f"Sentiment: {prediction['label']} with confidence: {prediction['score']:.2f}")