model_testing / src /streamlit_app.py
prd101-wd's picture
Update src/streamlit_app.py
54f1bf7 verified
raw
history blame
737 Bytes
import streamlit as st
from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
# Load model and tokenizer
model_name = "prd101-wd/phi1_5-sentiment-merged"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
# Create a pipeline
classifier = pipeline("text-classification", model=model, tokenizer=tokenizer)
# Streamlit UI
st.title("Sentiment Classifier")
text = st.text_area("Enter text to classify:")
if st.button("Classify"):
if text.strip():
result = classifier(text)[0]
st.markdown(f"**Label:** {result['label']} \n**Score:** {result['score']:.4f}")
else:
st.warning("Please enter some text.")