This project focuses on tracking people in video frames using the YOLOv8 object detection model. The code provides three main components: exploratory data analysis (EDA) on the COCO 2017 dataset, training the YOLOv8 model on the filtered dataset, and then using the trained model to track people in a video.
- Performed EDA on the COCO 2017 dataset to filter for the 'person' class.
- Trained YOLOv8 models (yolov8n, yolov8s, yolov8m) on the filtered COCO 2017 dataset.
- Implemented video tracking using the trained YOLOv8 models to detect and track people in a video.
- Saved the tracked video with bounding boxes and unique IDs for each person.
- Reported the total number of people detected in the video.
- Python 3.x
- Ultralytics YOLO library
- FiftyOne library
- OpenCV library
- Matplotlib library
- Clone the repository:
git clone https://github.com/your-username/person-tracking.git
- Navigate to the project directory:
cd person-tracking
- Install the required dependencies:
pip install -r requirements.txt
Before training the YOLOv8 models, we performed an exploratory data analysis (EDA) on the COCO 2017 dataset to prepare the data for training.
- Loaded the COCO 2017 dataset using the FiftyOne library, focusing on the 'person' class.
- Filtered the dataset to only include samples with 'person' detections in the ground truth.
- Exported the filtered dataset in the YOLOv5 format, with the 'person' class as the only label, to the
./yolov5-coco-datasets
directory.
This process ensured that the training, validation, and test splits of the dataset only contained samples with 'person' detections, which was the focus of our person-tracking project.
- Run the EDA code:
python eda.py
This will load the COCO 2017 dataset, filter it for the 'person' class, and export the dataset in the YOLOv5 format.
- Run the training code:
python train.py
This will train the YOLOv8 models on the filtered COCO 2017 dataset and save the trained weights in the ./training/
directory.
- Run the tracking code:
python track.py
This will use the trained YOLOv8 model to detect and track people in the provided video, saving the output video in the current directory.
The trained YOLOv8 models achieved the following mean average precisions (mAP) on the COCO 2017 validation set:
- yolov8n:
0.61287
- yolov8s:
0.56026
- yolov8m:
0.59617
The tracking code was able to detect and track number of people in the provided video.
output.mp4
output-2.mp4
- Integrate more advanced tracking algorithms to improve the accuracy and robustness of the person tracking.
- Explore the use of other object detection models, such as YOLOv5 or Faster R-CNN, and compare their performance.
- Implement real-time person tracking on live video streams.
- Explore the integration of the person tracking system with other applications, such as people counting or activity recognition.
This project is licensed under the MIT License.