Unified AI-Powered Crowd & Disaster Management for Nashik Kumbh Mela 2027
CrowdShield is a comprehensive AI-driven crowd management system designed specifically for mega gatherings like the Nashik Kumbh Mela 2027. The system combines the power of Flask backend with FastAPI features and Satellite Analysis to provide real-time crowd monitoring, intelligent alerts, and emergency response coordination.
The satellite_analysis/ module provides advanced AI-powered analysis of satellite imagery for crowd density estimation and prediction. This module is specifically designed for large-scale events like Kumbh Mela and can be used independently or integrated with the main CrowdShield system.
- 🛰️ Multi-Method Analysis: Edge density, texture analysis, blob detection, and hybrid approaches
- 🤖 Machine Learning: Random Forest-based crowd count prediction
- 📊 Data Management: JSON-based structured data storage
- 🎯 Event Prediction: Predict crowd counts for recurring events
- 📈 Visualization: Comprehensive analysis and prediction visualizations
- Python 3.8+
- Git
- Modern web browser
-
Clone the repository
git clone https://github.com/NMOLE08/CrowdShield.git cd CrowdShield -
Install dependencies
pip3 install -r requirements.txt pip3 install -r satellite_analysis/requirements.txt
-
Start the unified backend
python3 main.py
-
Access the system
- 🌐 Frontend Dashboard: http://localhost:5002/frontend
- 📋 API Documentation: http://localhost:5002/api/docs
- 🏥 Health Check: http://localhost:5002/health
python3 scripts/run_demo.py- YOLOv8 (Ultralytics): Real-time person detection and crowd counting
- OpenCV: Video processing and frame analysis
- PyTorch: Deep learning framework for model inference
- NumPy: Numerical computing for data processing
- Pillow: Image processing and manipulation
- Scikit-learn: Machine learning algorithms for predictive analytics
- Pandas: Data manipulation and analysis
- SciPy: Scientific computing and statistical analysis
- Flask-SocketIO: WebSocket communication for real-time updates
- Python-SocketIO: Real-time bidirectional communication
- Paho MQTT: IoT device communication protocol
- OpenStreetMap (OSM) API: Free location services, geocoding, route optimization
- OSRM: Open Source Routing Machine for directions
- Nominatim: Free geocoding service
- Mapbox: Interactive maps and heatmap visualization
- Folium: Python mapping library for data visualization
- Geopy: Geocoding and distance calculations
- Twilio: SMS and WhatsApp alert delivery
- WebSocket: Real-time data streaming to frontend
- SQLite: Lightweight database for data persistence
- SQLAlchemy: Database ORM and management
- Flask-SQLAlchemy: Flask database integration
┌─────────────────────────────────────────────────────────────┐
│ CrowdShield Unified Backend │
├─────────────────────────────────────────────────────────────┤
│ Flask Core (AI & Detection) │ FastAPI Features │
│ ├── YOLOv8 Detection │ ├── WebSocket Server │
│ ├── CCTV Management │ ├── Twilio Integration │
│ ├── Nashik Simulation │ ├── Real-time Updates │
│ ├── Route Optimization │ └── Push Notifications │
│ ├── Satellite Analysis │ │
│ └── Database Management │ │
└─────────────────────────────────────────────────────────────┘
crowd_detection.py: YOLOv8-based people detectioncctv_manager.py: Multi-stream video processingenhanced_alert_system.py: Master branch's threshold enginemapbox_heatmap_generator.py: Interactive map visualizationnashik_kumbh_simulator.py: Venue-specific simulationroute_optimizer.py: Crowd-aware navigationdatabase.py: Data persistence and managementsatellite_crowd_analyzer.py: Satellite image analysisenhanced_crowd_predictor.py: ML-based crowd prediction
POST /api/detect- Real-time crowd detectionGET /api/heatmap- Generate crowd density heatmapGET /api/alerts- Get active alertsPOST /api/routes/optimize- Optimize routes based on crowd
POST /api/nashik/simulate- Generate simulation scenariosGET /api/nashik/status- Get venue statusGET /api/nashik/map-data- Get interactive map dataGET /api/nashik/realtime-map- Real-time map updates
POST /api/satellite/analyze- Analyze satellite imageryGET /api/satellite/predict- Get crowd predictionsGET /api/satellite/status- Satellite analysis statusGET /api/satellite/data- Historical analysis data
GET /api/alerts- Get current active alertsGET /api/alerts/status- Get alert system statusGET /api/alerts/history- Get alert historyPOST /api/alerts/test- Test alert system with Twilio
- 5 Strategic Gates: Ramkund, Godavari Ghat, Main Bridge, Temporary Bridge, Parking Area
- Real Coordinates: Accurate Nashik location mapping
- Capacity Management: Per-gate crowd limits and monitoring
- Emergency Routes: Optimized evacuation paths
- Normal Crowd Flow: Regular festival attendance
- Peak Hour Rush: High-density periods
- Emergency Situations: Stampede, fire, medical emergencies
- Weather Conditions: Rain, heat impact on crowd behavior
- Density-Based Alerts: GREEN, YELLOW, RED, CRITICAL levels
- Smart Cooldown: 5-minute cooldown between repeated alerts
- Hourly Limits: Maximum 10 alerts per hour per location
- Real-time Processing: Automatic alert generation from CCTV data
- Multi-level Alerts: Based on crowd density and capacity
- Location-Specific: Gate-specific alerting for Nashik Kumbh Mela
- WebSocket Notifications: Real-time alert delivery
- Twilio Integration: SMS/WhatsApp alert delivery
- Alert History: Complete tracking with timestamps
- Interactive Heatmaps: Color-coded crowd density visualization
- Real-time Updates: Live crowd data overlay
- Gate Markers: All 5 Nashik Kumbh Mela gates with popups
- Landmark Integration: Godavari River, Ramkund, Main Ghat
- Alert Visualization: Real-time alert markers on map
- Route Optimization: Crowd-aware navigation using OSRM
- Geocoding: Free location services using Nominatim
- Distance Matrix: Real-time distance calculations
- Place Details: Venue information and details
- 5 CCTV Feeds: Real-time video streams from all gates
- YOLOv8 Detection: Person detection with bounding boxes
- Frame Generation: Simulated video frames with overlays
- Performance Metrics: Real-time processing statistics
- Detection Overlays: Bounding boxes, labels, timestamps
- Crowd Counting: Real-time person count per feed
- Status Indicators: Visual status for each camera
- Frame Caching: Optimized frame delivery
- Glass-morphism Design: Modern glass-like interface
- Responsive Layout: Works on all devices
- Real-time Updates: Live data without page refresh
- Interactive Maps: Mapbox integration with heatmaps
- CCTV Thumbnails: Live camera feed previews
- Live Statistics: Real-time crowd count and alerts
- Interactive Map: Nashik Kumbh Mela venue visualization
- Alert Panel: Active alerts with priority levels
- CCTV Feeds: Clickable camera thumbnails
- System Status: Health monitoring and status indicators
# Application
SECRET_KEY=your_secret_key
FLASK_DEBUG=True
PORT=5002
# OSM API (OpenStreetMap - Free, no API key required)
OSM_ENABLED=True
# Mapbox
MAPBOX_ACCESS_TOKEN=your_mapbox_access_token
# Twilio (Push Notifications)
TWILIO_ACCOUNT_SID=your_twilio_account_sid
TWILIO_AUTH_TOKEN=your_twilio_auth_token
TWILIO_PHONE_NUMBER=your_twilio_phone_number
# MQTT (optional)
MQTT_ENABLED=False
MQTT_BROKER=localhost
MQTT_PORT=1883test_enhanced_alerts.py: Enhanced alert system validationtest_cctv.py: CCTV functionality testingtest_api_endpoints.py: API endpoint verificationrun_demo.py: Comprehensive system demotest_setup.py: Satellite analysis environment testing
- Alert System: Threshold engine and cooldown logic
- CCTV Integration: Multi-stream processing
- Map Integration: Mapbox and Google Maps APIs
- API Endpoints: All REST endpoints and WebSocket
- Real-time Updates: Live data streaming
- Satellite Analysis: ML model validation and testing
CrowdShield/
├── src/
│ ├── api/ # Flask API layer
│ ├── core/ # Core AI & detection modules
│ └── config/ # Configuration management
├── frontend/ # Modern dashboard UI
├── backend/ # FastAPI features (integrated)
├── satellite_analysis/ # Satellite image analysis module
├── data/ # Generated data & models
├── scripts/ # Demo & utility scripts
├── tests/ # Test suites
└── docs/ # Documentation
- Real-time Monitoring: Live crowd density tracking
- Emergency Response: Instant alert system
- Route Management: Optimized traffic flow
- Resource Allocation: Data-driven decision making
- Satellite Analysis: Large-scale crowd monitoring
- Capacity Planning: Predictive crowd modeling
- Safety Management: Proactive risk mitigation
- Communication: Automated alert distribution
- Analytics: Historical data analysis
- Predictive Insights: ML-based crowd forecasting
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Ultralytics: YOLOv8 implementation
- Mapbox: Interactive mapping
- Twilio: Communication services
- OpenCV: Computer vision library
- Scikit-learn: Machine learning framework
- Nashik Kumbh Mela Authorities: Venue information and requirements
For support and questions:
- 📧 Email: support@crowdshield.ai
- 🐛 Issues: GitHub Issues
- 📖 Documentation: Wiki
Built with ❤️ for Nashik Kumbh Mela 2027