Spaces:
Sleeping
Sleeping
File size: 5,050 Bytes
6789936 459cb9f 6789936 7058515 459cb9f 7058515 459cb9f 6789936 | 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 | ---
title: AnomalDrive
emoji: ๐
colorFrom: green
colorTo: red
sdk: gradio
sdk_version: 5.45.0
app_file: app.py
pinned: false
short_description: Advanced ML-powered anomaly detection for GPS tracking data
---
# ๐ฃ๏ธ Vehicle Anomaly Detection System
An advanced machine learning-powered anomaly detection system for GPS tracking data with a beautiful Gradio interface.
## ๐ Features
- **Multiple ML Models**: Ensemble of Isolation Forest, One-Class SVM, and LSTM Autoencoder
- **Beautiful UI**: Modern Gradio interface with interactive visualizations
- **Real-time Processing**: Handles up to 2000 GPS points with detailed analysis
- **Comprehensive Output**: Point-by-point analysis, risk factors, and JSON export
- **Interactive Maps**: GPS route visualization with anomaly highlighting
- **Performance Analytics**: Speed, altitude, and confidence distribution charts
## ๐ Processing Performance
- **CPU-only processing**: 45-90 seconds for 2000 samples
- **HuggingFace Spaces ready**: Optimized for cloud deployment
- **Memory efficient**: Handles large datasets with rolling window processing
## ๐ง Installation
### Local Installation
```bash
# Clone or download the project
cd anomaly
# Install dependencies
pip install -r requirements.txt
# Run the Gradio app
python gradio_app.py
```
### HuggingFace Spaces Deployment
1. Create a new Space on HuggingFace
2. Upload all files including the `models/` directory
3. Set `app_file` to `app.py`
4. The app will automatically launch
## ๐ Input Format
Your CSV file must contain these columns:
| Column | Description | Range |
|--------|-------------|-------|
| `randomized_id` | Vehicle identifier | Any string |
| `lat` | Latitude | -90 to 90 |
| `lng` | Longitude | -180 to 180 |
| `spd` | Speed (km/h) | 0 to 300 |
| `azm` | Azimuth/heading (degrees) | 0 to 360 |
| `alt` | Altitude (meters) | Any number |
### Sample Data
```csv
randomized_id,lat,lng,spd,azm,alt
VEHICLE001,40.7128,-74.0060,45.5,90.0,100.0
VEHICLE001,40.7138,-74.0070,48.2,92.0,102.0
VEHICLE002,40.7500,-73.9800,35.2,180.0,90.0
```
**Maximum**: 2000 samples per upload
**Minimum**: 5 samples required
## ๐ฏ Anomaly Detection
The system detects various types of anomalies:
### Speed Anomalies
- Excessive speeding (>120 km/h)
- Sudden acceleration/deceleration
- Speed inconsistencies
### Movement Anomalies
- Erratic GPS patterns
- Sharp turns at high speed
- Altitude inconsistencies
### Behavioral Patterns
- Route deviations
- Stop-and-go patterns
- Unusual driving sequences
## ๐ Output Features
### 1. Detailed Results
- Point-by-point analysis
- Normal vs. anomaly classification
- Confidence scores and alert levels
- Risk factor identification
### 2. Interactive Visualizations
- GPS route mapping with anomaly markers
- Speed and altitude profiles
- Confidence score distributions
- Multi-panel analysis dashboard
### 3. Summary Statistics
- Processing performance metrics
- Overall anomaly rates
- Alert level distributions
- Risk factor rankings
### 4. JSON Export
Complete machine-readable results including:
- All detection scores
- Driving metrics
- Risk assessments
- Timestamps and metadata
## ๐ฌ Technical Details
### ML Models Used
1. **Isolation Forest**: Tree-based anomaly detection
2. **One-Class SVM**: Support vector-based outlier detection
3. **LSTM Autoencoder**: Deep learning sequence anomaly detection
### Feature Engineering
- 18 engineered features including:
- Speed patterns and statistics
- Acceleration and jerk calculations
- Angular velocity and curvature
- Rolling window aggregations
- Risk scoring algorithms
### Performance Optimization
- Efficient batch processing
- Memory-optimized feature calculation
- CPU-friendly model inference
- Progressive result streaming
## ๐ก๏ธ Privacy & Security
- **Local Processing**: All analysis happens in your environment
- **No Data Upload**: Your GPS data never leaves the system
- **Real-time Analysis**: No data storage or logging
- **Secure Processing**: Industry-standard ML pipeline
## ๐ Deployment Options
### Local Development
```bash
python gradio_app.py
# Access at http://localhost:7860
```
### HuggingFace Spaces
- Perfect for sharing and collaboration
- No setup required
- Automatic scaling
- Public or private deployment
### Docker (Optional)
```dockerfile
FROM python:3.9-slim
COPY . /app
WORKDIR /app
RUN pip install -r requirements.txt
CMD ["python", "gradio_app.py"]
```
## ๐ Support
For issues or questions:
1. Check the sample data format
2. Ensure your CSV has all required columns
3. Verify data is within expected ranges
4. Check for missing values or invalid entries
## ๐ฎ Future Enhancements
- Real-time streaming support
- Custom alert thresholds
- Historical trend analysis
- Fleet management dashboard
- Advanced route optimization
- Multi-vehicle correlation analysis
---
**Made with โค๏ธ using Gradio, PyTorch, and Advanced ML**
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|