Lightweight wheat ear extraction algorithm based on YOLOv5s+4 +ECAC3 model

By introducing GhostNet, MobileNetV3 and ShuffleNetV2 and other networks into the YOLOv5s+4+ECAC3 model, combined with the RRelu activation function and EIOU loss function, the model structure is optimized, solving the problem of large parameters and calculations in wheat ear detection, and achieving a better Efficient detection speed and accuracy.

CN118570652AInactive Publication Date: 2024-08-30TIANDI INFORMATION NETWORK RES INST (ANHUI) CO LTD

Patent Information

Application Number
CN202411035534.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-31
Publication Date
2024-08-30
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing technologies have problems with lightweight models in wheat ear detection, such as excessive parameter quantities and calculations, and slow detection speeds, making it difficult to meet the needs of equipment deployment and accuracy improvement.

Method used

Introduce GhostNet, MobileNetV3 and ShuffleNetV2 networks into the YOLOv5s+4+ECAC3 model, replace the C3 module and Conv module, and use the RRelu activation function and EIOU loss function to optimize the model structure and loss calculation.

Benefits of technology

It reduces the number of model parameters, size and number of floating-point operations, improving detection speed and accuracy. The number of parameters is reduced by 32%, the model size is reduced by 30%, the number of floating-point operations is reduced by 33.2%, and the accuracy is increased by 1.1% compared to the original model. and 0.86%, applicable to wheat ear detection services.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118570652A
    Figure CN118570652A
Patent Text Reader

Abstract

The invention provides a lightweight wheat ear extraction algorithm based on a YOLOv5s + 4 + ECAC3 model. Firstly, a GhostNet lightweight architecture is combined with a YOLOv5s + 4 + ECAC3 model, the calculation amount of the model is greatly reduced, a MobileNetV3 network is used for improving the YOLOv5s + 4 + ECAC3, and a trunk part in the network is replaced by the MobileNetV3; and then, an original Siou activation function and an original CIOU loss function are improved into an RReLU activation function and an EIOU loss function, so that the detection precision is improved. According to the method, the calculation amount of the model is reduced, the wheat ear detection precision is improved, and the method is suitable for wheat ear detection tasks.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of wheat ear image detection, and in particular to a lightweight wheat ear extraction algorithm based on a YOLOv5s+4+ECAC3 model. Background Art

[0002] Common methods for lightweighting deep learning networks mainly include network pruning and knowledge distillation. Network pruning is a model compression technology. Its main purpose is to remove some parameters and connections in the network, thereby reducing the size and number of parameters of the model without affecting the accuracy as much as possible, thereby reducing the storage and operation costs of the model. There are three main pruning methods, namely pruning before, during and after training, and fine-tuning. The process mainly includes five steps: (1) training the neural network; (2) evaluating the importance of weights and neurons; (3) sorting neurons or weights in order of importance, and then deleting the unimportant ones; (4) after deleting unimportant neurons or weights, the network will be damaged to a certain extent, so the network is fine-tuned to restore it; (5) since the number of pruning cannot be too large each time, it will be difficult to meet our needs, so it can be iterated until it meets our requirements. Knowledge distillation transfers the knowledge learned by the original model to the compressed model. It can not only meet the requirements of reducing the model size, but also learn the same knowledge. In the distillation process, the large model is called the teacher model and the small model is called the student model. The main steps are as follows: (1) Dataset preparation, that is, preparing a dataset for training; (2) Training the teacher model. The teacher model can be a trained model or a model trained from scratch. Use the teacher model to train on the prepared model to achieve a high accuracy; (3) Obtain the output results of the teacher model and use these results as the target labels of the student model; (4) Prepare a student model, which is a transformer-based image classification model. These models have been trained on small-scale datasets. Their computational cost is relatively low and the memory usage is not large; (5) Select a suitable loss function for knowledge distillation, which is a relatively important step. It is used to compare the output of the student model with the output of the teacher model. The loss function of distillation is binary cross entropy instead of KL entropy. The purpose is to reduce the amount of calculation and memory usage while improving the accuracy; (6) Train the student model with the same dataset, let the student model learn the soft labels of the teacher model, calculate the loss function and back propagate until the model converges; (7) Adjust the temperature parameter.

