Tryfonas's picture
Upload folder using huggingface_hub
477601e verified
raw
history blame contribute delete
845 Bytes
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.")