Spaces:
Sleeping
Sleeping
File size: 737 Bytes
3717835 54f1bf7 3717835 54f1bf7 3717835 54f1bf7 3717835 54f1bf7 3717835 54f1bf7 |
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
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.")
|