This repository contains a multi-camera violence detection and suspect tracking system. It leverages YOLO for object detection, OSNet for Person Re-Identification (ReID), and a CNN-GRU model for violence detection. The system is designed to simulate a control room environment where events are detected, and suspects are tracked across multiple camera feeds.
- Multi-Camera Simulation: Simulates a network of cameras with overlapping fields of view.
- Real-time Violence Detection: Uses a CNN-GRU model to detect violence in video streams.
- Suspect Tracking (ReID): Tracks suspects across different cameras using OSNet-based feature extraction.
- Event Orchestration: Manages active events, camera handoffs, and suspect locking logic.
- Visual Control Room: A GUI to visualize camera feeds, alerts, and tracking status.
.
├── visual_simulation.py # Main entry point for the visual simulation
├── train_hockey_gru.py # Script to train the violence detection model (Hockey Dataset)
├── evaluate_ucf_crime.py # Script to evaluate the model on the UCF-Crime dataset
├── test_yolo_pipeline.py # Test script for the YOLO pipeline
├── requirements.txt # Python dependencies
├── orchestration/ # Core logic for orchestration and dispatching
│ ├── engine.py # Orchestration Engine (Event & Camera Management)
│ ├── reid/ # ReID module
│ │ ├── feature_extractor.py # Feature extraction using OSNet
│ │ └── osnet.py # OSNet model definition
│ └── ...
├── violence_detection_model.pth # Pre-trained Violence Detection Model
├── yolo26n.pt # YOLO model weights (Custom or v8)
└── ...
-
Clone the repository:
git clone <repository_url> cd <repository_name>
-
Create a virtual environment (optional but recommended):
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Verify Model Weights: Ensure the following model weights are present in the root directory:
yolo26n.pt(oryolov8n.ptdepending on configuration)violence_detection_model.pth
This is the main demo of the system. It launches a window showing multiple camera feeds and simulates violence detection and suspect tracking.
python visual_simulation.py- Controls:
- Press
qto exit the simulation. - Click on a bounding box to provide feedback (mark as false positive).
- Press
To train the CNN-GRU model on the Hockey Fight Dataset:
python train_hockey_gru.py --dataset hockey --data_root /path/to/HockeyDataset --epochs 20To evaluate the trained model on the UCF-Crime dataset:
python evaluate_ucf_crime.pyNote: You will need the UCF-Crime dataset structure setup locally.
To test the object detection pipeline on a single video:
python test_yolo_pipeline.py path/to/video.mp4- Orchestration Engine: Manages the state of the entire camera network, handling event triggers and spatial handoffs.
- Dispatcher: Processes frames using a combination of YOLO (detection), OSNet (ReID features), and GRU (activity recognition).
- Feature Extractor: Extracts L2-normalized feature vectors for person re-identification.
- Camera Network: defined in
orchestration/cameras_network.json. - Model Parameters: logic for thresholds and model paths can be found in
orchestration/engine.pyand respective training scripts.