Spaces:
Sleeping
Sleeping
metadata
title: ππ©ππ¦πππ± ππ - ππ¬ππ« ππ§πππ«ππππ
emoji: π¨
colorFrom: green
colorTo: blue
sdk: docker
pinned: false
license: mit
π§ SpamDex Web - AI-Powered Spam Detection
A beautiful, fully-functional web application for spam detection powered by Naive Bayes + TF-IDF machine learning model from Hugging Face.
π Features
- β¨ Beautiful UI - Glassmorphism design with dark/light mode
- π Real-time Analysis - Instant spam detection
- π¨ Responsive Design - Works on all devices (mobile, tablet, desktop)
- π₯ Smooth Animations - Enhanced user experience
- π€ AI-Powered - Using state-of-the-art ML model
- π REST API - Easy integration with other apps
- β‘ Fast & Lightweight - Optimized performance
π Quick Start (Local Development)
Prerequisites
- Python 3.8+
- pip
Installation
- Clone the repository
git clone <your-repo-url>
cd spamdex-web
- Install dependencies
pip install -r requirements.txt
- Run the application
uvicorn app:app --host 0.0.0.0 --port 7860 --reload
- Open in browser
http://localhost:7860
π Deploy to Hugging Face Spaces
Step 1: Create a Space
- Go to Hugging Face
- Click on your profile β New Space
- Fill in the details:
- Name:
spamdex-web(or your choice) - License: MIT
- SDK: Gradio (will change to custom)
- Hardware: Free CPU (sufficient for this model)
- Name:
Step 2: Prepare Files
Create these files in your Space:
your-space/
βββ app.py # Backend server
βββ requirements.txt # Python dependencies
βββ index.html # Frontend UI
βββ README.md # Documentation
βββ .gitignore # Git ignore file
Step 3: Upload Files
Option A: Via Web Interface
- Click "Files and versions" in your Space
- Click "Add file" β "Upload files"
- Upload all files listed above
Option B: Via Git
git clone https://huggingface.co/spaces/YOUR-USERNAME/spamdex-web
cd spamdex-web
# Add all files
git add .
git commit -m "Initial commit"
git push
Step 4: Configure Space Settings
- Go to Settings in your Space
- Under Space SDK, select: Docker
- Create a
Dockerfile(optional, or use default)
Step 5: Wait for Build
- Hugging Face will automatically build and deploy your Space
- Check the logs for any errors
- Once built, your Space will be live!
π File Structure
spamdex-web/
β
βββ app.py # FastAPI backend with ML model
β βββ /api/predict # POST endpoint for predictions
β βββ /api/info # GET endpoint for model info
β βββ /health # Health check endpoint
β
βββ index.html # Complete React frontend
β βββ React components
β βββ Tailwind CSS
β βββ API integration
β
βββ requirements.txt # Python dependencies
β βββ fastapi
β βββ uvicorn
β βββ huggingface-hub
β βββ scikit-learn
β βββ joblib
β
βββ README.md # This file
π API Documentation
Endpoint: /api/predict
Method: POST
Request Body:
{
"text": "Congratulations! You won $1000!"
}
Response:
{
"prediction": "spam",
"label": 1,
"confidence": 95.67,
"cleaned_text": "congratulations you won"
}
Status Codes:
200- Success400- Bad request (empty text)500- Server error503- Model not loaded
Endpoint: /api/info
Method: GET
Response:
{
"model_name": "SpamDex v1.0",
"algorithm": "Naive Bayes (MultinomialNB)",
"vectorization": "TF-IDF",
"developer": "DarkNeuronAI",
"huggingface_repo": "DarkNeuron-AI/darkneuron-spamdex-v1",
"labels": {
"0": "Ham (Not Spam)",
"1": "Spam"
}
}
Example Usage (Python)
import requests
# API endpoint
url = "http://localhost:7860/api/predict"
# Text to analyze
data = {
"text": "FREE iPhone! Click here to claim your prize!!!"
}
# Make request
response = requests.post(url, json=data)
result = response.json()
print(f"Prediction: {result['prediction']}")
print(f"Confidence: {result['confidence']}%")
Example Usage (JavaScript)
const analyzeText = async (text) => {
const response = await fetch('/api/predict', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ text })
});
const result = await response.json();
console.log('Prediction:', result.prediction);
console.log('Confidence:', result.confidence);
};
analyzeText("Win $1000 now!");
π¨ UI Features
Dark/Light Mode Toggle
- Smooth transition animations
- Persistent across sessions
- Automatic theme detection
Responsive Design
- Mobile-first approach
- Breakpoints:
sm,md,lg,xl - Flexible grid layouts
Interactive Elements
- Hover effects on all cards
- Smooth scaling animations
- Glassmorphism design
- Floating background particles
π§ͺ Model Information
- Model: Naive Bayes (MultinomialNB)
- Vectorization: TF-IDF
- Training Data: Real-world email dataset
- Accuracy: ~95%+
- Repository: DarkNeuron-AI/darkneuron-spamdex-v1
Prediction Labels
- 0: Ham (Not Spam)
- 1: Spam
π οΈ Troubleshooting
Issue: Model not loading
Solution:
# Check if files are downloaded
from huggingface_hub import hf_hub_download
vectorizer_path = hf_hub_download(
"DarkNeuron-AI/darkneuron-spamdex-v1",
"spam_detection_vectorizer.pkl"
)
print(f"Vectorizer loaded from: {vectorizer_path}")
Issue: CORS errors
Solution:
- Check if CORS middleware is enabled in
app.py - Ensure
allow_origins=["*"]is set
Issue: Port already in use
Solution:
# Use a different port
uvicorn app:app --host 0.0.0.0 --port 8000
π Performance
- Average Response Time: < 200ms
- Model Size: ~2MB
- Memory Usage: ~50MB
- Concurrent Requests: 100+
π€ Contributing
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
π License
This project is licensed under the MIT License - see the LICENSE file for details.
π¨βπ» Developer
DarkNeuronAI
- GitHub: @Madara369Uchiha
- Hugging Face: DarkNeuron-AI
π Acknowledgments
- Model trained using scikit-learn
- UI built with React and Tailwind CSS
- Backend powered by FastAPI
- Hosted on Hugging Face Spaces
π Support
For issues, questions, or suggestions:
- Open an issue on GitHub
- Contact via Hugging Face
- Email: [[email protected]]
Crafted with β€οΈ and passion by @Madara369Uchiha
β Star this project if you find it helpful!