Helmet detection experiment, designed using YOLOv7 object detection model, with bicycle and motorbike helmets training data
The dataset used for training the model is not included in this repository. You can use your own dataset or download a helmet detection dataset from https://www.kaggle.com/datasets/andrewmvd/helmet-detection
To set up the environment for running the algorithm, follow these steps:
-
Clone this repository:
git clone git@github.com:Jawabreh0/helmet-detection.git
-
Navigate to the cloned repository:
cd helmet-detection
-
Download the YOLOv7 weights:
wget https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7.pt
-
Download the YOLOv7x weights:
wget https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7x.pt
-
Install the required packages:
pip install -r requirements.txt
To train the algorithm, run the following command:
python train.py --data data.yaml --cfg models/custom_yolov7.yaml --weights yolov7.pt
You can adjust the batch size, number of epochs, and other parameters by modifying the command above.
To detect helmets in an image, run the following command:
python detect.py --weights runs/train/exp/weights/best.pt --img 640 --conf 0.4 --source path/to/image.jpg
This will output an image with bounding boxes around the detected helmets.
The trained model achieved an average precision of 0.85 on the test set.
This project is licensed under the MIT License