[0003] With the development of technology, the lightweighting of models is no longer limited to pruning, knowledge distillation, etc. More and more experts and scholars have begun to design lightweight networks for use in their own network models. The addition of these models can help us better deploy our models on devices. New lightweight networks mainly include MobileNet type networks, ShuffleNet type networks, and GhostNet networks. On this basis, in order to improve the accuracy of wheat ear detection and reduce the amount of model calculation, we propose a lightweight wheat ear extraction algorithm based on the YOLOv5s+4+ECAC3 model. Summary of the invention

[0004] In view of the problems existing in the existing technical solutions, the object of the present invention is to provide a lightweight wheat ear extraction algorithm based on the YOLOv5s+4+ECAC3 model.

[0005] To achieve the above object, the present invention provides the following technical solutions: A lightweight wheat ear extraction algorithm based on the YOLOv5s+4+ECAC3 model includes the following steps: (1) Introduce GhostNet into the YOLOv5s+4+ECAC3 network to generate a new network YOLOv5s+4+ECAC3+Ghost; the specific introduction method is as follows: (1.1) Replace all C3 modules in the YOLOv5s+4+ECAC3 network with C3Ghost modules; (1.2) Replace all Conv modules except the first Conv module in the YOLOv5s+4+ECAC3 network with GhostConv modules; (2) Use the MobileNetV3 network to improve YOLOv5s+4+ECAC3 and replace the backbone part of its network with MobileNetV3; (3) Improvement of activation function: The original Siou activation function is changed to RRelu activation function, and its formula is as follows: , this function is based on Relu and introduces and Two parameters, the original linear correction unit is improved into an adaptive and extensible linear unit; (4) Improvement of loss function; the loss function calculation formula is shown in Formula 1-1: (1-1) in, represents the classification loss, represents the confidence loss, Indicates position loss; The loss function used by YOLOv5 is CIOU, which can achieve regression through two center points after measuring the difference between the predicted box and the true box. The calculation method is shown in formulas 1-2, 1-3, 1-4 and 1-5: (1-2) (1-3) (1-4) (1-5) in, Used to determine whether the size of the predicted box and the real box are consistent. It is a balance factor that measures the aspect ratio and IoU loss. represents the diagonal distance of the minimum closure area, represents the center point of the prediction box, Indicates the center point of the real box; Use the EIOU loss function to replace the original CIOU loss function. The calculation process is shown in formula 1-6: (1-6) in, and Respectively represent the width and height of the minimum bounding box covering the prediction box.

[0006] Furthermore, in step (2), MobileNetV3 is divided into two different network structures, namely, MobileNetV3-large and MobileNetV3-small. Indicates the number of channels that the 1×1 convolution increases. represents the number of output feature maps, Indicates whether the SE attention mechanism is added here. It represents stride, that is, the step size. It indicates the type of activation function added; The representative activation function is h-swish, and the calculation formula is shown in Formula 2-1: (2-1) Represents the Relu activation function, and its calculation formula is shown in Formula 2-2: (2-2).

[0007] Furthermore, the step (2) can also use the ShuffleNetV2 network to improve the YOLOv5s+4+ECAC3 network by replacing the backbone part of the network with ShuffleNetV2.

[0008] Furthermore, in step (3), the RRelu activation function updates the parameters of the RRelu. and parameters There are two main parts in the training process: forward propagation and back propagation. In the former, all parameters are involved in the calculation, but there is no update. In the latter, there is an update. Before updating the parameters, the cross entropy loss function is determined first, and then a series of calculations are performed in the forward propagation process, as shown in Formula 3-1: (3-1) in, For the The output calculated by the forward propagation of the layer. Then the gradient descent iteration method is used to find the parameters of each layer and ; About activation functions The gradient is ,parameter and The gradient is shown in formula 3-2: (3-2) From this we can get the Layer Parameters and The gradient is shown in Formula 3-3 and Formula 3-4: (3-3) (3-4) in, are the gradients coming from the deeper layers of the network.

