test_depl / src /streamlit_app.py
ananyajoshi's picture
Upload folder using huggingface_hub
c0bf0db verified
Raw
History Blame Contribute Delete
761 Bytes
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}`")