import streamlit as st
from transformers import pipeline
import torch
# Set page config
st.set_page_config(
page_title="Tweet Classifier",
page_icon="đĻ",
layout="wide"
)
# Custom CSS for better styling
st.markdown("""
""", unsafe_allow_html=True)
# App title
st.markdown('
', unsafe_allow_html=True)
col1, col2 = st.columns([1, 2])
with col1:
st.markdown(f"### {label_colors.get(label, 'âĒ')} **Prediction:**")
color = badge_colors.get(label, "#9E9E9E")
st.markdown(f'
{label.upper()}', unsafe_allow_html=True)
with col2:
st.markdown(f"### đ **Confidence:** {confidence:.1%}")
st.markdown(f'
', unsafe_allow_html=True)
st.markdown(f"**Description:** {label_descriptions.get(label, '')}")
st.markdown('
', unsafe_allow_html=True)
except Exception as e:
st.error(f"Error during prediction: {e}")
else:
st.warning("Please enter some text to analyze!")
# Model info section
st.markdown("---")
st.markdown("## âšī¸ About This Model")
# Using simple text instead of triple-quoted string
st.info("**Model Details:**\n"
"- **Base Model**: DistilBERT-base-uncased\n"
"- **Training**: Fine-tuned on 50,000 tweets\n"
"- **Accuracy**: 96.4% on validation set\n"
"- **Labels**: Positive, Negative, Litigious, Uncertainty\n"
"- **Created By**: You! đ¯\n\n"
"**How to use programmatically:**\n"
"```python\n"
"from transformers import pipeline\n"
"classifier = pipeline('text-classification', \n"
" model='ChatBotsTA/distilbert-tweet-classifier')\n"
"result = classifier('Your text here')\n"
"```")
# Footer
st.markdown("---")
st.markdown('