[0009] Finally, introduce Momentum is used to update the parameters, as shown in Formula 3-5: (3-5) Compared with the prior art, the invention has the following beneficial effects: the lightweight wheat ear extraction algorithm of the YOLOv5s+4+ECAC3 model of the invention introduces GhostNet into the YOLOv5s+4+ECAC3 network to generate a new network YOLOv5s+4+ECAC3+Ghost, the network parameter quantity is reduced by 32%, the model size is reduced by 30%, and the number of floating-point operations is reduced by 33.2%. After adding the RReLU activation function and the EIOU loss function, the model parameter quantity, size, number of floating-point operations and detection speed are almost unchanged. After adding the RReLU activation function, the accuracy of the YOLOv5s+4+ECAC3+G+RR model is improved by 1.1 percentage points relative to YOLOv5s+4+ECAC3+G, and after adding the EIOU loss function, the YOLOv5s+4+ECAC3+G+RR is improved by 0.86 percentage points. With almost no change in the model complexity, the final accuracy of YOLOv5s+4+ECAC3+G+RR+E is 2.17 percentage points lower than that of YOLOv5s+4+ECAC3, but still 0.77 percentage points higher than that of YOLOv5s. The number of parameters is reduced by 32% and 28.2% compared with YOLOv5s+4+ECAC3 and YOLOv5s respectively, the model size is reduced by 28.0% and 20% respectively, and the number of floating-point operations is reduced by 33.2% and 9.5% respectively, which can be well used in wheat ear detection services. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] The present invention will be further described below in conjunction with the accompanying drawings.

[0011] Figure 1 Schematic diagram of the traditional convolution and Ghost convolution process in the GhostNet network; Figure 2 It is a schematic diagram of the Ghost bottleneck structure; Figure 3 This is the structural block diagram of YOLOv5s+4+ECAC3+G of the present invention; Figure 4 This is a structural block diagram of the basic unit of ShuffleNetV2 of the present invention; Figure 5 This is the structural block diagram of YOLOv5s+4+ECAC3+S of the present invention; Figure 6 This is a schematic diagram of the MobileNetV3 structure; Figure 7 This is the structural block diagram of YOLOv5s+4+ECAC3+M; Figure 8 This is the image structure diagram of the RRelu activation function. DETAILED DESCRIPTION

[0012] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention. Example 1

[0013] In the GhostNet network, the original Conv layer is changed to the Ghost module. The traditional convolution operation and the Ghost convolution operation are as follows: Figure 1 As shown in the figure. In the process of Ghost convolution, the convolution kernel is half of the ordinary convolution layer, so the amount of calculation is reduced by half to obtain half of the feature map. The secondary convolution process performs a depth-separable convolution on the feature map output by the primary convolution, so as to obtain the other half of the feature map, and then combine the two parts together; For an input feature map, assume that its number of channels, height, and width are , , , the input features are , the convolution kernel size is , the number of convolution kernels is , the bias term is The output features are , the calculation formula of ordinary convolution is shown in formula 1.1: (1.1); For ordinary convolution, the FLOP calculation amount is In the operation of GhostNet, after the size of the output feature map and the number of feature maps are determined, the number of groups in the operation can be calculated First, the first group is obtained by convolution operation with a smaller convolution kernel. The computational cost is ; Then perform linear transformation, and get the second group, the third group, etc., the calculation amount is , is the average size of the convolution kernel in the linear transformation; finally, the feature maps outputted previously are combined and concatenated. The ratio of the computational complexity of ordinary convolution and GhostNet is shown in formula (1.2): (1.2); From this we can see that GhostNet requires much less computation than ordinary convolution.

