File size: 640 Bytes
2a6ebd4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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}")