Spaces:
Sleeping
Sleeping
File size: 7,568 Bytes
db16549 2ae1eba 957250d db16549 4e5407a db16549 957250d db16549 957250d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 |
---
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
1. **Clone the repository**
```bash
git clone <your-repo-url>
cd spamdex-web
```
2. **Install dependencies**
```bash
pip install -r requirements.txt
```
3. **Run the application**
```bash
uvicorn app:app --host 0.0.0.0 --port 7860 --reload
```
4. **Open in browser**
```
http://localhost:7860
```
---
## π Deploy to Hugging Face Spaces
### Step 1: Create a Space
1. Go to [Hugging Face](https://huggingface.co/)
2. Click on your profile β **New Space**
3. 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)
### 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**
1. Click "Files and versions" in your Space
2. Click "Add file" β "Upload files"
3. Upload all files listed above
**Option B: Via Git**
```bash
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
1. Go to **Settings** in your Space
2. Under **Space SDK**, select: **Docker**
3. 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:**
```json
{
"text": "Congratulations! You won $1000!"
}
```
**Response:**
```json
{
"prediction": "spam",
"label": 1,
"confidence": 95.67,
"cleaned_text": "congratulations you won"
}
```
**Status Codes:**
- `200` - Success
- `400` - Bad request (empty text)
- `500` - Server error
- `503` - Model not loaded
### Endpoint: `/api/info`
**Method:** GET
**Response:**
```json
{
"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)
```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)
```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](https://huggingface.co/DarkNeuron-AI/darkneuron-spamdex-v1)
### Prediction Labels
- **0**: Ham (Not Spam)
- **1**: Spam
---
## π οΈ Troubleshooting
### Issue: Model not loading
**Solution:**
```python
# 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:**
```bash
# 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:
1. Fork the repository
2. Create a feature branch (`git checkout -b feature/AmazingFeature`)
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request
---
## π License
This project is licensed under the MIT License - see the LICENSE file for details.
---
## π¨βπ» Developer
**DarkNeuronAI**
- GitHub: [@Madara369Uchiha](https://github.com/Madara369Uchiha)
- Hugging Face: [DarkNeuron-AI](https://huggingface.co/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: [your-email@example.com]
---
<div align="center">
**Crafted with β€οΈ and passion by [@Madara369Uchiha](https://github.com/Madara369Uchiha)**
β Star this project if you find it helpful!
</div> |