[0014] In the Ghost module, there is also a part called the Ghost bottleneck layer, which is mainly composed of multiple Ghost modules stacked together. There are two main types of Ghost bottleneck layers. One is with stride 1, and all 3×3 convolutions are replaced by Ghost modules. The other is with stride 2, and depthwise separable convolutions with stride 2 are introduced into the Ghost module. Their structures are as follows: Figure 2 shown.

[0015] Depend on Figure 2 It can be seen that the main steps of Ghost are as follows: (1) convolution calculation; (2) adjusting the number of channels; (3) using global average pooling and standard convolution to change the size of the feature map to obtain a 1×1×1280 feature layer.

[0016] Due to the excellent performance of the GhostNet network, this application introduces it into the YOLOv5s+4+ECAC3 network to generate a new network YOLOv5s+4+ECAC3+Ghost. The specific introduction method is as follows: (1) Replace all C3 modules in the YOLOv5s+4+ECAC3 network with C3Ghost modules; (2) Replace all Conv modules except the first Conv module in the YOLOv5s+4+ECAC3 network with GhostConv modules. This optimizes the model's computational complexity, size, and detection speed. The YOLOv5s+4+ECAC3+G structure block diagram is shown below. Figure 3 shown.

[0017] This embodiment provides a lightweight wheat ear extraction algorithm based on the YOLOv5s+4+ECAC3 model, including the following steps: (1) Introduce GhostNet into the YOLOv5s+4+ECAC3 network to generate a new network YOLOv5s+4+ECAC3+Ghost; the specific introduction method is as follows: (1.1) Replace all C3 modules in the YOLOv5s+4+ECAC3 network with C3Ghost modules; (1.2) Replace all Conv modules except the first Conv module in the YOLOv5s+4+ECAC3 network with GhostConv modules; (2) Use the MobileNetV3 network to improve YOLOv5s+4+ECAC3 and replace the backbone part of its network with MobileNetV3; MobileNet networks mainly include three generations of networks: MobileNetV1, MobileNetV2, and MobileNetV3. Among them, the biggest feature of MobileNetV1 is that it changes the traditional convolution to a depth-separable convolution and uses the width coefficient to reduce the number of parameters. Compared with MobileNetV1, MobileNetV2 adds an inverted residual structure to reduce memory usage. MobileNetV3 can be said to have inherited the previous two. It not only uses the depth-separable convolution of MobileNetV1, but also introduces the inverted residual structure of MobileNetV2. In addition, the SE module is introduced into the network, which greatly improves the performance of the network. Its structure diagram is as follows Figure 6 shown.

[0018] In step (2), MobileNetV3 is divided into two different network structures, namely, MobileNetV3-large and MobileNetV3-small. Indicates the number of channels that the 1×1 convolution increases. represents the number of output feature maps, Indicates whether the SE attention mechanism is added here. It represents stride, i.e. the step size. It indicates the type of activation function added; The representative activation function is h-swish, and the calculation formula is shown in Formula 2-1: (2-1) Represents the Relu activation function, and its calculation formula is shown in Formula 2-2: (2-2).

[0019] Compared with the previous two generations, the performance of MobileNetV3 network has been greatly improved. Therefore, this embodiment uses MobileNetV3 network to improve YOLOv5s+4+ECAC3, and changes its backbone network to MobileNetV3 to reduce the size and computation of the model. The improved model is named YOLOv5s+4+ECAC3+M, and its structure is as follows: Figure 7 .

[0020] (3) Improvement of activation function: The original Siou activation function is changed to RRelu activation function, whose formula is as follows: , this function is based on Relu and introduces and Two parameters, the original linear correction unit is improved into an adaptive and extensible linear unit; RRelu activation function image Figure 8 Parameters and Can be any value, as The right half of the function graph moves between the first and third quadrants. When the right half is in the first quadrant, When , the right half is in the fourth quadrant; The left half of the function graph moves in the second and third quadrants. When the left part of the image is in the third quadrant, , the left half of the image is in the second quadrant.

