4、yolov5 model training

yolov5 official tutorial: https://github.com/ultralytics/yolov5/blob/master/tutorial.ipynb

yolov5 official source code: https://github.com/ultralytics/yolov5

yolov5 weight file: https://github.com/ultralytics/yolov5/releases

4.1. yolov5 introduction

In February 2020, Joseph Redmon, the father of YOLO, announced his withdrawal from the field of computer vision research. YOLOv4 was released on April 23, 2020, and YOLOv5 was released on June 10, 2020. The developer of YOLOv5 claims that YOLOv5 can achieve a fast detection of 140 FPS on Tesla P100; while the detection speed of YOLOv4 is 50 FPS. Not only that, the size of YOLOv5 is only 27 MB. YOLOv4 is 244 MB. YOLOv5 is nearly 90% smaller than YOLOv4. In terms of accuracy metrics, YOLOv5 is comparable to YOLOv4.

As a result, YOLOv5 is very fast, has a very lightweight model size, and is as accurate as the YOLOv4 baseline.

Yolov5 author’s algorithm performance test chart:

image-20220301141838248

Video test official case

Important folder description:

4.2. Environmental requirements

The factory image has been configured and no installation is required.

Installation example

4.3. Usage process

4.4. Custom training data set

4.4.1. Collect data sets

First go to Baidu to download or use other methods. Under the path [garbage/texture], fill in more background images ([more])

Run the [Get_garbageData.py] file to obtain the data set

4.4.2. Create yaml file

For example garbage.yaml:

4.5.3. Modify train.py

Other places are based on your own needs.

4.5.4. Modify model configuration file

Modify the second line of the yaml file of the yolov5 neural network and use which weight file to modify the corresponding yaml file.

Here we are using yolov5s.yaml, so just modify the second line of the models/yolov5s.yaml file.

4.5.5. Modify detect.py

It’s almost the same place that needs to be modified in the [train.py] file.

Other places are based on your own needs.

4.5.6. Training and prediction

Train the model. After training, the final model will be produced in the [runs/train] folder. By default, the folder with the exp prefix is generated, and the latest one is generated.

Video real-time monitoring requires modifying the model path.