CyberAIfirstApp / app.py
KB-Infinity-Tech's picture
Create app.py
55bcdff verified
raw
history blame contribute delete
892 Bytes
import streamlit as st
from transformers import pipeline
# Load AI model
classifier = pipeline(
"text-classification",
model="mrm8488/bert-tiny-finetuned-sms-spam-detection"
)
# Page config
st.set_page_config(
page_title="AI Cyber Threat Detector",
page_icon="🛡️"
)
st.title("🛡️ AI Cyber Threat Detector")
text = st.text_input(
"Enter URL or message"
)
if st.button("Analyze"):
if text.strip() == "":
st.warning("Please enter text")
else:
with st.spinner("Analyzing..."):
result = classifier(text)[0]
label = result["label"]
confidence = round(result["score"] * 100, 2)
if label.lower() == "spam":
st.error(f"⚠️ Threat Detected: {label}")
else:
st.success(f"✅ Safe: {label}")
st.write("Confidence:", confidence, "%")