This project is an implementation of vehicle detection and counting using YOLOv8 object detection model and PyQt5 GUI framework. The project is capable of detecting and counting vehicles in a given video.
- Python 3.6 or higher
- PyQt5
- OpenCV
- Pytorch
You can install these dependencies by running the following command:
pip install -r requirements.txt
- Clone the repository:
git clone https://github.com/IstakozNecmi/VehicleDetectCounting-PyQt5_GUI-Yolov8.git
- Navigate to the cloned repository:
cd VehicleDetectCounting-PyQt5_GUI-Yolov8
- Run the program:
python main.py
-
Select the input video file.
-
Press the Start button to start detecting and counting the vehicles in the video.
This project comes with a pre-trained YOLOv8 object detection model. However, you can train your own custom model by following these steps:
-
Prepare the dataset by collecting and annotating images.
-
Generate the
train.txt
andvalid.txt
files containing the paths to the training and validation images. -
Modify the
data/custom.data
file to specify the number of classes and the paths to thetrain.txt
andvalid.txt
files. -
Download the pre-trained weights file from the official YOLOv8 repository.
-
Train the model using the following command:
python train.py --data data/custom.data --cfg cfg/custom.cfg --weights weights/yolov8.weights --batch-size 32
- Once the model is trained, modify the
config.py
file to specify the paths to the custom model weights and configuration files.
This project was inspired by the YOLOv5 repository and the Vehicle Detection and Tracking project.