|
import streamlit as st
|
|
from transformers import pipeline
|
|
|
|
|
|
MODEL_NAME = "Tryfonas/fine-tuned-bert-classifier-bds24"
|
|
classifier = pipeline("text-classification", model=MODEL_NAME)
|
|
|
|
|
|
st.title("BERT Text Classifier")
|
|
st.write("Enter text below to classify:")
|
|
|
|
|
|
user_input = st.text_area("Input Text", "Type here...")
|
|
|
|
if st.button("Classify"):
|
|
if user_input.strip():
|
|
|
|
result = classifier(user_input)
|
|
|
|
|
|
label = result[0]['label']
|
|
confidence = result[0]['score']
|
|
|
|
|
|
if label == "LABEL_1":
|
|
sentiment = "Positive 😊"
|
|
elif label == "LABEL_0":
|
|
sentiment = "Negative 😞"
|
|
else:
|
|
sentiment = "Unknown 🤔"
|
|
|
|
|
|
st.subheader("Prediction:")
|
|
st.write(f"**Sentiment:** {sentiment}")
|
|
else:
|
|
st.warning("Please enter some text.")
|
|
|