Alina Arslanova commited on
Commit
9a49d8c
Β·
1 Parent(s): 775afeb

homework is done

Browse files
Files changed (2) hide show
  1. app.py +32 -1
  2. requirements.txt +2 -1
app.py CHANGED
@@ -1,3 +1,34 @@
1
  import streamlit as st
 
2
 
3
- st.write("Hello, World!")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
+ from transformers import BertForSequenceClassification, BertTokenizer, TextClassificationPipeline
3
 
4
+ model_path = "JungleLee/bert-toxic-comment-classification"
5
+ tokenizer = BertTokenizer.from_pretrained(model_path)
6
+ model = BertForSequenceClassification.from_pretrained(model_path, num_labels=2)
7
+
8
+ pipeline = TextClassificationPipeline(model=model, tokenizer=tokenizer, return_all_scores=False)
9
+
10
+ st.set_page_config(page_title="Message Vibe Checker", page_icon="😬")
11
+ st.title("πŸ•΅οΈβ€β™‚οΈ Check Your Message Before Sending!")
12
+ st.subheader("Don't let your message get you canceled πŸ˜…")
13
+
14
+ user_message = st.text_area("Paste your message here:", placeholder="e.g., You're a freaking genius!")
15
+
16
+ if st.button("Analyze Message"):
17
+ if not user_message.strip():
18
+ st.warning("You forgot to type something, buddy!")
19
+ else:
20
+ with st.spinner("Scanning your message for rage and sass..."):
21
+ result = pipeline(user_message)[0]
22
+ label = result['label']
23
+ score = result['score']
24
+
25
+ if label == "TOXIC":
26
+ st.error(f"☒️ Whoa there! That message might be **toxic** (confidence: {score:.2f})")
27
+ st.caption("Try sending good vibes instead πŸ§˜β€β™‚οΈπŸŒˆ")
28
+ else:
29
+ st.success(f"βœ… Looks good! This message seems **clean** (confidence: {score:.2f})")
30
+ st.balloons()
31
+ st.caption("Spread kindness like confetti πŸŽ‰")
32
+
33
+ st.markdown("---")
34
+ st.caption("Made with love.")
requirements.txt CHANGED
@@ -1 +1,2 @@
1
- transformers[torch] (>=4.51.3,<5.0.0)
 
 
1
+ transformers[torch] (>=4.51.3,<5.0.0)
2
+ streamlit==1.33.0