Spaces:
Sleeping
Sleeping
Download app.py from Hiddenxhage/SafeNet-AI: direct link, hf CLI and curl.
- Browser
- Download file 950 Bytes
-
https://huggingface.co/spaces/Hiddenxhage/SafeNet-AI/resolve/main/app.py
- Command line
-
hf download hf://spaces/Hiddenxhage/SafeNet-AI/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Hiddenxhage/SafeNet-AI/resolve/main/app.py
950 Bytes
| import gradio as gr | |
| from transformers import pipeline | |
| # Load a sentiment model that can classify scam-like language | |
| classifier = pipeline("text-classification", model="bhadresh-savani/bert-base-uncased-emotion") | |
| def detect_scam(text): | |
| result = classifier(text)[0] | |
| label = result['label'] | |
| score = result['score'] | |
| if "fear" in label.lower() or "anger" in label.lower(): | |
| message = "⚠️ This message may be a scam or manipulative." | |
| else: | |
| message = "✅ This message seems okay." | |
| return f"Prediction: {label} ({score:.2f})\n{message}" | |
| interface = gr.Interface(fn=detect_scam, | |
| inputs=gr.Textbox(lines=4, placeholder="Paste a message here..."), | |
| outputs="text", | |
| title="SafeNet AI - Scam Message Detector", | |
| description="Paste a suspicious message to detect if it might be a scam using AI.") | |
| interface.launch() | |