test-2 / app.py
eagletiger1's picture
Create app.py
2a6ebd4 verified
raw
history blame contribute delete
640 Bytes
import streamlit as st
from transformers import pipeline
# Load a pre-trained sentiment-analysis pipeline
classifier = pipeline("sentiment-analysis")
# Streamlit app
st.title("Sentiment Analysis with Hugging Face Transformers")
st.write("Enter text below to analyze sentiment:")
# Text input
user_input = st.text_area("Text Input", "Enter your text here...")
if st.button("Analyze"):
# Perform sentiment analysis
results = classifier(user_input)
sentiment = results[0]['label']
score = results[0]['score']
# Display results
st.write(f"Sentiment: {sentiment}")
st.write(f"Confidence Score: {score:.2f}")