Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -1,22 +1,27 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
st.title("Text Sentiment Analysis ππ")
|
| 12 |
|
| 13 |
-
# Create a text input for a single sentence
|
| 14 |
user_input = st.text_input("Enter a sentence for sentiment analysis:", placeholder="I love this!")
|
| 15 |
|
| 16 |
-
# Add a button to trigger predictions
|
| 17 |
if st.button("Analyze Sentiment"):
|
| 18 |
if user_input:
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
| 21 |
else:
|
| 22 |
st.write("Please enter a sentence to analyze.")
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
from setfit import SetFitModel
|
| 3 |
|
| 4 |
+
@st.cache_resource
|
| 5 |
+
def load_model():
|
| 6 |
+
st.write("Loading model...")
|
| 7 |
+
return SetFitModel.from_pretrained("Tryfonas/setfit-paraphrase-mpnet-base-v2-sst2")
|
| 8 |
|
| 9 |
+
try:
|
| 10 |
+
model = load_model()
|
| 11 |
+
st.write("Model loaded successfully!")
|
| 12 |
+
except Exception as e:
|
| 13 |
+
st.error(f"Failed to load model: {e}")
|
| 14 |
|
| 15 |
st.title("Text Sentiment Analysis ππ")
|
| 16 |
|
|
|
|
| 17 |
user_input = st.text_input("Enter a sentence for sentiment analysis:", placeholder="I love this!")
|
| 18 |
|
|
|
|
| 19 |
if st.button("Analyze Sentiment"):
|
| 20 |
if user_input:
|
| 21 |
+
try:
|
| 22 |
+
predictions = model([user_input])
|
| 23 |
+
st.write(f"Prediction for '{user_input}': {predictions[0]}")
|
| 24 |
+
except Exception as e:
|
| 25 |
+
st.error(f"Error during prediction: {e}")
|
| 26 |
else:
|
| 27 |
st.write("Please enter a sentence to analyze.")
|