A Safety Equipment Detection System

Nahidul Islam
2 min readSep 16, 2022

--

In this article, I'm going to describe how I build Safety Equipment Detection System using YOLOv7-X.

@analyticalnahid

Why YOLOv7-X?

The YOLO algorithm is important because of the following reasons:

  • Speed: This algorithm improves the speed of detection because it can predict objects in real-time.
  • High accuracy: YOLO is a predictive technique that provides accurate results with minimal background errors.
  • Learning capabilities: The algorithm has excellent learning capabilities that enable it to learn the representations of objects and apply them in object detection.

Dataset Info:

Dataset Link

Dataset annotation format: Pascal VOC (XMLs)

Step 01 (Label Data):

  • Download Dataset
  • Convert the annotation format to YOLO supported format Code here

Step 02 (Configure YOLOv7):

  • Clone Yolov7 repository link
  • Copy train & validation dataset with labels files from step 01 to /yolov7/data
  • Create a custom YAML file in the data folder and specify your train and validation folder links. Specify the number of the class and class name also.
  • Goto yolov7/cfg/training/ folder then create a copy of your desired yolo version in my case it’s yolov7-x, open the file in the text editor change the number of the class according to your requirements, reset the things will remain same and save it.

Step 03 (Train model):

  • Train model sample command below:

!python train.py β€” device 0 β€” batch-size 8 β€” epochs 10 β€” img 640 640 β€” data data/custom_data.yaml β€” hyp data/hyp.scratch.custom.yaml β€” cfg cfg/training/yolov7x-custom.yaml β€” weights yolov7x.pt β€” name yolov7x-custom

  • It’s required some time based on your data and hardware capacity.

Step 04 (Validate model):

  • Validation model sample command below:

!python detect.py β€” weights runs/train/yolov7x-custom3/weights/best.pt β€” conf 0.5 β€” img-size 640 β€” source /kaggle/working/yolov7/data/val/images/hard_hat_workers663.png β€” no-trace

  • It can validate images and videos. Just provide the source file

Step 05 :

  • If you're happy with your result then nothing to worry about, if not then retrain it again with more data and apply some hyperparameter tunning techniques or data augmentation techniques

Do you want learn more about YOLOv7? Just follow me more cool projects are coming soon!

If you find this article helpful don’t forget to give claps and feedback. Share with your friends and colleagues. In case you have any query you can drop mail to πŸ“§ analyticalnahid@gmail.com

πŸ’¬ My Social Profile :- GitHub | LinkedIn | YouTube | Facebook

--

--