Spaces:
Sleeping
Sleeping
File size: 761 Bytes
430f654 c0bf0db | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | import streamlit as st
import joblib
from pathlib import Path
st.set_page_config(page_title="Sentiment Predictor", layout="centered")
st.title("Sentiment Predictor")
# Load the model pipeline
HERE = Path(__file__).resolve().parent
pipeline = joblib.load(HERE / "pipeline.joblib") # expects pipeline.joblib in same folder (src/)
text = st.text_area("Enter text (one sentence per line)", "I love this\nThis is terrible", height=140)
if st.button("Predict"):
lines = [t.strip() for t in text.splitlines() if t.strip()]
if not lines:
st.warning("Type at least one sentence.")
else:
preds = pipeline.predict(lines)
st.subheader("Predictions")
for s, p in zip(lines, preds):
st.write(f"**{s}** → `{p}`")
|