AM-YOLOX-Based Strawberry Pest and Disease Detection Method and System
By improving the YOLOX-s model, combining multiple attention mechanisms and data enhancement algorithms, the problem of inaccurate classification and positioning in strawberry pest detection is solved, and the accuracy and robustness of the detection are improved.
Patent Information
- Application Number
- CN202211397092.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-09
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2042-11-09
AI Technical Summary
The prior art has problems of inaccurate classification results and inaccurate positioning in strawberry pest detection, especially in complex natural contexts.
The improved YOLOX-s model is adopted, combining multiple attention mechanisms and CIoU target regression loss functions to perform image feature learning and fusion, and data augmentation is performed using the Mosaic algorithm and the Mixup algorithm during the training stage.
It improves the accuracy and positioning accuracy of strawberry pest detection, significantly improves the model's learning ability and target detection accuracy, enhances the robustness to complex environments, and achieves higher F1 scores and average accuracy.
Smart Images

Figure CN115631462B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of strawberry pest and disease detection, and particularly relates to a strawberry pest and disease detection method and system based on AM-YOLOX. Background Art
[0002] Strawberries are perennial herbaceous plants belonging to the Rosaceae family and the genus Fragaria, native to South America. They are not only delicious, juicy, and nutritious but also have high economic value. Their pulp is sweet and juicy, with a unique flavor, and is rich in nutrients such as vitamins, minerals, tea polyphenols, and anthocyanins. Also, due to their short growth cycle and easy management, they have become one of the important cash crops widely cultivated in China.
[0003] Strawberries are crops extremely vulnerable to pests and diseases. The strawberry plants are short, and their stems, leaves, and fruits are close to the ground, making them susceptible to various pests and diseases. Common pests and diseases include strawberry angular leaf spot, strawberry anthracnose, blossom blight, leaf spot, powdery mildew, gray mold, etc. All kinds of pests and diseases will affect the growth of strawberries. For example, gray mold is one of the most devastating diseases worldwide and is common in both greenhouse and open-field cultivation; gray mold also causes post-harvest decay of strawberry fruits, resulting in significant economic losses. There are many types of strawberry pests and diseases, causing great economic losses. Therefore, accurately identifying and preventing possible pests and diseases during the growth of strawberries is of great significance to strawberry production.
[0004] Currently, image recognition and machine learning methods are widely used in the field of pest and disease identification, which can, to a certain extent, replace traditional visual identification and improve the efficiency of pest and disease detection. With the rapid development of deep learning, it has become a new technical means in the field of image recognition, with advantages such as fast recognition speed and high accuracy. The plant disease target detection algorithms based on deep learning mainly focus on single-stage algorithms centered on the YOLO (You only look once) series and two-stage algorithms centered on RCNN (Region-CNN).
[0005] In the prior art, for example, the Chinese patent application document with the application number 201911153437.8 discloses a rapid classification method for strawberry pests and diseases. Its technical solution is to continuously obtain strawberry pest and disease image data from multiple platforms to form a strawberry pest and disease database; uniformly calibrate the strawberry pest and disease image data; select a sample set from the calibrated strawberry pest and disease database; establish a deep convolutional neural network model, where the input of the model is the original image of strawberry pests and diseases, and the output is the classification vector of strawberry pests and diseases; put the sample set into the deep convolutional neural network model for training, and use S-fold cross-validation to select the model; input the strawberry pest and disease image to be classified into the selected model for calculation to obtain the classification result of the strawberry pest and disease to be classified.
[0006] However, the disclosed technical solution only classifies the original images of strawberry pests and diseases using a deep convolutional neural network, and then outputs the results of different types of strawberry pests and diseases. However, in the actual operation process, when the occurrence area of strawberry pests and diseases is small or relatively scattered, the performance of classification by only the deep convolutional neural network is poor, the classification results are inaccurate, or the positioning of strawberry pests and diseases is inaccurate. At the same time, the natural background of strawberry pests and diseases is relatively complex, and using only the deep convolutional neural network of the existing technology for classification will result in poor robustness. Therefore, there is an urgent need for a strawberry pest and disease positioning and recognition method with high detection accuracy and high performance in data learning and fusing image features. Summary of the Invention
[0007] In view of the above defects, the present invention provides a strawberry pest and disease detection method and system based on improved AM-YOLOX. Aiming at the problems of many types of pests and diseases during the growth of strawberries and the difficulty of accurate identification under natural backgrounds, the YOLOX-s model is used as the basic network. At different positions of the network, according to the functions of different attention mechanisms, multiple different attention mechanisms are fused, so that the network model can learn and fuse the features of images more efficiently; secondly, the CIoU target regression loss function is introduced to improve the positioning accuracy of the network for strawberry pests and diseases, thereby significantly improving the learning ability of the entire model for image features and the target detection accuracy; finally, in the training stage, the Mosaic algorithm and the Mixup algorithm are used for data augmentation, so that the network has better robustness in the face of complex environments.
[0008] The present invention provides the following technical solutions: A strawberry pest and disease detection method based on AM-YOLOX, the method includes collecting images of strawberry planting areas; the method further includes the following steps:
[0009] S1. Extract image features from the collected images of strawberry planting areas;
[0010] S2. Perform multi-scale feature fusion on the image after image feature extraction using the PAFPN structure layer;
[0011] S3. Identify and locate the image after multi-scale feature fusion;
[0012] S4. Use the Mosaic algorithm and the Mixup algorithm to perform data augmentation on the strawberry pest and disease images obtained by identification and location in step S3;
[0013] S5. Construct a loss function, calculate the recognition and location loss value, and judge whether the strawberry planting area image obtained by recognition and location after data augmentation in step S4 is used to evaluate the accuracy of strawberry pest and disease occurrence; if the calculated recognition and location loss value is less than the loss threshold of 0.86, perform step S6, otherwise repeat steps S1-S4;
[0014] S6. Calculate the evaluation indicators for evaluating strawberry pest and disease detection: recall rate, accuracy rate, mean average precision, mean average precision, and F1 score. Finally, output strawberry pest and disease images that meet the thresholds of each evaluation indicator as strawberry pest and disease detection result images.
[0015] Further, in step S1, the CSPDarknet network is adopted, including a Focus structure layer, a CBS structure layer, a CSP structure layer, and an SPP structure layer;
[0016] The Focus structure layer is used to obtain a value for every other pixel in the collected strawberry planting area image, obtain four independent feature layers, and then stack the four independent feature layers;
[0017] The CBS structure layer is used for; the CBS structure layer consists of three parts: Conv + BN + SiLU;
[0018] The CSP structure layer is used to increase the network depth and enhance the feature extraction ability;
[0019] The SPP structure layer is used to pool the image data processed by the CSP structure layer, fuse features of different scales together, and achieve multi-scale input of data.
[0020] Further, the CSP structure layer includes a convolutional layer and X residual components spliced together.
[0021] Further, a coordinate attention mechanism improvement module is set between the Focus structure layer and the CBS structure layer to improve the data processed by the Focus structure layer through the coordinate attention mechanism. The improvement of the coordinate attention mechanism module on the Focus structure layer includes the following steps:
[0022] M1. The data processed by the Focus structure layer is input into the X_Avg average pooling layer and the Y_Avg average pooling layer through the coordinate attention mechanism improvement module for processing to obtain a feature map of C*1*W;
[0023] M2. Then enter the concat + Conv2d structure layer to obtain a feature map of (C / r)*1*(H+W), where r is the scaling rate;
[0024] M3. Then enter the BatchNorm + Non-linear layer for non-linear processing,
[0025] M4. The feature maps of (C / r)*1*(H+W) obtained from the processing in step M3 respectively enter two Conv2D layers, where r is the scaling ratio, to obtain feature maps of C*1*W;
[0026] M5. Then, the two Conv2D layers respectively enter two Sigmoid layers for activation to obtain feature maps of C*1*W;
[0027] M6. Finally, they are aggregated, reweighted, and the results are output.
[0028] Further, a channel attention mechanism improvement module is set after the SPP structure layer to improve the SPP structure layer with the channel attention mechanism. The channel attention mechanism improvement includes the following steps:
[0029] B1. The data processed by the SPP structure layer is input into the global average pooling layer through the channel attention mechanism improvement module, and the feature maps with an output channel of C, a height of H, and a width of W are processed to obtain feature maps of C*1*1;
[0030] B2. Then, it enters the first fully connected layer to obtain feature maps of (C / r)*1*(H+W), where r is the scaling ratio;
[0031] B3. Then, it enters the non-linear processing layer to obtain feature maps of (C / r)*1*(H+W), where r is the scaling ratio;
[0032] B4. Then, it enters the second fully connected layer to obtain feature maps of C*1*1;
[0033] B5. Finally, it enters the Sigmoid layer for activation;
[0034] B6. They are aggregated, reweighted, and the results are output.
[0035] Further, in step S2, the multi-scale feature fusion of the image after image feature extraction is performed using the PAFPN structure. First, it is fused through upsampling, and then the predicted feature maps are obtained through downsampling fusion. Finally, a tuple result composed of 3 feature layers is output.
[0036] Further, a convolutional block attention mechanism improvement module is used to improve the PAFPN structure layer. The convolutional block attention mechanism improvement module includes a channel attention module and a spatial attention module. The improvement of the PAFPN structure by the convolutional block attention mechanism improvement module includes the following steps:
[0037] C1. After processing the data in the S1 step, input the intermediate feature map F with an output channel of C, a height of H, and a width of W into the channel attention module through the convolutional block attention mechanism improvement module, and perform global max pooling and average pooling simultaneously;
[0038] C2. Send the two one-dimensional vectors after pooling into a shared fully connected layer for calculation and then add them to generate M C (C*1*1) one-dimensional channel attention feature map;
[0039] C3. Multiply the one-dimensional channel attention feature map obtained in the C2 step by the intermediate feature map F input in the C1 step to obtain the feature map F' after channel attention adjustment, and the channel attention module is completed;
[0040] C4. Input the feature map F' obtained in the C3 step into the spatial attention module, and perform global max pooling and average pooling once in the spatial dimension;
[0041] C5. Concatenate the two two-dimensional vectors generated by pooling in the C4 step and perform a convolution operation, finally generating a two-dimensional spatial attention feature map, and then perform a Sigmoid operation to generate the spatial attention Ms feature map;
[0042] C6. Multiply the spatial attention Ms feature map generated in the C5 step by the feature map F' input into the spatial attention module in the C4 step to obtain the output feature map after the convolutional block attention mechanism improvement module is completed.
[0043] Further, the loss function for constructing the recognition and localization loss value Loss in the S4 step is as follows:
[0044] Loss = Loss Reg +Loss Obj +Loss Cls ;
[0045] Among them, Loss Reg is the overlap degree loss value between the predicted box and the ground truth box of the pest and disease image of the monitored strawberry planting area image, Loss Obj is the cross-entropy loss value calculated according to the prediction results of positive and negative samples and whether the feature points contain pests and diseases in the monitored strawberry planting area image, Loss Cls is the cross-entropy loss value calculated according to the prediction results of the types of the ground truth box and the types of the feature points of the pest and disease image of the monitored strawberry planting area image;
[0046] Among them, IOU is the intersection over union of the predicted box and the ground truth box; b is the center point of the predicted box, b gtis the center point of the ground truth box, ρ is the Euclidean distance between the center point of the predicted box and the center point of the ground truth box, c is the diagonal distance of the smallest rectangular enclosing area that can contain both the predicted box and the ground truth box; α is the coordination ratio parameter, v is the parameter for measuring the consistency of the aspect ratio between the predicted box and the ground truth box, and αv is the aspect ratio influence factor;
[0047] A represents the predicted box, B represents the ground truth box, A∩B represents the value of the intersection area of A and B, and |A∪B| represents the value of the union area of A and B;
[0048]
[0049]
[0050] Among them, w gt and h gt are the width and height of the target box respectively, and w and h are the width and height of the predicted box respectively.
[0051] Furthermore, the Mosaic algorithm adopted in the S5 step is to randomly crop four relevant strawberry pest and disease images identified and located in the S4 step, and then splice them onto one image as training data;
[0052] The Mixup algorithm data adopted in the S5 step is used to perform data augmentation on the strawberry pest and disease images identified and located in the S4 step, including the following steps:
[0053] D1. Extract the first batch sample batch x1 and the second batch sample batch x2 from the strawberry pest and disease images identified and located in the SS4 step;
[0054] D2. Label the first batch sample batch x1 extracted in the D1 step with the corresponding first label batch y1 and the second batch sample batch x2 with the corresponding second label batch y2 , and calculate the beta distribution mixing coefficient λ determined by the first beta parameter β and the second beta parameter γ:
[0055] λ = Bata(β, γ);
[0056] Among them, Bata(·) is for calculating the beta distribution;
[0057] D3. Calculate from the first batch sample batch x1 and the second batch sample batchx2 The mixed sample after mixing and by the first label batch y1 and the second label batch y2 The mixed label after mixing
[0058]
[0059] The evaluation indexes for evaluating the recall rate, accuracy rate, and average accuracy rate of strawberry pest and disease detection in the S6 step, and the calculation formulas for the mean average precision and F1 score are as follows:
[0060]
[0061]
[0062]
[0063]
[0064]
[0065] Among them, Recall is the recall rate, Precision is the accuracy rate, AP is the average accuracy rate, mAP is the mean average precision, and F1 is the F1 score; TP is the number of correctly detected samples, FP is the number of misdetected samples, FN is the number of undetected samples, AP(i) represents the AP value of the i-th type of strawberry pest and disease, and NC is the number of strawberry pest and disease categories;
[0066] The thresholds of each evaluation index in the S6 step are as follows: the recall rate threshold is 80%, the accuracy rate threshold is 96.5%, the average accuracy rate threshold is 90%, the mean average precision threshold is 97%, and the F1 score threshold is 88.
[0067] The present invention also provides a strawberry pest and disease detection system based on AM-YOLOX, including a camera for collecting images of the strawberry planting area. The system further includes a backbone feature extraction network module, a Neck module, a Head module, a positioning effect evaluation module, an image data enhancement module, and a pest and disease detection evaluation and output module;
[0068] The backbone feature extraction network module is used to extract image features from the images of the strawberry planting area collected by the camera;
[0069] The Neck module is used to perform multi-scale feature fusion on the images after image feature extraction;
[0070] The Head module is used to identify and locate the image after multi-scale feature fusion;
[0071] The image data augmentation module is used to perform data augmentation on the strawberry pest and disease image obtained by the identification and location by using the Mosaic algorithm and the Mixup algorithm;
[0072] The location effect evaluation module is used to construct a loss function to judge the accuracy of strawberry pests and diseases occurring in the strawberry planting area obtained by the identification and location after data augmentation;
[0073] The pest and disease detection evaluation and output module is used to calculate the evaluation indicators for evaluating strawberry pest and disease detection: recall rate, accuracy rate, mean average precision, mean average precision, and F1 score, and finally output the strawberry pest and disease image that meets the threshold of each evaluation indicator as the strawberry pest and disease detection result image.
[0074] The beneficial effects of the present invention are as follows:
[0075] 1. The strawberry pest and disease detection method and system based on AM-YOLOX provided by the present invention uses the YOLOX-s model as the basic network. At different positions of the network, according to the functions of different attention mechanisms, a variety of different attention mechanisms are fused, so that the network model can learn and fuse the features of the image more efficiently.
[0076] 2. The strawberry pest and disease detection method and system based on AM-YOLOX provided by the present invention introduces a loss function model based on the bounding box regression loss in step S4, improves the location accuracy of the network for strawberry pests and diseases, and thus significantly improves the learning ability of the entire model for image features and the target detection accuracy.
[0077] 3. The strawberry pest and disease detection method and system based on AM-YOLOX provided by the present invention uses the Mosaic algorithm and the Mixup algorithm for data augmentation during the training stage, so that the network has better robustness in the face of complex environments.
[0078] 4. Experimental results show that the strawberry pest and disease detection method and system based on AM-YOLOX provided by the present invention has better comprehensive performance in the detection of seven strawberry pests and diseases. The F1 score is 88.1, and the mean average precision is 97.17%. Compared with the basic network YOLOX-s, it has increased by 2.54 percentage points. It shows great advantages compared with the mainstream deep learning algorithms SSD, Faster-RCNN, YOLOv3, and YOLOv5-s.
[0079] 5. The strawberry pest and disease detection method and system based on AM-YOLOX provided by the present invention can effectively avoid misdetection and missed detection of pests and diseases by the constructed AM-YOLOX model, which proves the effectiveness of the new algorithm. BRIEF DESCRIPTION OF THE DRAWINGS
[0080] The present invention will be described in more detail below based on embodiments and with reference to the drawings. Among them:
[0081] Figure 1 It is a schematic flow diagram of the strawberry pest and disease detection method based on AM-YOLOX provided by the present invention;
[0082] Figure 2 It is a schematic diagram of the CSPDarknet network structure adopted by the method provided by the present invention;
[0083] Figure 3 It is a schematic diagram of the Focus structure layer in the CSPDarknet network adopted by the method provided by the present invention;
[0084] Figure 4 It is a schematic diagram of the SPP structure layer in the CSPDarknet network adopted by the method provided by the present invention;
[0085] Figure 5 It is a schematic diagram of the addition position of the coordinate attention mechanism improvement module in the CSPDarknet network in the method provided by the present invention;
[0086] Figure 6 It is a schematic diagram of the structure of the coordinate attention mechanism improvement module in the method provided by the present invention;
[0087] Figure 7 It is a schematic diagram of the addition position of the channel attention mechanism improvement module in the CSPDarknet network in the method provided by the present invention;
[0088] Figure 8 It is a schematic diagram of the structure of the channel attention mechanism improvement module in the method provided by the present invention;
[0089] Figure 9 It is a schematic diagram of the overall structure of the convolutional block attention mechanism improvement module in the method provided by the present invention;
[0090] Figure 10 It is a schematic diagram of the improvement process of the channel attention module in the convolutional block attention mechanism improvement module of the present invention;
[0091] Figure 11 It is a schematic diagram of the improvement process of the spatial attention module in the convolutional block attention mechanism improvement module of the present invention;
[0092] Figure 12Schematic diagram of the improvement process of the convolutional block attention mechanism improvement module provided by the present invention;
[0093] Figure 13 Schematic diagram of calculating the Euclidean distance between the center point of the predicted box and the center point of the ground truth box by the loss function constructed by the present invention;
[0094] Figure 14 Schematic diagram of classifying the original strawberry pest and disease image dataset processed in step S1 of the method provided by the present invention.
[0095] Figure 15 Effect diagram of the image with strawberry pests and diseases obtained by identifying and positioning using the Mosaic algorithm in the present invention;
[0096] Figure 16 Effect diagram of the image with strawberry pests and diseases obtained by identifying and positioning using the Mixup algorithm in the present invention;
[0097] Figure 17 Line graph of the loss function constructed by the present invention during the data training stage;
[0098] Figure 18 Comparison diagram of the strawberry pest and disease detection methods with and without the improved AM-YOLOX provided by the present invention in the ablation experiment comparison of the present invention;
[0099] Figure 19 Partial structural schematic diagram of the strawberry pest and disease detection system based on AM-YOLOX provided by the present invention. Detailed implementation manners
[0100] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
[0101] The present invention provides a strawberry pest and disease detection method based on AM-YOLOX. The method includes collecting images of strawberry planting areas; using the YOLOX-s model to learn and train the collected images of strawberry planting areas, and then identifying the areas where strawberry pests and diseases occur in the strawberry planting areas. The YOLO series of networks is one of the most common object detection models in single-stage algorithms. YOLOX-s is an excellent representative of it, with characteristics such as high detection accuracy and fast inference speed. The background of strawberry pest and disease images taken in the natural environment is complex, there are many types of pests and diseases, and the differences between them are small, which is likely to cause misdetection and missed detection of pest and disease targets. To improve the recognition accuracy of strawberry pests and diseases, the strawberry pest and disease detection method based on AM-YOLOX proposed by the present invention uses the YOLOX-s algorithm as the basic network model for relevant research and improvement.
[0102] As Figure 1 shown, the strawberry pest and disease detection method based on AM-YOLOX further includes the following steps:
[0103] S1. Extract image features from the collected images of strawberry planting areas;
[0104] S2. Use the PAFPN structure layer to perform multi-scale feature fusion on the image after image feature extraction;
[0105] S3. Identify and locate the images after multi-scale feature fusion;
[0106] S4. Use the Mosaic algorithm and the Mixup algorithm to perform data augmentation on the strawberry pest and disease images obtained by identification and location in step S3;
[0107] S5. Construct a loss function, calculate the recognition and location loss value, and judge whether the strawberry planting area image obtained by identification and location after data augmentation in step S4 is used to evaluate the accuracy of strawberry pest and disease occurrence; if the calculated recognition and location loss value is less than the loss threshold of 0.86, perform step S6, otherwise repeat steps S1-S4;
[0108] S6. Calculate the evaluation indicators for evaluating strawberry pest and disease detection: recall rate (Recall), precision rate (Precision), average precision (AP), mean average precision (mAP), and F1 score, and finally output strawberry pest and disease images that meet the thresholds of each evaluation indicator as strawberry pest and disease detection result images.
[0109] In the S3 step provided by the present invention, for the image after multi-scale feature fusion, image recognition and localization are realized separately by classification and regression, and then integrated during the final prediction. This structure can not only improve the detection performance but also enhance the convergence speed. In addition, methods such as anchor free, Multi positives, and SimOTA are also adopted, all of which improve the speed, performance, and recognition accuracy of the model.
[0110] The natural background of strawberry pests and diseases is relatively complex. Therefore, during the training stage, the method provided by the present invention uses the Mosaic algorithm and the Mixup algorithm for data augmentation after the S4 step, enriching the background of the detected objects and enabling the network to have better robustness in the face of complex environments.
[0111] As a preferred embodiment of the present invention, as Figure 2 shown, in the S1 step, the CSPDarknet network is adopted, including a Focus structure layer, a CBS structure layer, a CSP structure layer (i.e., the Csplayer layer in Figure 3 ), and an SPP structure layer as shown; Figure 2 The Focus structure layer is used to take a value every other pixel in the image of the strawberry planting area collected, obtain four independent feature layers, and then stack the four independent feature layers. Thus, the width W and height H information in the image of the strawberry planting area collected is concentrated into the channel information, and the input channels are expanded to four times the original.
[0112] The CBS structure layer is used for; the CBS structure layer is composed of Conv + BN + SiLU;
[0113] Conv + BN + SiLU is a common model structure. Conv represents depth convolution operation, BN (BatchNormalization) represents batch normalization operation, and SiLU is an activation function. Normalization is performed during each convolution, and then activation is performed, which is beneficial to image feature extraction.
[0114] The CSP structure layer is used to increase the network depth and enhance the feature extraction ability;
[0115] The CSP structure layer is used to increase the network depth and enhance the feature extraction ability;
[0116] YOLOX-S designs two CSP networks, namely the CSP1_X structure and the CSP2_X structure. The CSP1_X structure is applied in the backbone network and consists of two branches. One branch is stacked via X Bottleneck modules, and the other branch only undergoes convolutional layer processing. The two branches are then connected and passed through a convolutional layer to increase the network depth and enhance the feature extraction ability.
[0117] The SPP structure layer is used to pool the image data processed by the CSP structure layer, fuse features of different scales together, and achieve multi-scale input of data.
[0118] As Figure 4 shown, it is a schematic diagram of the SPP structure layer provided by the present invention.
[0119] As another preferred embodiment of the present invention, the CSP structure layer is composed of a convolutional layer and X residual components spliced together.
[0120] In order to enable the network model to learn and fuse image features more efficiently. By introducing a multi-attention mechanism to improve the performance of the network. Combining the different characteristics of different attention mechanism modules, different parts of the network are improved to maximize the model performance. Therefore, as another preferred embodiment of the present invention, as Figure 5 shown, a coordinate attention mechanism improvement module (i.e., CA attention mechanism improvement module) is set after the Focus structure layer and before the CBS structure layer to improve the data processed by the Focus structure layer through the coordinate attention mechanism. As Figure 6 shown, the improvement of the Focus structure layer by the coordinate attention mechanism improvement module includes the following steps:
[0121] M1. The data processed by the Focus structure layer is input into the X_Avg average pooling layer and the Y_Avg average pooling layer respectively through the coordinate attention mechanism improvement module for processing to obtain a feature map of C*1*W;
[0122] M2. Then enter the concat+Conv2d structure layer to obtain a feature map of (C / r)*1*(H+W), where r is the scaling ratio;
[0123] M3. Then enter the BatchNorm+Non-linear layer for non-linear processing.
[0124] M4. The feature map of (C / r)*1*(H+W) obtained by the processing in step M3 enters two Conv2D layers respectively, where r is the scaling ratio, to obtain a feature map of C*1*W;
[0125] M5. Then the two Conv2D layers enter two Sigmoid layers respectively for activation to obtain a feature map of C*1*W;
[0126] M6. Finally, summarize and reassign weights and output the result.
[0127] As another preferred embodiment of the present invention, as Figure 7As shown, a channel attention mechanism improvement module (i.e., SE attention mechanism improvement module) is set after the SPP structure layer to improve the channel attention mechanism of the SPP structure layer. For example, Figure 8 As shown, the improvement of the channel attention mechanism includes the following steps:
[0128] B1. The data processed by the SPP structure layer is input into the global average pooling layer (i.e., Global Avg Pool layer) through the channel attention mechanism improvement module for processing, and a feature map with an output channel of C, a height of H, and a width of W is obtained to get a C*1*1 feature map;
[0129] B2. Then it enters the first fully connected layer (i.e., Fully Connected layer) to obtain a (C / r)*1*(H+W) feature map, where r is the scaling rate;
[0130] B3. Then it enters the non-linear processing layer (i.e., Non-linear layer) to obtain a (C / r)*1*(H+W) feature map, where r is the scaling rate;
[0131] B4. Then it enters the second fully connected layer (i.e., the Fully Connected layer after the Non-linear layer) to obtain a C*1*1 feature map;
[0132] B5. Finally, it enters the Sigmoid layer for activation;
[0133] B6. Aggregate and reassign weights and output the result.
[0134] The channel attention mechanism improvement module includes 1 global average pooling layer, 2 fully connected layers, and 1 activation function. The principle is to input a feature map of C*H*W (channel, height, width). First, it passes through the global average pooling layer once to obtain a C*1*1 feature map, and then it undergoes non-linear processing using 2 fully connected layers and 1 activation function to obtain a C*1*1 feature map. Finally, the original C*H*W feature map and the C*1*1 feature map are multiplied element-wise to obtain a feature map with different channel importances.
[0135] The SE attention mechanism can compress global information into channel weights, which can well determine the importance between different channels. SPP extracts features through max pooling with different pooling kernel sizes to increase the receptive field of the network. Combining the characteristics of the SE attention mechanism and the role of the SPP module, it is decided to add the SE attention mechanism after the SPP module. For example, Figure 7As shown, the spliced channels will reassign channel weights, determine channel importance, increase the weights of more feature channels beneficial to the recognition task, and suppress the weights of other feature channels, making the network model pay more attention to the feature information of the target and improving the recognition performance of the network model.
[0136] As another preferred embodiment of the present invention, in step S2, multi-scale feature fusion of the image after image feature extraction is performed using the PAFPN structure. First, it is fused by upsampling, and then the predicted feature map is obtained by downsampling fusion, and finally a tuple result composed of 3 feature layers is output.
[0137] As another preferred embodiment of the present invention, the convolutional block attention mechanism improvement module (i.e., the CBAM attention mechanism improvement module) is used to improve the PAFPN structure layer, as Figure 9 shown, which is the overall structure schematic diagram of the convolutional block attention mechanism improvement module. The convolutional block attention mechanism improvement module includes a channel attention module and a spatial attention module, as Figure 10 shown, which is the improvement process schematic diagram of the channel attention module, as Figure 11 shown, which is the improvement process schematic diagram of the spatial attention module. The improvement of the PAFPN structure by the convolutional block attention mechanism improvement module includes the following steps:
[0138] C1. The data processed in step S1 is input into the channel attention module through the convolutional block attention mechanism improvement module with the intermediate feature map F having an output channel of C, a height of H, and a width of W, and global max pooling and average pooling are performed simultaneously;
[0139] C2. The two one-dimensional vectors after pooling are sent to the shared fully connected layer for calculation and then added to generate M C (C*1*1) one-dimensional channel attention feature map;
[0140] C3. Multiply the one-dimensional channel attention feature map obtained in step C2 by the intermediate feature map F input in step C1 to obtain the feature map F' after channel attention adjustment, and the channel attention module completes the improvement;
[0141] C4. Input the feature map F' obtained in step C3 into the spatial attention module, and perform global max pooling and average pooling in the spatial dimension once;
[0142] C5. Concatenate the two two-dimensional vectors generated by pooling in step C4 and perform a convolution operation, and finally generate a two-dimensional spatial attention feature map, and then perform a Sigmoid operation to generate the spatial attention Ms feature map;
[0143] C6. As Figure 9As shown, the spatial attention Ms feature map generated in step C5 is multiplied by the feature map F' input to the spatial attention module in step C4 to obtain the output feature map completed by the improved convolutional block attention mechanism module.
[0144] As Figure 9 shown, the improved convolutional block attention mechanism module provided by the present invention is different from the traditional single-module attention mechanism. The traditional single-module attention mechanism only uses the channel attention mechanism or only uses the spatial attention mechanism. The improved convolutional block attention mechanism module provided by the present invention includes both a channel attention module and a spatial attention module, and can act in both the channel and spatial dimensions.
[0145] The improved convolutional block attention mechanism module (i.e., the improved CBAM attention mechanism module) completes the fusion of channel information and spatial information along two independent dimensions, can complete adaptive feature optimization. The role of PAFPN can transfer the stronger semantic information of the deep feature layer to the shallow feature layer, and can also transfer the stronger localization information of the shallow feature layer to the deep feature layer, effectively strengthening the feature fusion ability of the network. Combining the characteristics of the CBAM attention mechanism and the role of the PAFPN structure, therefore, the improved CBAM attention mechanism module is added to the PAFPN structure network, as Figure 12 shown, to enhance the weight of the target feature, enable the network to pay more attention to the target to be detected, improve the detection effect, and solve the problem of easy misdetection and missed detection in complex environmental backgrounds.
[0146] Since some pests and diseases are small, it will lead to inaccurate positioning of some pests and diseases, so a loss function is introduced as the bounding box regression loss, which can not only improve the stability of the target box regression, but also make the convergence speed of the loss function faster. As another preferred embodiment of the present invention, the loss function for identifying the positioning loss value Loss constructed in step S4 is as follows:
[0147] Loss = Loss Reg + Loss Obj + Loss Cls ;
[0148] where Loss Reg is the overlap degree loss value between the predicted box and the ground truth box of the pest and disease image in the monitored strawberry planting area image, loss Obj is the cross-entropy loss value calculated according to the prediction results of positive and negative samples and whether the feature points contain pests and diseases in the monitored strawberry planting area image, Loss Cls is the cross-entropy loss value calculated according to the prediction results of the category of the ground truth box and the category of the feature points of the pest and disease image in the monitored strawberry planting area image;
[0149] where IOU is the intersection over union of the predicted bounding box and the ground truth bounding box; b is the center point of the predicted bounding box, and b gt is the center point of the ground truth bounding box, ρ is the Euclidean distance d between the center points of the predicted bounding box and the ground truth bounding box as shown in Figure 4 , c is the diagonal distance of the smallest rectangular closed area that can contain both the predicted bounding box and the ground truth bounding box as shown in Figure 13 ; α is the coordination ratio parameter, v is the parameter measuring the consistency of the aspect ratio between the predicted bounding box and the ground truth bounding box, and αv is the aspect ratio influence factor;
[0150] A represents the predicted bounding box, B represents the ground truth bounding box, A∩B represents the value of the intersection area of A and B, and |A∪B| represents the value of the union area of A and B; when the IOU value is smaller, it means the overlapping degree of the predicted bounding box and the ground truth bounding box is higher. On the contrary, the overlapping degree is lower. However, in the prediction of strawberry diseases and pests, because some diseases and pests are small, it may lead to a state where the predicted bounding box and the ground truth bounding box do not overlap at all, resulting in inaccurate positioning of some diseases and pests. Aiming at the deficiency that IoU cannot optimize the state where the predicted bounding box and the ground truth bounding box do not overlap, and the problem that the IoU value cannot reflect the distance between the predicted bounding box and the ground truth bounding box, therefore, the present invention adopts to be added, thereby improving the calculation of the overlapping loss value of the predicted bounding box and the ground truth bounding box, considering the three elements of target box regression (overlapping area, center point distance, and aspect ratio), which can not only improve the stability of target box regression, but also make the convergence speed of the loss function faster, and is also more reasonable and flexible in optimizing network errors, improving the accuracy.
[0151]
[0152]
[0153] where, w gt and h gt are the width and height of the target box respectively, and w and h are the width and height of the predicted bounding box respectively.
[0154] As shown in Figure 14As shown in the figure, the original strawberry pest and disease image dataset for image feature extraction in step S1 of the strawberry pest and disease detection method based on improved AM-YOLOX provided by the present invention was collected by members of the AI Laboratory of the Department of Computer Science and Engineering of JBNU. This dataset contains 2,500 images of strawberry diseases, including 7 different types of pests and diseases. The pest and disease categories include strawberry angular leaf spot, strawberry anthracnose, blossom blight, leaf spot, strawberry powdery mildew, powdery mildew leaf, and gray mold. The data was collected from greenhouses under natural light conditions in different places to ensure environmental diversity, and these strawberry pests and diseases were verified by experts in the field. The method provided by the present invention selects and screens some images from them, and re-labels a small part. Since the number of various pests and diseases in the dataset is unbalanced, in order to ensure the balance of the number of various pests and diseases, data augmentation is performed through horizontal flipping, equal-proportion scaling, random cropping and padding, random brightness, vertical flipping, etc. The preprocessed dataset has a total of 3,806 images, and the specific classification is shown in Table 1, meeting the requirements of network training. To ensure the independence of the dataset, the dataset is split into a training set, a validation set, and a test set according to a ratio of 8:1:1.
[0155] As another preferred embodiment of the present invention, the Mosaic algorithm in step S5 randomly crops four relevant strawberry pest and disease images identified and located in step S4, and then stitches them together into one image as training data; as Figure 15 shown, the advantage of using the Mosaic algorithm to further perform data augmentation on the strawberry pest and disease images identified and located in step S4 is that it greatly enriches the background of the detected objects. The natural background of strawberry pests and diseases is relatively complex, and this can greatly improve the robustness of the model.
[0156] In step S5, the Mixup algorithm is used to perform data augmentation on the strawberry pest and disease images identified and located in step S4, including the following steps:
[0157] D1. Extract the first batch of samples batch x1 and the second batch of samples batch x2 from the strawberry pest and disease images identified and located in step SS4;
[0158] D2. Mark the first label batch x1 corresponding to the first batch of samples batch y1 extracted in step D1 and the second label batch x2 corresponding to the second batch of samples batch y2 , and calculate the beta distribution mixing coefficient λ determined by the first beta parameter β and the second beta parameter γ:
[0159] λ = Beta(β, γ);
[0160] where Beta(·) is to calculate the beta distribution;
[0161] D3. Calculate the mixed sample x1 formed by the first batch of samples batch x2 and the second batch of samples batch and the mixed label y1 formed by the first label batch y2 and the second label batch
[0162]
[0163]
[0164] Mixup is an algorithm for cross-class enhancement. The effect of data enhancement on the strawberry pest and disease images identified and located in step S4 using the above steps D1 - D3 is as Figure 16 shown, which can mix images between different classes, thereby expanding the training data set.
[0165] In step S6, the evaluation metrics for recall, precision, average precision (AP), mean average precision (mAP), and F1-score used to evaluate strawberry pest and disease detection are as follows:
[0166]
[0167]
[0168]
[0169]
[0170]
[0171] where Recall is the recall rate, Precision is the precision rate, AP is the average precision rate, mAP is the mean average precision rate, F1 is the F1-score; TP is the number of correctly detected samples, FP is the number of misdetected samples, FN is the number of undetected samples, AP(i) represents the AP value of the i-th class of strawberry pests and diseases, and NC is the number of strawberry pest and disease categories;
[0172] The threshold values of each evaluation index in step S6 are as follows: the recall rate threshold is 80%, the accuracy threshold is 96.5%, the average accuracy threshold is 90%, the average precision mean threshold is 97%, and the F1 score threshold is greater than 88.
[0173] When the present invention conducts model training, COCO is used for pre-training the dataset for transfer learning training, so as to solve the problem that the amount of strawberry pest and disease data is insufficient, resulting in poor generalization performance of the trained model. The size of the input image in the model is 640×640, the sgd optimizer is adopted, the learning rate adjustment method is cosine annealing decay, the total number of iterations is 100 generations, the training batch size is 32, the learning rate is 0.001, and the freezing training method is adopted to improve the training efficiency and accelerate convergence. The first 50 rounds are freezing training, and the last 50 rounds are unfreezing training. Among them, the first 50% of the training uses the Mosaic algorithm for data augmentation and the Mixup algorithm for data augmentation, and the last 50% does not use the Mosaic algorithm for data augmentation and the Mixup algorithm for data augmentation. Under such a training strategy, not only can the images synthesized by data augmentation enhance the model's learning ability of local features, thereby improving the generalization ability of the entire model, but also the dataset can focus more on the original images, enabling the model to learn the overall features of the target well.
[0174] The model training carried out by the present invention is under the Linux operating system, and the experimental platform for model training is completed based on the GPU, Pytorch, and CUDA frameworks. Its specific parameter configuration is shown in Table 1.
[0175] Table 1 Experimental training environment configuration
[0176]
[0177]
[0178] The loss curve of the training process is as Figure 17 shown, and the horizontal and vertical coordinates are the epoch and loss values respectively. The loss function of the algorithm drops rapidly in the initial stage; after 35 epochs, the loss function tends to be flat; at the 50th epoch, the loss function drops steeply. On the one hand, because the last 50 rounds are unfreezing training, the backbone of the model is not frozen, and the feature extraction network is also trained; on the other hand, because the introduction of real samples by using the Mosaic algorithm for data augmentation and the Mixup algorithm for data augmentation is turned off, over-data augmentation is prevented, and its network is well trained.
[0179] To better understand the detection effect of various improvements in the method provided by the present invention on strawberry pests and diseases, a series of ablation experiments were conducted. With the same training parameters, YOLOX-s was used as the basic comparison network, and "√" indicates the introduction of this method. The results of the ablation experiments are shown in Table 2. Among them, Experiment A is the basic YOLOX-s network structure, Experiment E is the fusion of three attention mechanisms based on YOLOX-s, and Experiments B, C, and D reduce one attention mechanism respectively compared with Experiment E. The experimental results show that Experiments B, C, and D are all inferior to Experiment E. Therefore, when all attention modules are added, the effect is the best. Compared with the original YOLOX-s algorithm, the mAP increases by 1.97 percentage points, the Precision increases by 2.3 percentage points, and the Recall increases by 0.7 percentage points. This shows that according to the functions of different attention mechanisms, adding multiple different attention mechanisms at different positions in the network can enable the network model to learn the features of the feature map more efficiently. AM-YOLOX uses the CIoU loss function as the bounding box regression loss on the basis of Experiment E. Compared with using the IOU as the bounding box regression loss in Experiment E, the mAP increases by 0.57 percentage points, the Precision increases by 0.7 percentage points, and the Recall increases by 0.8 percentage points. This shows that using the CIoU loss function as the bounding box regression loss can improve the stability of the target box regression.
[0180] Through the ablation experiment, it is again proved that each improvement strategy can improve the performance of the network model. The AM-YOLO network model proposed in the method provided by the present invention has better recognition performance compared with the original YOLOX-s network model. The mAP increases by 2.54 percentage points, the F1 score increases by 2.2, and the Precision increases by 3 percentage points. The specific improvement values of the AP values of various strawberry pests and diseases before and after the improvement are as Figure 18 .
[0181] Table 2 Results of Ablation Experiments
[0182]
[0183]
[0184] The experimental results show that the method provided by the present invention has better comprehensive performance in the detection of seven strawberry pests and diseases. The F1 score increases by 2.2, and the mean average precision is 97.17%. Compared with the basic network YOLOX-s, it increases by 2.54 percentage points. Compared with the mainstream deep learning algorithms SSD, Faster-RCNN, YOLOv3, and YOLOv5-s, it shows great advantages.
[0185] To further prove the effectiveness and superiority of the strawberry pest and disease detection method based on the improved AM-YOLOX provided by the present invention, under the condition that the experimental environment and model parameters remain unchanged, the mainstream methods SSD, Faster-RCNN, YOLOv3, YOLOv5-s in the current object detection field are selected to be compared with the method provided by the present invention, and Precision, Recall, mAP, and F1 are used as evaluation indicators. The results are shown in Table 3.
[0186] Table 3 Comparison test results
[0187]
[0188] It can be seen from the data in Table 3 that the Precision, Recall, mAP, and F1 scores of the method provided by the present invention are the highest among other test algorithms in the table. In terms of detection accuracy, compared with the single-stage algorithms SSD, YOLOV3, and YOLOV5-s, the Precision of AM-YOLOX has increased by 4.8 percentage points, 17 percentage points, and 14.9 percentage points respectively, the mAP has increased by 4.36 percentage points, 16.73 percentage points, and 14.74 percentage points respectively, and the F1 score has increased by 8.1, 18.3, and 11.5 respectively. Moreover, compared with the classic two-stage object detection algorithm Faster R-CNN, the Precision has increased by 5.1 percentage points, the mAP has increased by 4.41 percentage points, and the F1 score has increased by 6.8, showing great advantages in algorithm performance. For strawberry pests and diseases in the natural environment, the image background is complex, the volume of the disease spots is small, and it is easy to miss detections. In terms of recall rate, AM-YOLOX has increased by 10%, 7.8%, 18.7%, and 9.3% compared with SSD, Faster-RCNN, YOLOv3, and YOLOv5-s respectively. Therefore, the comprehensive performance of the network model provided by the present invention is better and more suitable for completing the task of identifying strawberry pests and diseases in the natural environment.
[0189] The present invention also provides a strawberry pest and disease detection system based on AM-YOLOX, including a camera for collecting images of the strawberry planting area. As Figure 19 shown, the system provided by the present invention also includes a backbone feature extraction network module (Backbone module), a Neck module, a Head module, a positioning effect evaluation module, an image data enhancement module, and a pest and disease detection evaluation and output module;
[0190] The backbone feature extraction network module is used to extract image features from the images of the strawberry planting area collected by the camera;
[0191] The Neck module is used to perform multi-scale feature fusion on the images after image feature extraction;
[0192] The Head module is used to identify and locate pictures of the image after multi-scale feature fusion;
[0193] The image data augmentation module is used to augment the data of the strawberry pest and disease image obtained by identification and location using the Mosaic algorithm and the Mixup algorithm;
[0194] The positioning effect evaluation module is used to construct a loss function to judge the accuracy of strawberry pests and diseases occurring in the strawberry planting area obtained by identification and location after data augmentation by the image data augmentation module;
[0195] The pest and disease detection evaluation and output module is used to calculate the evaluation indicators for evaluating strawberry pest and disease detection: recall, precision, average precision (AP), mean of average precision (mAP), and F1 score, and finally output the strawberry pest and disease image that meets the threshold of each evaluation indicator as the strawberry pest and disease detection result image.
[0196] To achieve the precise positioning and identification of strawberry pests and diseases, the present invention uses the YOLOX-s network model as the basic network. First, according to the functions of different attention mechanisms, various different attention mechanisms are added at different positions in the network to enable the network model to more efficiently learn the features of the feature map. Secondly, a loss function model based on the bounding box regression loss is introduced, so that the learning ability of the entire model for image features and the target detection accuracy are significantly improved, and the positioning accuracy of the network for strawberry pests and diseases is improved. In the training stage, the Mosaic algorithm and the Mixup algorithm are used for data augmentation, so that the network has better robustness in the face of complex environments.
[0197] Experimental results show that the improved AM-YOLOX model provided by the present invention has a higher classification confidence, better accuracy and recall rate compared with the original model and other mainstream algorithms. Therefore, the detection accuracy and positioning accuracy of this model are both good, and the probability of false detection and missed detection of strawberry pests and diseases can be reduced. Therefore, it can meet the needs of strawberry pest and disease detection.
[0198] It should be noted that the serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments. And the term "comprising" or "including" or any other variant thereof in this article is intended to cover non-exclusive inclusion, so that a process, apparatus, article or method comprising a series of elements not only includes those elements but also includes other elements not expressly listed, or further includes elements inherent to such process, apparatus, article or method. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, apparatus, article or method comprising the element.
[0199] Through the description of the above embodiments, those skilled in the art can clearly understand that the above embodiment methods can be implemented by means of software plus a necessary general hardware platform. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art can be embodied in the form of a software product. The computer software product is stored in a storage medium as described above (such as ROM / RAM, magnetic disk, optical disk), and includes several instructions for causing a terminal device (which may be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0200] The above are only the preferred embodiments of the present invention, and do not limit the patent scope of the present invention accordingly. Any equivalent structure or equivalent process transformation made by using the content of the specification and drawings of the present invention, or directly or indirectly applied in other related technical fields, shall be equally included in the patent protection scope of the present invention.
Claims
1. A strawberry pest and disease detection method based on AM-YOLOX, the method comprising collecting images of strawberry planting areas; characterized in that, The method further includes the following steps: S1. Extract image features from the collected strawberry planting area images; S2. Use the PAFPN structure layer to perform multi-scale feature fusion on the images after image feature extraction; S3. Identify and locate the images after multi-scale feature fusion; S4. Use the Mosaic algorithm and the Mixup algorithm to perform data augmentation on the strawberry pest and disease images obtained by identification and location in step S3; S5. Construct a loss function, calculate the recognition and location loss value, and judge the accuracy of using the strawberry planting area images obtained by recognition and location after data augmentation in step S4 to evaluate the occurrence of strawberry pests and diseases; if the calculated recognition and location loss value is less than the loss threshold of 0.86, perform step S6, otherwise repeat steps S1-S4; S6. Calculate the evaluation indicators for evaluating strawberry pest and disease detection: recall rate, accuracy rate, mean average precision, mean average precision, and F1 score, and finally output strawberry pest and disease images that all meet the thresholds of each evaluation indicator as strawberry pest and disease detection result images; In step S1, the CSPDarknet network is used, including a Focus structure layer, a CBS structure layer, a CSP structure layer, and an SPP structure layer; The Focus structure layer is used to take one value from every other pixel in the collected strawberry planting area images to obtain four independent feature layers, and then stack the four independent feature layers; The CBS structure layer is used for; the CBS structure layer consists of three parts: Conv+BN+SiLU; The CSP structure layer is used to increase the network depth and enhance the feature extraction ability; The SPP structure layer is used to pool the image data processed by the CSP structure layer to fuse features of different scales together and achieve multi-scale input of data; The CSP structure layer includes a convolutional layer and X residual components spliced together; A coordinate attention mechanism improvement module is set after the Focus structure layer and before the CBS structure layer to improve the data processed by the Focus structure layer through the coordinate attention mechanism. The improvement of the coordinate attention mechanism module on the Focus structure layer includes the following steps: M1. Input the feature maps with an output channel of C, a height of H, and a width of W of the data processed by the Focus structure layer into the X_Avg average pooling layer and the Y_Avg average pooling layer through the coordinate attention mechanism improvement module for processing to obtain a C*1*W feature map; M2. Then enter the concat+Conv2d structure layer to obtain a (C / r)*1*(H+W) feature map, where r is the scaling ratio; M3. Then enter the BatchNorm+Non-linear layer for non-linear processing; M4. The (C / r)*1*(H+W) feature map obtained by the processing in step M3 enters two Conv2D layers respectively, where r is the scaling ratio, to obtain a C*1*W feature map; M5. Then, the two Conv2D layers respectively enter two Sigmoid layers for activation to obtain a feature map of C*1*W. M6. Finally, the results are aggregated, reweighted, and output.
2. The strawberry pest and disease detection method based on AM-YOLOX according to claim 1, wherein, After the SPP structure layer, a channel attention mechanism improvement module is set to improve the SPP structure layer. The channel attention mechanism improvement includes the following steps: B1. The data processed by the SPP structure layer is input into the global average pooling layer through the channel attention mechanism improvement module for processing to obtain a feature map of C*1*1 from a feature map with an output channel of C, a height of H, and a width of W. B2. Then, it enters the first fully connected layer to obtain a feature map of (C / r)*1*(H+W), where r is the scaling factor. B3. Then, it enters the non-linear processing layer to obtain a feature map of (C / r)*1*(H+W), where r is the scaling factor. B4. Then, it enters the second fully connected layer to obtain a feature map of C*1*1. B5. Finally, it enters the Sigmoid layer for activation. B6. The results are aggregated, reweighted, and output.
3. The strawberry pest and disease detection method based on AM-YOLOX according to claim 1, characterized in that In step S2, multi-scale feature fusion of the image after image feature extraction is performed using the PAFPN structure. First, it is fused by upsampling, and then the predicted feature map is obtained by downsampling fusion. Finally, a tuple result composed of 3 feature layers is output.
4. The strawberry pest and disease detection method based on AM-YOLOX according to claim 3, wherein, The convolutional block attention mechanism improvement module is used to improve the PAFPN structure layer. The convolutional block attention mechanism improvement module includes a channel attention module and a spatial attention module. The improvement of the PAFPN structure by the convolutional block attention mechanism improvement module includes the following steps: C1. The data processed in step S1 is input into the channel attention module through the convolutional block attention mechanism improvement module. The intermediate feature map F with an output channel of C, a height of H, and a width of W is input, and at the same time, global max pooling and average pooling are performed. C2. Feed the two one-dimensional vectors after pooling into a shared fully-connected layer for computation and then add them to generate M C (C*1*1) one-dimensional channel attention feature map; C3. Multiply the one-dimensional channel attention feature map obtained in step C2 by the intermediate feature map F input in step C1 to obtain the feature map F' after channel attention adjustment, and the channel attention module completes the improvement. C4. Input the feature map F' obtained in step C3 into the spatial attention module, and perform global max pooling and average pooling in the spatial dimension once. C5. Concatenate the two two-dimensional vectors generated by pooling in step C4 and perform a convolution operation to finally generate a two-dimensional spatial attention feature map. After Sigmoid operation, a spatial attention Ms feature map is generated. C6. Multiply the spatial attention Ms feature map generated in step C5 by the feature map F' input into the spatial attention module in step C4 to obtain the output feature map after the improvement of the convolutional block attention mechanism improvement module.
5. The strawberry pest and disease detection method based on AM-YOLOX according to claim 1, wherein The loss function for identifying and locating the loss value Loss constructed in step S4 is as follows: Loss=Loss Reg +Loss Obj +Loss Cls ; Among them, Loss Reg is the overlap degree loss value between the predicted box and the ground truth box of the pest and disease image in the monitored strawberry planting area image, and Loss Obj is the cross-entropy loss value calculated according to whether the positive and negative samples and the feature points contain the predicted results of pests and diseases in the monitored strawberry planting area image, and Loss Cls is the cross-entropy loss value calculated according to the predicted results of the types of the ground truth boxes and the types of the feature points of the pest and disease images in the monitored strawberry planting area image; where IOU is the intersection over union of the predicted box and the ground truth box; b is the center point of the predicted box, and b gt is the center point of the ground truth box, ρ is the Euclidean distance between the center points of the predicted box and the ground truth box, c is the diagonal distance of the smallest rectangular closed region that can contain both the predicted box and the ground truth box; α is the coordination ratio parameter, v is the parameter for measuring the consistency of the aspect ratios of the predicted box and the ground truth box, and αv is the aspect ratio influence factor; A represents the predicted bounding box, B represents the ground truth bounding box, A ∩ B represents the value of the intersection area between A and B, and |A ∪ B| represents the value of the union area between A and B; where w gt and h gt are the width and height of the target bounding box respectively, and w and h are the width and height of the predicted bounding box respectively.
6. The strawberry pest and disease detection method based on AM-YOLOX according to claim 1, wherein The adoption of the Mosaic algorithm in step S5 is to randomly crop the four relevant strawberry pest and disease images identified and located in step S4, and then splice them onto one image as training data; In step S5, the Mixup algorithm is used to perform data augmentation on the strawberry pest and disease images identified and located in step S4, including the following steps: D1. Extract the first batch sample batch and the second batch sample batch from the strawberry pest and disease images identified and located in the SS4 step x1 and the second batch sample batch x2 ; D2. Label the first batch of samples batch extracted in step D1 x1 with the corresponding first label batch y1 and the second batch of samples batch x2 with the corresponding second label batch y2 , and calculate the beta distribution mixing coefficient λ determined by the first beta parameter β and the second beta parameter γ: λ = Beta(β, γ); where Beta(·) is to calculate the beta distribution; D3. Calculate the mixed sample after mixing the first batch of samples batch x1 and the second batch of samples batch x2 and the mixed label after mixing the first label batch and the second label batch y1 y2 mixed label In step S6, the evaluation indicators for evaluating the recall rate, accuracy rate, and mean average precision of strawberry pest and disease detection, and the calculation formulas for the mean average precision and F1 score are as follows: where Recall is the recall rate, Precision is the accuracy rate, AP is the average accuracy rate, mAP is the mean average precision, and F1 is the F1 score; TP is the number of correctly detected samples, FP is the number of misdetected samples, FN is the number of missed detected samples, AP(i) represents the AP value of the i-th type of strawberry pest and disease, and NC is the number of strawberry pest and disease categories; The thresholds of each evaluation indicator in step S6 are as follows: the recall rate threshold is 80%, the accuracy rate threshold is 96.5%, the average accuracy rate threshold is 90%, the mean average precision threshold is 97%, and the F1 score threshold is 88.
7. The strawberry pest and disease detection system based on AM-YOLOX includes a camera, and the camera is used to collect images of the strawberry planting area, characterized in that, The system further includes a backbone feature extraction network module, a Neck module, a Head module, a positioning effect evaluation module, an image data augmentation module, and a pest and disease detection evaluation and output module; The backbone feature extraction network module is used to extract image features from the strawberry planting area images collected by the camera; The Neck module is used to perform multi-scale feature fusion on the images after image feature extraction; The Head module is used to identify and locate the images after multi-scale feature fusion; The image data augmentation module is used to perform data augmentation on the strawberry pest and disease images obtained by the identification and location using the Mosaic algorithm and the Mixup algorithm; The positioning effect evaluation module is used to construct a loss function to judge the accuracy of strawberry pests and diseases occurring in the strawberry planting area obtained by the identification and location after being augmented by the image data augmentation module; The pest and disease detection evaluation and output module is used to calculate the evaluation indicators for evaluating strawberry pest and disease detection: recall rate, accuracy rate, average accuracy rate, mean average precision, and F1 score, and finally output the strawberry pest and disease images that meet the thresholds of each evaluation indicator as the strawberry pest and disease detection result images.
Citation Information
Patent Citations
A method and device for rapid classification of strawberry diseases and pests
CN111027597B
Foreign matter intelligent detection method and system based on high-resolution X-Ray image
CN115035045A
Crop disease and pest identification method based on improved YOLOX-S network
CN115063602A
Face detection method in classroom environment based on YOLO deep network and detection system thereof
CN115240259A