A privacy-focused spam detection system built using TensorFlow Lite, FastAPI, Android, and a real-time monitoring dashboard.
The project demonstrates how mobile devices can participate in a collaborative spam detection workflow while minimizing the transfer of sensitive SMS data. Android clients perform local inference using a TensorFlow Lite model and communicate with a centralized FastAPI server that manages model updates, evaluation, and deployment.
- Android SMS Spam Detection Client
- TensorFlow Lite On-Device Inference
- FastAPI Backend Server
- Real-Time Monitoring Dashboard
- Model Versioning and Round Tracking
- Accuracy Monitoring
- Azure VM Deployment
- Privacy-Oriented Architecture
Android Client
│
│ Prediction / Training Data
▼
FastAPI Server
│
├── Model Management
├── Accuracy Evaluation
├── Round Tracking
└── Model Export
│
▼
TensorFlow Lite Model
│
▼
Redistributed To Clients
▲
│
Streamlit Dashboard
(Real-Time Monitoring)
Spam-Detection/
│
├── android/
│ └── SpamDetector/
│
├── dashboard/
│ └── dashboard.py
│
├── server/
│ └── main.py
│
├── data/
│ └── SMSSpamCollection
│
├── models/
│ ├── round_0.tflite
│ ├── round_0.weights.h5
│ ├── accuracy.json
│ ├── current_round.json
│ └── vocab.json
│
├── build_trainable_model.py
├── train.py
├── requirements.txt
└── README.md
Dataset Used:
- SMS Spam Collection Dataset
Classes:
- Ham (0)
- Spam (1)
Embedding
↓
GlobalAveragePooling1D
↓
Dense (ReLU)
↓
Dropout
↓
Dense (Sigmoid)
| Parameter | Value |
|---|---|
| Vocabulary Size | 8000 |
| Sequence Length | 100 |
| Embedding Dimension | 32 |
| Batch Size | 32 |
| Epochs | 10 |
The Android application performs on-device spam detection using TensorFlow Lite.
round_0.tflite
vocab.json
- Kotlin
- TensorFlow Lite
- Android SDK
- Material Components
The backend is implemented using FastAPI.
- Serve latest TensorFlow Lite model
- Accept client uploads
- Track training rounds
- Evaluate model accuracy
- Export updated models
- Provide dashboard metrics
GET /get_model
POST /upload_weights
GET /metrics
WS /ws/dashboardThe Streamlit dashboard provides:
- Current training round
- Accuracy tracking
- Upload statistics
- Client activity monitoring
- Real-time server events
streamlit run dashboard/dashboard.py --server.port 8501git clone https://github.com/Codeblitz-Ankit/Spam-Detection.git
cd Spam-Detectionpip install -r requirements.txtpython train.pycd server
uvicorn main:app --host 0.0.0.0 --port 8000Lightning AI
Used for:
- Model training
- Experimentation
- Development
Azure Virtual Machine
Used for:
- FastAPI hosting
- Dashboard hosting
- Model distribution
- Monitoring
Current Round:
cat models/current_round.jsonAccuracy:
cat models/accuracy.jsonGenerated Models:
ls models/- Differential Privacy
- Secure Aggregation
- Federated Averaging with True Weight Aggregation
- Multi-Client Simulation
- Transformer-Based Models
- Docker Deployment
- Kubernetes Deployment
Ankit Koli
Federated Learning • Android Development • FastAPI • TensorFlow Lite • Machine Learning