KB-Infinity-Tech commited on
Commit
68249eb
·
verified ·
1 Parent(s): 927b695

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +43 -15
app.py CHANGED
@@ -1,15 +1,43 @@
1
- import streamlit as st
2
- from model import predict_text
3
-
4
- st.set_page_config(page_title="AI Cyber Guard")
5
-
6
- st.title("🛡️ AI Cyber Threat Detector")
7
-
8
- text = st.text_input("Enter URL or message")
9
-
10
- if st.button("Analyze"):
11
-
12
- result = predict_text(text)
13
-
14
- st.success(result["prediction"])
15
- st.write("Confidence:", result["confidence"], "%")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app.py
2
+
3
+ import streamlit as st
4
+ from model import predict_text
5
+
6
+ st.set_page_config(
7
+ page_title="AI Cyber Threat Detector",
8
+ page_icon="🛡️",
9
+ layout="centered"
10
+ )
11
+
12
+ st.title("🛡️ AI Cyber Threat Detector")
13
+ st.write("Detect phishing, spam, or suspicious messages using AI.")
14
+
15
+ # Input box
16
+ text = st.text_input(
17
+ "Enter URL or message",
18
+ placeholder="Example: http://secure-paypal-login.xyz"
19
+ )
20
+
21
+ # Button
22
+ if st.button("Analyze"):
23
+
24
+ if text.strip() == "":
25
+ st.warning("Please enter a message or URL.")
26
+ else:
27
+ with st.spinner("Analyzing..."):
28
+ result = predict_text(text)
29
+
30
+ label = result["prediction"]
31
+ confidence = result["confidence"]
32
+
33
+ # Display result
34
+ if label.lower() in ["spam", "phishing", "malicious"]:
35
+ st.error(f"⚠️ Threat Detected: {label}")
36
+ else:
37
+ st.success(f"✅ Safe: {label}")
38
+
39
+ st.write("Confidence:", confidence, "%")
40
+
41
+ # Footer
42
+ st.markdown("---")
43
+ st.caption("Built with Hugging Face Transformers")