YOLOv7 model training

surroundings

  • ubuntu 18.04 64bit
  • torch 1.7.1+cu101

Dataset Preparation

Here is an example of the mask data set we used in the training of the YOLOv5 model . This data set comes from the website roboflow.com . It is really great to have a look at this site again. There are not only detailed blog tutorials, but also many open sources. The data set, and the supported data formats are also very rich, it is definitely worth visiting frequently.

The download address of the mask dataset: https://public.roboflow.com/object-detection/mask-wearing/4 , here is also a copy on the Baidu network disk, and you need to pick it up yourself

Link: https://pan.baidu.com/s/1JvniT205zX79wASqiKtt5Q

Extraction code: 9feh

After downloading the dataset, unzip it, rename the folder to mask , and put it in the root directory of yolo v7 (you can do anything here, as long as the paths before and after match), the complete directory structure is as follows

It can be found that in fact, yolo v7 and yolo v5 dataset formats are exactly the same, and the same conclusion can be drawn through the labeling tool labelimg

train

Before model training starts, we need to modify some configuration files

First is the data.yaml in the dataset

 train: mask/train/images val: mask/valid/images nc: 2 names: ['mask', 'no-mask']

Second, modify the configuration file cfg/training/ yolo v7.yaml in yolo yolo v7 , mainly the nc field

 nc: 2 # number of classes

Then, to train, execute

 python train.py --data mask/data.yaml --cfg cfg/training/yolov7.yaml --weights '' --name yolov7 --hyp data/hyp.scratch.p5.yaml

Model testing

Finally, let’s test the effect of the model

 python detect.py --source mask/test/images/shutterstock_1627199179_jpg.rf.350e69105dd1458572a590c3e3ef2538.jpg --weight runs/train/yolov7/weights/best.pt

 python detect.py --source mask/test/images/the-first-day-of-wuhan-s-closure-some-people-fled-some-panicked_jpg.rf.51ed69bf8d327d93b429a08581f6dea0.jpg --weight runs/train/yolov7/weights/best.pt

This article is reprinted from https://xugaoxiang.com/2022/08/02/yolov7-training/
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment

Your email address will not be published.