Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Load a sentiment model that can classify scam-like language
|
| 5 |
+
classifier = pipeline("text-classification", model="bhadresh-savani/bert-base-uncased-emotion")
|
| 6 |
+
|
| 7 |
+
def detect_scam(text):
|
| 8 |
+
result = classifier(text)[0]
|
| 9 |
+
label = result['label']
|
| 10 |
+
score = result['score']
|
| 11 |
+
if "fear" in label.lower() or "anger" in label.lower():
|
| 12 |
+
message = "⚠️ This message may be a scam or manipulative."
|
| 13 |
+
else:
|
| 14 |
+
message = "✅ This message seems okay."
|
| 15 |
+
return f"Prediction: {label} ({score:.2f})\n{message}"
|
| 16 |
+
|
| 17 |
+
interface = gr.Interface(fn=detect_scam,
|
| 18 |
+
inputs=gr.Textbox(lines=4, placeholder="Paste a message here..."),
|
| 19 |
+
outputs="text",
|
| 20 |
+
title="SafeNet AI - Scam Message Detector",
|
| 21 |
+
description="Paste a suspicious message to detect if it might be a scam using AI.")
|
| 22 |
+
|
| 23 |
+
interface.launch()
|