File size: 795 Bytes
36d5e6f
8139db3
36d5e6f
8139db3
 
36d5e6f
 
 
 
 
8139db3
36d5e6f
 
 
 
 
8139db3
 
36d5e6f
 
 
 
 
 
8139db3
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
import streamlit as st
import joblib  # Replace with torch if using a PyTorch model

# Load the trained model (ensure the model file is in the same directory)
model = joblib.load('path_to_your_model.pkl')

# Streamlit UI
st.title("Sentiment Analysis App using GenAI Models")

# Text input from the user
user_input = st.text_area("Enter text to analyze sentiment:", "")

# Prediction button
if st.button("Analyze"):
    if user_input:
        # Perform prediction
        prediction = model.predict([user_input])
        sentiment = "Positive" if prediction[0] == 1 else "Negative"
        st.write(f"**Predicted Sentiment:** {sentiment}")
    else:
        st.warning("Please enter some text to analyze.")

# Optional: Footer
st.write("---")
st.caption("Built with Streamlit and GenAI models.")