testSpace / src /streamlit_app.py
WilliamVoster
basic sentiment analysis demo, with defaults
74428fe
raw
history blame contribute delete
636 Bytes
import streamlit as st
from transformers import pipeline
st.title("Sentiment Analysis")
@st.cache_resource
def load_pipe():
return pipeline("sentiment-analysis")
sentiment_analysis_classifier = load_pipe()
user_input = st.text_area("Enter text to analyze:")
if st.button("Analyze"):
if user_input:
result = sentiment_analysis_classifier(user_input)[0]
label = result['label']
score = result['score']
st.write(f"**Sentiment:** {label}")
st.progress(score)
st.write(f"Confidence: {100*score:.2f}%")
else:
st.warning("Please enter some text.")