[0021] In step (3), the parameters of the RRelu activation function are updated. and parameters There are two main parts in the training process: forward propagation and back propagation. In the former, all parameters are involved in the calculation, but there is no update. In the latter, there is an update. Before updating the parameters, the cross entropy loss function is determined first, and then a series of calculations are performed in the forward propagation process, as shown in Formula 3-1: (3-1) in, For the The output calculated by the forward propagation of the layer. Then the gradient descent iteration method is used to find the parameters of each layer and ; About activation functions The gradient is ,parameter and The gradient is shown in formula 3-2: (3-2) From this we can get the Layer Parameters and The gradient is shown in Formula 3-3 and Formula 3-4: (3-3) (3-4) in, are the gradients coming from the deeper layers of the network.

[0022] Finally, introduce Momentum is used to update the parameters, as shown in Formula 3-5: (3-5) (4) Improvement of loss function; the loss function calculation formula is shown in Formula 1-1: (1-1) in, represents the classification loss, represents the confidence loss, Indicates position loss; The loss function used by YOLOv5 is CIOU, which can achieve regression through two center points after measuring the difference between the predicted box and the true box. The calculation method is shown in formulas 1-2, 1-3, 1-4 and 1-5: (1-2) (1-3) (1-4) (1-5) in, Used to determine whether the size of the predicted box and the real box are consistent. It is a balance factor that measures the aspect ratio and IoU loss. represents the diagonal distance of the minimum closure area, represents the center point of the prediction box, Indicates the center point of the real box; Use the EIOU loss function to replace the original CIOU loss function. The calculation process is shown in formula 1-6: (1-6) in, and Respectively represent the width and height of the minimum bounding box covering the prediction box.

[0023] Example 2 In step (2) of this embodiment, the ShuffleNetV2 network can also be used to improve the YOLOv5s+4+ECAC3 network, replacing the backbone part of the network with ShuffleNetV2.

[0024] Improved YOLOv5s+4+ECAC3 model based on ShuffleNetV2: The main function of ShuffleNetV2 is to achieve image classification while reducing the amount of calculation and the number of parameters. The structure of ShuffleNetV2 can be divided into the following modules: (1) Basic modules, namely grouped convolution, channel reorganization and batch normalization; (2) Bottleneck modules, namely 1×1 convolution, grouped convolution, channel reorganization and batch normalization; (3) ShuffleNetV2 unit, which is a combination of the basic module and the bottleneck module.

[0025] The basic units of the ShuffleNetV2 network can be divided into two types: step size 1 and 2. The structure diagram is as follows Figure 4 shown. Figure 4 In the example, DWConv represents a depthwise separable convolutional layer, Conv represents a normal convolutional layer, BN represents batch normalization, Channel Split represents splitting on the channel dimension, Channel Shuffle is a channel shuffling module, which is mainly used to promote information exchange, and Concat is a concatenation module. When the step size is 1, the channel of the input feature matrix is ​​shuffled. It is divided into two parts, one of which is , the other part is , the left end directly reaches the Concat module and is concatenated with the output on the right. There are no other operations in the process. On the right end, it goes through two 1×1 convolutions and one 3×3 separable convolution. When the stride is 2, there is no split operation on the channel. There is a 3×3 separable convolution and a 1×1 convolution on the left, and the structure on the right is the same as when the stride is 1.

[0026] Compared with ShuffleNetV1, ShuffleNetV2 has an optimized network, which is more helpful to reduce the number of network parameters while improving accuracy. The present invention uses ShuffleNetV2 network to improve the YOLOv5s+4+ECAC3 network, replacing the backbone of the network with ShuffleNetV2. The improved new network is called YOLOv5s+4+ECAC3+S, and its structure is shown in the figure. Figure 5 shown.

[0027] The experimental results of the embodiments are presented and analyzed below.

[0028] Table 4.1 compares the experimental results of five models: YOLOv5s, YOLOv5s+4+ECAC3, YOLOv5s+4+ECAC3+G, YOLOv5s+4+ECAC3+S and YOLOv5s+4+ECAC3+M on the global wheat dataset.

