File size: 845 Bytes
c78f488
8d6519f
c78f488
8d6519f
 
 
 
c78f488
8d6519f
 
 
 
 
c78f488
 
 
 
 
 
 
8d6519f
 
477601e
8d6519f
 
c78f488
 
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
import streamlit as st
from setfit import SetFitModel

@st.cache_resource
def load_model():
    st.write("Loading model...")
    return SetFitModel.from_pretrained("Tryfonas/setfit-paraphrase-mpnet-base-v2-sst2")

try:
    model = load_model()
    st.write("Model loaded successfully!")
except Exception as e:
    st.error(f"Failed to load model: {e}")

st.title("Text Sentiment Analysis 😊😞")

user_input = st.text_input("Enter a sentence for sentiment analysis:", placeholder="I love this!")

if st.button("Analyze Sentiment"):
    if user_input:
        try:
            predictions = model([user_input])
            st.write(f"Prediction: {predictions[0]}")
        except Exception as e:
            st.error(f"Error during prediction: {e}")
    else:
        st.write("Please enter a sentence to analyze.")