The aim of this project is to develop a robust system for counting people in crowded environments using advanced computer vision techniques. This involves using the YOLOv8 model, which is known for its high performance in object detection tasks, to detect and track individuals in video feeds. The project focuses on accurately counting the number of people crossing a predefined line, making it applicable for scenarios such as traffic monitoring and managing crowd flow in public areas.
The primary goal of this repository is to implement a people counting system using the YOLOv8 object detection model from Ultralytics. The model is trained on the Crowd Human dataset [1], the CrowdHuman dataset is large, rich-annotated and contains high diversity, ensuring it can generalize well across different environments with varied crowd densities. The system processes video feeds, detects and tracks people, and counts how many cross a designated line in the video.
- Python
- YOLOv8 (Ultralytics)
-
Clone the repository: git clone https://github.com/omerAJ/peopleCounting.git cd people-counting
-
Install required Python libraries: pip install -r requirements.txt
-
Just detect and count
- Use the provided script in Scripts/counting.py to run the YOLOv8 model on your video feed. This script loads the pre-trained YOLOv8 model and applies it to detect and count people in the video, it tracks the detected individuals across frames and counts how many cross a predefined line in the video feed. Adjust the line coordinates in the script based on your specific requirements.
-
Count and collect GT
- In addition to detect and count this code can also be used to collect GT counts to evaluate performance of model. As you watch the video, the model counts are automatically incremented and you can use key presses to count the actual people in/out.
The crowd human dataset used for training the YOLO is placed in D://omer/crowdHuman The folder includes:
- original data
- data converted to YOLO format
- annotation of head of human
- use train.py to train the model, provide it path to the data.yaml file and select the model you want to train.
- all pretrained models are saved in D://omer/YOLO_weights
Full credits to the mentioned papers.
[1] @article{shao2018crowdhuman, title={CrowdHuman: A Benchmark for Detecting Human in a Crowd}, author={Shao, Shuai and Zhao, Zijian and Li, Boxun and Xiao, Tete and Yu, Gang and Zhang, Xiangyu and Sun, Jian}, journal={arXiv preprint arXiv:1805.00123}, year={2018} }
- This project was done at Centre for Urban Informatics, Technology, and Policy (CITY @ LUMS)