[0029] Table 4.1 Performance comparison of different algorithms Network Model Parameter quantity (M) Model size (MB) Floating point operations (GFlops) Fps Accuracy (%) YOLOv5s 7.01 14.50 15.80 74.60 91.03 YOLOv5s+4+ECAC3 7.50 16.10 21.40 49.50 93.97 YOLOv5s+4+ECAC3+G 5.10 11.60 14.30 51.80 89.84 YOLOv5s+4+ECAC3+S 3.50 7.40 2.60 71.40 78.52 YOLOv5s+4+ECAC3+M 3.50 7.50 6.20 80.60 86.80

[0030] As can be seen from Table 4.1, after the lightweight improvement of the YOLOv5s+4+ECAC3 network, the network has been significantly reduced in terms of parameter quantity, model size, and number of floating-point operations. Among them, the network with the largest reduction is the YOLOv5s+4+ECAC3+S network, with only 3.50M parameters, a decrease of 53.3% compared to YOLOv5s+4+ECAC3, the model size is 7.40MB, a decrease of 54.0%, and the number of floating-point operations is 2.60GFlops, a decrease of 87.9%. The second is the YOLOv5s+4+ECAC3+M network, with the same number of parameters as the YOLOv5s+4+ECAC3+S network, a decrease of 53.3, the model size is 7.50MB, a decrease of 53.4%, and the number of floating-point operations is 6.20GFlops, a decrease of 71.0%. The number of parameters of the YOLOv5s+4+ECAC3+G network decreased by 32%, the model size decreased by 30%, and the number of floating-point operations decreased by 33.2%. In terms of detection speed, the fastest detection speed among the three models is the YOLOv5s+4+ECAC3+M network, reaching 80.60Fps, followed by the YOLOv5s+4+ECAC3+S network, with a detection speed of 71.40Fps. The worst detection speed is the YOLOv5s+4+ECAC3+G network, only 51.80Fps, but it is still better than the YOLOv5s+4+ECAC3 network. In terms of accuracy, the highest is the YOLOv5s+4+ECAC3+G network, reaching 89.84%, followed by the YOLOv5s+4+ECAC3+M, with an accuracy of 86.8%. The detection effect of YOLOv5s+4+ECAC3+S is the worst, only 78.52%.

[0031] By comparing the above data, we found that although the YOLOv5s+4+ECAC3+S network and the YOLOv5s+4+ECAC3+M network have reduced a lot in terms of parameter quantity, model size and number of floating-point operations, their accuracy is too low, only 78.52% and 86.8% respectively, which are 15.45 and 7.17 percentage points lower than the accuracy of the YOLOv5s+4+ECAC3 network, respectively, and are not suitable for practical applications. Although the effect of YOLOv5s+4+ECAC3+G in terms of parameter quantity, model size, number of floating-point operations and detection speed is not the best, it can still have a high accuracy while reducing the model size and improving the detection speed, which is 0.19 percentage points lower than the accuracy of the original YOLOv5s network and 4.13 percentage points lower than the accuracy of the YOLOv5s+4+ECAC3 network. In summary, the GhostNet network is selected to make lightweight improvements to the YOLOv5s+4+ECAC3 model, that is, the YOLOv5s+4+ECAC3+G network is selected as the lightweight wheat ear detection model. The activation function used by YOLOv5 is the Siou activation function. The present invention changes the Siou activation function to Hard-swish, ELU, ACON, ReLU and RReLU activation functions respectively. The improved models are called YOLOv5s+4+ECAC3+G+H, YOLOv5s+4+ECAC3+G+E, YOLOv5s+4+ ECAC3+G+A, YOLOv5s+4 +ECAC3+ G +R and YOLOv5s+4+ECAC3+G+RR respectively. The comparison results are shown in Table 4.2.

