Spaces:
Sleeping
Sleeping
File size: 863 Bytes
6af6114 15f9a29 6af6114 15f9a29 6af6114 15f9a29 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
import streamlit as st
from transformers import pipeline
# Load the sentiment analysis pipeline
@st.cache_resource
def load_model():
return pipeline("sentiment-analysis")
def main():
st.title("Sentiment Analysis App")
# Create text input
user_input = st.text_area("Enter text for sentiment analysis:")
# Analyze button
if st.button("Analyze Sentiment"):
if user_input:
# Load model
sentiment_model = load_model()
# Perform sentiment analysis
result = sentiment_model(user_input)[0]
# Display results
st.write("Sentiment:", result['label'])
st.write("Confidence Score:", f"{result['score']:.2%}")
else:
st.warning("Please enter some text to analyze.")
if __name__ == "__main__":
main() |