By inputting a picture - performing convolution - getting the output result The Yolo algorithm uses a separate CNN model to achieve end-to-end target detection. The entire system is shown as follows: First Resize the input image to 448x448, then send it to the CNN network, and finally process the network prediction results to obtain the detected target. Compared with the R-CNN algorithm, it is a unified framework, it is faster, and the training process of Yolo is also end-to-end.
Before training, pre-training was performed on ImageNet. The pre-trained classification model uses the first 20 convolutional layers in Figure 8, and then adds an average-pool layer and a fully connected layer. . After pre-training, 4 randomly initialized convolution layers and 2 fully connected layers are added to the 20 convolution layers obtained from pre-training. Since detection tasks generally require higher-definition images, the input of the network is increased from 224x224 to 448x448. The flow of the entire network is shown in the figure below:
2. Train your own model
Directory Structure
2.1 Create a new directory Mydata as shown below under Data
mydata
images
test
train (storage original image)
labels
test
train (storage labeled images)
After saving the picture
As shown in the figure, it is a building block diagram
2.1 Labelimg graphics for data annotation
If lableimg is not installed, you can install it.
2.2 Dataset
# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: /home/hfg/Soft/Idea_Project/deep/yolov5/data/mydata/images/train # dataset root dir
train: /home/hfg/Soft/Idea_Project/deep/yolov5/data/mydata/images/train # train images (relative to 'path') 128 images
val: /home/hfg/Soft/Idea_Project/deep/yolov5/data/mydata/images/train # val images (relative to 'path') 128 images
test: # test images (optional)# Classes
names:
0: 积木
2.3 train.py adjusts the data dataset
2.4 Start training
Training is performed as shown in the figure, this epochs is 100