File size: 1,035 Bytes
68249eb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
36
37
38
39
40
41
42
43
# app.py

import streamlit as st
from model import predict_text

st.set_page_config(
    page_title="AI Cyber Threat Detector",
    page_icon="🛡️",
    layout="centered"
)

st.title("🛡️ AI Cyber Threat Detector")
st.write("Detect phishing, spam, or suspicious messages using AI.")

# Input box
text = st.text_input(
    "Enter URL or message",
    placeholder="Example: http://secure-paypal-login.xyz"
)

# Button
if st.button("Analyze"):

    if text.strip() == "":
        st.warning("Please enter a message or URL.")
    else:
        with st.spinner("Analyzing..."):
            result = predict_text(text)

        label = result["prediction"]
        confidence = result["confidence"]

        # Display result
        if label.lower() in ["spam", "phishing", "malicious"]:
            st.error(f"⚠️ Threat Detected: {label}")
        else:
            st.success(f"✅ Safe: {label}")

        st.write("Confidence:", confidence, "%")

# Footer
st.markdown("---")
st.caption("Built with Hugging Face Transformers")