Perth0603/Random-Forest-Model-for-PhishingDetection
0
1---2title: PhishWatch Proxy3emoji: 🛡️4sdk: docker5---6 7# Hugging Face Space - Phishing Text Classifier (Docker + FastAPI)8 9This Space exposes two endpoints so the Flutter app can call them reliably:10 11- `/predict` for text/email/SMS classification via Transformers. Returns `{ label, score }` where `score` is the confidence for the predicted label.12- `/predict-url` for URL classification via your URL model. Returns `{ label, score, phishing_probability, backend, threshold }` where:13 - `phishing_probability` is always the raw probability of phishing (0..1)14 - `label` is `PHISH` when `phishing_probability >= threshold`, else `LEGIT`15 - `score` is the confidence for the predicted label (for `LEGIT`, `score = 1 - phishing_probability`), which lets the app show "Safe Confidence" for legitimate URLs16 17## Files18- Dockerfile - builds a small FastAPI server image19 - app.py - FastAPI app that loads the model and returns normalized responses as above.20- requirements.txt - Python dependencies.21 22## How to deploy231. Create a new Space on Hugging Face (type: Docker).242. Upload the contents of this `hf_space/` folder to the Space root (including Dockerfile).253. In Space Settings → Variables, add:26 - MODEL_ID = Perth0603/phishing-email-mobilebert27 - URL_REPO = Perth0603/Random-Forest-Model-for-PhishingDetection28 - URL_FILENAME = url_rf_model.joblib (set to your artifact filename)294. Wait for the Space to build and become green. Test:30 - GET `/` should return `{ status: ok, model: ... }`31 - POST `/predict` with `{ "inputs": "Win an iPhone! Click here" }`32 - POST `/predict-url` with `{ "url": "https://example.com/login" }`33 34## Flutter app config35Set the Space URL in your env file so the app targets the Space instead of the Hosted Inference API:36 37```38{"HF_SPACE_URL":"https://<your-space>.hf.space"}39```40 41Run the app:42```43flutter run --dart-define-from-file=hf.env.json44```45 