This project includes Python scripts for detecting traffic jams using anomaly detection on live camera feed images from the Singapore Government's Traffic API. The YOLOv11 model is employed to count the number of vehicles in each image. Anomaly detection is then performed using the z-score method on features such as the occupation ratio and the vehicle count to identify traffic surges.
-
Clone the repository:
git clone https://github.com/BlazeStorm001/singvms-anomaly.git cd singvms-anomaly
-
Install the required packages:
pip install -r requirements.txt
python mask.py --image_path "data\\3796\\raw\\3796_20241216_223631.jpg"
python segment.py --input_folder "data/3796/raw" --output_folder "data/3796/masked" --points_json "points.json"
Obtain API key from Roboflow and run:
python inference.py --masked_dir "data/3796/masked" --output_dir "data/3796/output" --json_dir "data/3796/json" --api_key "YOUR_ROBOFLOW_API_KEY"
python prepare.py --json_directory "data/3796/json" --points_json "points.json" --output_file "37962_vehicle_data.csv"
python anomaly.py --file_path "3796_vehicle_data.csv" --significance_level 0.001