model1 / app.py
engrharis's picture
Create app.py
27b2983 verified
raw
history blame contribute delete
888 Bytes
import streamlit as st
from transformers import pipeline
# Title and Introduction
st.title("Sentiment Analysis App")
st.write("""
This app uses a Hugging Face model to analyze the sentiment of your text.
Type something below and click "Analyze Sentiment" to get started!
""")
# Text Input
user_input = st.text_area("Enter your text here:")
# Perform Sentiment Analysis
if st.button("Analyze Sentiment"):
if user_input.strip() == "":
st.warning("Please enter some text to analyze.")
else:
# Load the sentiment analysis pipeline
sentiment_pipeline = pipeline("sentiment-analysis")
result = sentiment_pipeline(user_input)
# Extract and display results
sentiment = result[0]['label']
confidence = result[0]['score']
st.write(f"**Sentiment:** {sentiment}")
st.write(f"**Confidence Score:** {confidence:.2f}")