A full-stack web application built with Flask and YOLOv8 to analyze crowd behavior in real-time. This system detects, tracks, and analyzes crowd density, speed, and directional chaos to provide early warnings for potential stampedes.
| Feature | Description |
|---|---|
| 🔒 Secure Web Dashboard | A Flask-based web app with a passkey-protected login |
| 🎯 Dynamic "Hotspot" Zones | Upload any video and define custom regions of interest |
| 📊 Advanced Behavioral Analysis | Tracks crowd density, average speed, and directional chaos |
| 🧠 Self-Calibrating Model | Automatically learns a "normal" baseline for any video and flags anomalies |
| 🚨 Real-time Alerts | Classifies the crowd state as NORMAL, WARNING, or CRITICAL |
| 🚀 GPU Accelerated | Uses PyTorch with CUDA to perform all AI inference on an NVIDIA GPU |
| Layer | Technology |
|---|---|
| Backend | Python 3.9+, Flask |
| Computer Vision | OpenCV, YOLOv8 (yolov8m), supervision |
| AI / Deep Learning | PyTorch (CUDA 12.1) |
| Frontend | HTML5, CSS3, Jinja2 |
| Deployment | Docker (Hugging Face Spaces) |
- Python 3.9+
- NVIDIA GPU (Recommended for real-time inference)
- CUDA 12.1 toolkit
git clone https://github.com/KrishMistry18/CrowdPulse.git
cd CrowdPulse# Create virtual environment
python -m venv venv
# Windows
venv\Scripts\activate
# macOS/Linux
source venv/bin/activate
# Install dependencies
pip install -r requirements.txtpip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121- Download the
yolov8m.ptmodel from the YOLOv8 releases. - Place the
.ptfile in the mainCrowdPulsefolder.
python app.pyOpen http://127.0.0.1:5000 🎉
CrowdPulse/
├── app.py # Core Flask server and routes
├── main_web.py # Main inference & video processing logic
├── requirements.txt # Dependencies
├── Dockerfile # Hugging Face deployment config
├── yolov8m.pt # YOLOv8 weights (downloaded)
├── static/ # CSS, JS, and images
├── templates/ # Jinja2 HTML templates
└── uploads/ # Directory for uploaded videos
CrowdPulse combines several cutting-edge computer vision techniques:
| Component | Function |
|---|---|
| YOLOv8 Medium | Real-time object detection (optimized for 'person' class) |
| Supervision | Multi-object tracking, zone detection, and annotation rendering |
| Motion Tracking | Used to calculate movement vectors and directional chaos |
| Anomaly Detection | Self-calibrating statistical analysis to detect panic states |
- Passkey Protection — Limits access to the analytics dashboard.
- Async Processing — Video processing runs in background threads to keep the UI responsive.
- Auto-Cleanup — Temporary video files are automatically managed.
- GPU Optimization — Operations are tensorized and offloaded to CUDA where possible.
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature - Commit:
git commit -m "feat: add your feature" - Push and open a Pull Request
MIT — see LICENSE for details.
Made for safety · CrowdPulse v1.0.0 · Built by Krish Mistry