File size: 1,496 Bytes
981724f
9a49d8c
981724f
9a49d8c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
058238c
9a49d8c
 
 
 
 
 
 
 
058238c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import streamlit as st
from transformers import BertForSequenceClassification, BertTokenizer, TextClassificationPipeline

model_path = "JungleLee/bert-toxic-comment-classification"
tokenizer = BertTokenizer.from_pretrained(model_path)
model = BertForSequenceClassification.from_pretrained(model_path, num_labels=2)

pipeline = TextClassificationPipeline(model=model, tokenizer=tokenizer, return_all_scores=False)

st.set_page_config(page_title="Message Vibe Checker", page_icon="😬")
st.title("πŸ•΅οΈβ€β™‚οΈ Check Your Message Before Sending!")
st.subheader("Don't let your message get you canceled πŸ˜…")

user_message = st.text_area("Paste your message here:", placeholder="e.g., You're a freaking genius!")

if st.button("Analyze Message"):
    if not user_message.strip():
        st.warning("You forgot to type something, buddy!")
    else:
        with st.spinner("Scanning your message for rage and sass..."):
            result = pipeline(user_message)[0]
            label = result['label']
            score = result['score']

        if label == "toxic":
            st.error(f"☒️ Whoa there! That message might be **toxic** (confidence: {score:.2f})")
            st.caption("Try sending good vibes instead πŸ§˜β€β™‚οΈπŸŒˆ")
        else:
            st.success(f"βœ… Looks good! This message seems **clean** (confidence: {score:.2f})")
            st.balloons()
            st.caption("Spread kindness like confetti πŸŽ‰")

st.markdown("---")
st.caption("Made with love")