prd101-wd/model_testing
0
1import streamlit as st2from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline3 4# Load model and tokenizer5model_name = "prd101-wd/phi1_5-sentiment-merged"6tokenizer = AutoTokenizer.from_pretrained(model_name)7model = AutoModelForSequenceClassification.from_pretrained(model_name)8 9# Create a pipeline10classifier = pipeline("text-classification", model=model, tokenizer=tokenizer)11 12# Streamlit UI13st.title("Sentiment Classifier")14 15text = st.text_area("Enter text to classify:")16 17if st.button("Classify"):18 if text.strip():19 result = classifier(text)[0]20 st.markdown(f"**Label:** {result['label']} \n**Score:** {result['score']:.4f}")21 else:22 st.warning("Please enter some text.")23 