File size: 636 Bytes
74428fe
29f1a9c
74428fe
 
 
 
 
 
 
29f1a9c
 
74428fe
29f1a9c
 
74428fe
29f1a9c
 
74428fe
 
 
 
29f1a9c
74428fe
 
 
 
 
 
 
 
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

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.")