[0032] Table 4.2 Performance comparison of different algorithms Network Model Parameter quantity (M) Model size (MB) Floating point operations (GFlops) Accuracy (%) YOLOv5s+4+ECAC3+G 5.10 11.60 14.30 89.84 YOLOv5s+4+ECAC3+G+H 5.10 11.60 14.30 89.90 YOLOv5s+4+ECAC3+G+E 5.10 11.60 14.30 86.70 YOLOv5s+4+ECAC3+G+A 5.10 11.60 14.30 88.52 YOLOv5s+4+ECAC3+G+R 5.10 11.60 14.30 89.23 YOLOv5s+4+ECAC3+G+RR 5.10 11.60 14.30 90.94 It can be seen from Table 4.2 that the change of activation function has almost no effect on the number of parameters, model size and number of floating-point operations of the network model, but has a greater impact on the accuracy of wheat ear detection. Among them, the YOLOv5s+4+ECAC3+G+RR network model with the RReLU activation function has the highest accuracy, reaching 90.94%, which is 1.1, 1.04, 4.24, 2.42 and 1.71 percentage points higher than YOLOv5s+4+ECAC3+G, YOLOv5s+4+ECAC3+G+H, YOLOv5s+4+ECAC3+G+E, YOLOv5s+4+ECAC3+G+A and YOLOv5s+4+ECAC3+G +R respectively. The lowest accuracy is YOLOv5s+4+ECAC3+G+E, with an accuracy of 86.7%. Therefore, the present invention chooses to replace the original Siou activation function with RReLU.

[0033] The YOLOv5s+4+ECAC3+G network model that changes SIOU to EIOU loss function is called YOLOv5s+4+ECAC3+G+RR+E. The comparison results are shown in Table 4.3.

[0034] Table 4.3 Performance comparison of different algorithms Network Model Parameter quantity (M) Model size (MB) Floating point operations (GFlops) Fps Accuracy (%) YOLOv5s 7.01 14.50 15.80 74.60 91.03 YOLOv5s+4+ECAC3 7.50 16.10 21.40 49.50 93.97 YOLOv5s+4+ECAC3+G 5.10 11.60 14.30 51.80 89.84 YOLOv5s+4+ECAC3+G+RR 5.10 11.60 14.30 51.80 90.94 YOLOv5s+4+ECAC3+G+RR+E 5.10 11.60 14.30 51.30 91.80 As can be seen from Table 4.3, the number of parameters of the YOLOv5s+4+ECAC3+G network has decreased by 32%, the model size has decreased by 30%, the number of floating-point operations has decreased by 33.2%, and the accuracy is 0.19 percentage points lower than the accuracy of the original YOLOv5s network, and 4.13 percentage points lower than the accuracy of the YOLOv5s+4+ECAC3 network. After adding the RReLU activation function and the EIOU loss function, the number of parameters, size, number of floating-point operations, and detection speed of the model have hardly changed. After adding the RReLU activation function, the accuracy of the YOLOv5s+4+ECAC3+G+RR model has increased by 1.1 percentage points relative to YOLOv5s+4+ECAC3+G, and the accuracy of the YOLOv5s+4+ECAC3+G+RR model has increased by 0.86 percentage points after adding the EIOU loss function. With almost no change in the complexity of the model, the final accuracy of YOLOv5s+4+ECAC3+G+RR+E is 2.17 percentage points lower than that of YOLOv5s+4+ECAC3, but still 0.77 percentage points higher than that of YOLOv5s. The number of parameters of YOLOv5s+4+ECAC3 and YOLOv5s are reduced by 32% and 28.2% respectively, the model size is reduced by 28.0% and 20% respectively, and the number of floating-point operations is reduced by 33.2% and 9.5% respectively, which can be well used in the practical application of wheat ear detection.

[0035] The above contents are merely examples of the structure of the present invention. Those skilled in the art may make various modifications or additions to the specific embodiments described or replace them in a similar manner. As long as they do not deviate from the structure of the present invention or exceed the scope defined by the claims, they shall all fall within the protection scope of the present invention.

Claims

