Model training

1.Introduction

Yolov5 author's algorithm performance test chart:

2. Environmental requirements

You don't need to reinstall these software to use the virtual machine we provide, just run the program directly.

3. Model training

Using the virtual machine we provide does not require retraining, simply skip it. This tutorial is intended for users of secondary development (you can refer to the official YOLOv5 training tutorial if you need a certain foundation)

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

(1) Introduction to folder structure

Data/garage/train/images: storing images of the dataset

Data/garage/train/labels: Store labels for the dataset

inference/images: Test image path

inference/output: Test output path

data/image: Store the original image (target image to be recognized)

data/context: Store background images (more needed)

data/Get_ GarbagData.py: Automatically generate corresponding datasets (requires more) The weights folder is used to store weight files (pre trained models). If you need the latest version or other model files, please download them from the official website

runs: Training output position

runs/exp/weights: If there are two files, best. pt is the best training model. If there is only one file, there is no choice

There are validation images in the runs/exp file. After training for an epoch, go and check if the images are correct. If they are not correct, adjust them quickly.

Otherwise, if you adjust them after training, you will have to retrain/ Runs/exp1/results. txt: Training log information

(2)Training steps

Note that the names of the images and label files should correspond, and the format of the label file is category center point x, center point y, border width w, border height h.

The label format is as follows:

Found nc: The number of categories matches the custom yaml file

epochs: Refers to how many times the entire dataset will be iterated during the training process. If the graphics card is not working, you can adjust it down a bit.

batch size: How many images do you need to view at once before updating the weight? For mini batch with gradient descent, if the graphics card doesn't work, you can adjust it down a bit.

cfg: Configuration file for storing model structure

data: A file that stores training and testing data

img size: Input the width and height of the image. If the graphics card doesn't work, you can adjust it down a bit.

rect: Perform rectangular training

resume: Restore the recently saved model and start training

nosave: Only save the final checkpoint

note: Only test the last epoch

evolve: Evolutionary hyperparameters

bucket: gsutil bucket

cache images: cache images to speed up training

weights: weight file path

name: Renaming results. txt to results_ Name.txt

device: cuda device, i.e. 0 or 0,1,2,3 or CPU

adam: Optimizing with Adam

multi scale: Multi scale training, img size+/-50%

single cls: a single class training set

(3)Custom model testing