Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import joblib # Replace with torch if using a PyTorch model
|
3 |
+
|
4 |
+
# Load the trained model (ensure the model file is in the same directory)
|
5 |
+
model = joblib.load('path_to_your_model.pkl')
|
6 |
+
|
7 |
+
# Streamlit UI
|
8 |
+
st.title("Sentiment Analysis App using GenAI Models")
|
9 |
+
|
10 |
+
# Text input from the user
|
11 |
+
user_input = st.text_area("Enter text to analyze sentiment:", "")
|
12 |
+
|
13 |
+
# Prediction button
|
14 |
+
if st.button("Analyze"):
|
15 |
+
if user_input:
|
16 |
+
# Perform prediction
|
17 |
+
prediction = model.predict([user_input])
|
18 |
+
sentiment = "Positive" if prediction[0] == 1 else "Negative"
|
19 |
+
st.write(f"**Predicted Sentiment:** {sentiment}")
|
20 |
+
else:
|
21 |
+
st.warning("Please enter some text to analyze.")
|
22 |
+
|
23 |
+
# Optional: Footer
|
24 |
+
st.write("---")
|
25 |
+
st.caption("Built with Streamlit and GenAI models.")
|