1. A lightweight wheat ear extraction algorithm based on the YOLOv5s+4+ECAC3 model, characterized in that: The steps include: (1) Introduce GhostNet into the YOLOv5s+4+ECAC3 network to generate a new network YOLOv5s+4+ECAC3+Ghost; the specific introduction method is as follows: (1.1) Replace all C3 modules in the YOLOv5s+4+ECAC3 network with C3Ghost modules; (1.2) Replace all Conv modules except the first Conv module in the YOLOv5s+4+ECAC3 network with GhostConv modules; (2) Use the MobileNetV3 network to improve YOLOv5s+4+ECAC3 and replace the backbone part of its network with MobileNetV3; (3) Improvement of activation function: The original Siou activation function is changed to RRelu activation function, and its formula is as follows: ; This function is based on Relu and introduces and Two parameters, the original linear correction unit is improved into an adaptive and extensible linear unit; (4) Improvement of loss function; The loss function calculation formula is shown in Formula 1-1; (1-1) in, represents the classification loss, represents the confidence loss, Indicates position loss; The loss function used by YOLOv5 is CIOU, which can achieve regression through two center points after measuring the difference between the predicted box and the true box. The calculation method is shown in formulas 1-2, 1-3, 1-4 and 1-5: (1-2) (1-3) (1-4) (1-5) in, Used to determine whether the size of the predicted box and the real box are consistent. It is a balance factor that measures the aspect ratio and IoU loss. represents the diagonal distance of the minimum closure area, represents the center point of the prediction box, Indicates the center point of the real box; Use the EIOU loss function to replace the original CIOU loss function. The calculation process is shown in formula 1-6: (1-6) in, and Respectively represent the width and height of the minimum bounding box covering the prediction box.

2. According to claim 1, a lightweight wheat ear extraction algorithm based on the YOLOv5s+4+ECAC3 model is characterized in that: In step (2), MobileNetV3 is divided into two different network structures, namely the network structures of MobileNetV3-large and MobileNetV3-small; Indicates the number of channels that the 1×1 convolution increases. represents the number of output feature maps, Indicates whether the SE attention mechanism is added here. It represents stride, that is, the step size. It indicates the type of activation function added; The representative activation function is h-swish, and the calculation formula is shown in Formula 2-1: (2-1) Represents the Relu activation function, and its calculation formula is shown in Formula 2-2: (2-2)。 3. The lightweight wheat ear extraction algorithm based on the YOLOv5s+4+ECAC3 model according to claim 1, characterized in that: The step (2) can also use the ShuffleNetV2 network to improve the YOLOv5s+4+ECAC3 network by replacing the backbone part of the network with ShuffleNetV2.

4. The lightweight wheat ear extraction algorithm based on the YOLOv5s+4+ECAC3 model according to claim 1, characterized in that: In step (3), the parameters of the RRelu activation function are updated. and parameters There are two main parts in the training process: forward propagation and back propagation. In the former, all parameters are involved in the calculation, but there is no update. In the latter, there is an update. Before updating the parameters, the cross entropy loss function is determined first, and then a series of calculations are performed in the forward propagation process, as shown in Formula 3-1: (3-1) in, For the The output calculated by the forward propagation of the layer. Then the gradient descent iteration method is used to find the parameters of each layer and ; About activation functions The gradient of ,parameter and The gradient is shown in formula 3-2: (3-2) From this we can get the Layer Parameters and The gradient is shown in Formula 3-3 and Formula 3-4: (3-3) (3-4) in, It is the gradient coming from the deeper network; Finally, introduce Momentum is used to update the parameters, as shown in Formula 3-5: (3-5)。

Citation Information

Patent Citations

  • Infrared target detection method based on improved YOLOv3

    CN112949633A

  • Wheat rust identification method based on transfer learning and sharpness perception minimization

    CN114842291A

  • Wheat ear detection method based on improved YOLOv5

    CN114973002A

  • Recyclable garbage recognition and classification system based on deep learning

    CN115457322A

  • Method for rapidly detecting wheat scab spike and severity in natural environment

    CN116958784A

Cited By

  • Wheat ear automatic detection and counting method based on improved RT-DETR

    CN120580580A