Rice Pest Detection Method Based on Improved BCNN Network
Through the improved BCNN network, rice pest detection is carried out, combined with the axial attention mechanism and multi-order feature fusion, the problems of slow detection speed and low accuracy in the prior art are solved, and efficient and accurate classification of rice pests are achieved.
Patent Information
- Application Number
- CN202311053083.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-21
- Publication Date
- 2025-08-05
- Estimated Expiration
- 2043-08-21
AI Technical Summary
The existing rice pest classification methods have slow detection speed and low detection accuracy, and it is impossible to achieve real-time monitoring and effective prevention and control of rice pests.
The improved BCNN network is used for feature extraction, combined with the axial attention mechanism and multi-order feature fusion, and the categories of rice pests are identified through image acquisition, preprocessing, labeling data sets, and training classifier models.
It improves the accuracy and recall rate of rice pest classification, reduces the missed and missed detection rates, improves the robustness and generalization capabilities of the model, and realizes efficient monitoring of rice pests.
Smart Images

Figure CN117036819B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of deep learning, computer vision, and crop prevention and control. Background Art
[0002] Rice is a vital food crop, occupying a crucial position among China's food crops. According to a report released by the Food and Agriculture Organization of the United Nations, as of 2021, rice provided food for over 2.5 billion people worldwide. Data from the World Health Organization indicates that over 70% of the world's population obtains approximately 20% of their dietary calories from rice. These figures demonstrate the importance of rice in the global food sector and its contribution to humanity. China leads the world in both rice cultivated area and yield, occupying a key position in the global rice cultivation sector. With the acceleration of social modernization and the continuous increase in population growth, the demand for food continues to rise. Therefore, to meet my country's growing food demand, increasing grain production has become a key task for Chinese agricultural experts. In recent years, the incidence of rice pests and diseases has gradually increased, seriously affecting the healthy growth of rice and reducing grain yields. Therefore, strengthening rice pest control has become a critical agricultural issue that needs to be addressed urgently.
[0003] Pest monitoring is a crucial control measure for rice pests. This helps rice field managers better understand the severity of damage caused by different pests and their control methods, providing more effective measures for rice protection and production. This is not only of great significance to rural economic development but also significantly contributes to food security. To combat pests, rice field managers typically apply pesticides regularly. However, this method only eliminates some pests, can reduce beneficial insect populations, and can also harm rice growth. Therefore, real-time monitoring of rice pests is of vital practical significance. Pest monitoring requires counting the types and numbers of pests in rice fields, keeping abreast of pest conditions, and providing information for predicting pest invasions.
[0004] Traditional rice pest classification methods are primarily based on manual observation and empirical judgment. Pest species are determined by observing features such as their appearance, size, and color. Alternatively, pest atlases can be used to determine pest species by comparing their appearance. This method has low recognition efficiency, is extremely expensive, and fails to meet the real-time requirements for rice pest control. The development of computer vision technology has greatly facilitated our daily lives and is gradually being applied in many fields. In the field of agricultural pest identification, traditional machine vision-based rice pest classification methods require preprocessing of pest images, followed by manual extraction of features such as color, morphology, and texture, before classification using a classifier. This results in slow detection speeds, especially for small pests, where missed and false detections are common, leading to low detection accuracy. Therefore, these issues urgently need to be addressed. Summary of the Invention
[0005] The purpose of the present invention is to solve the problems of slow detection speed and low detection accuracy of existing rice pest classification methods. The present invention provides a rice pest detection method based on an improved BCNN network.
[0006] A rice pest detection method based on an improved BCNN network comprises the following steps:
[0007] S1, image acquisition and preprocessing to obtain data sets;
[0008] S2. Labeled dataset:
[0009] Mark the rice pests on each candidate image in the dataset, mark the category of each rice pest and the coordinate information of the bounding box marked at the location of each rice pest;
[0010] S3. Feature extraction through the improved BCNN network:
[0011] Feature extraction is performed on the marked rice pests in each candidate image to obtain a feature vector. During the feature extraction process, an axial attention mechanism is used to adjust the feature contribution rates of different channels in the row and column directions of the candidate image. Deep and shallow feature extraction and feature fusion are combined to obtain three fused feature maps of different scales. The three fused feature maps of different scales are then fully connected to obtain the feature vector corresponding to the candidate image.
[0012] S4. Train the classifier model:
[0013] The feature vector is used as input data of the classifier model, and the category of the rice pest at each coordinate information on the candidate image corresponding to the input data is used as the true value, and the classifier model is trained to obtain a trained classifier model;
[0014] S5. Perform feature extraction on the current image to be detected through the improved BCNN network to obtain the feature vector to be identified, and use the trained classifier model to identify the feature vector to be identified to identify the category of rice pests.
[0015] Preferably, step S1, image acquisition and preprocessing, to obtain a data set is implemented by:
[0016] S11, collecting images of insects in rice fields to obtain batches of original images;
[0017] S12, preliminarily screening the batch of original images based on the image clarity index to obtain multiple candidate images;
[0018] S13. Use data enhancement technology to expand the candidate images, and each expanded candidate image is used as a sample to form a data set.
[0019] Preferably, S12, performing preliminary screening of batches of original images according to image clarity indicators, is achieved by an OSTU threshold segmentation method.
[0020] Preferably, in step S13, the data enhancement technology includes data rotation, data flipping, image scaling, brightness adjustment and noise addition.
[0021] Preferably, the improved BCNN network includes, from left to right, a convolution module, a first axial attention residual module, a first second-order shallow feature extraction module SFM, a second second-order shallow feature extraction module SFM, a second axial attention residual module, a third axial attention residual module, a second-order deep feature extraction module, a multi-order feature fusion module MFM and a fully connected module;
[0022] The convolution module is used to perform a first convolution operation on the received candidate image to obtain a feature map after the first convolution operation;
[0023] The first axial attention residual module is used to adjust the feature contribution rate of different channels and perform a second convolution operation on the feature map after the first convolution operation to obtain the feature map after the second convolution operation;
[0024] The first and second order shallow feature extraction module SFM is used to perform the first second order shallow feature extraction on the feature map after the second convolution operation to obtain the first and second order shallow feature maps;
[0025] A second second-order shallow feature extraction module SFM is used to perform a second second-order shallow feature extraction on the first second-order shallow feature map to obtain a second second-order shallow feature map;
[0026] The second axial attention residual module is used to adjust the feature contribution rate of different channels and perform a third convolution operation on the second-order shallow feature map to obtain the feature map after the third convolution operation;
[0027] The third-axis attention residual module is used to adjust the feature contribution rate of different channels and perform the fourth convolution operation on the feature map after the third convolution operation to obtain the feature map after the fourth convolution operation;
[0028] A second-order deep feature extraction module is used to extract second-order deep features from the feature map after the fourth convolution operation to obtain a second-order deep feature map;
[0029] After upsampling the second-order shallow feature map and the second-order deep feature map, they are sent to the multi-order feature fusion module MFM;
[0030] The multi-order feature fusion module MFM is used to fuse the upsampled second-order shallow feature map and the second-order deep feature map, as well as the first-order shallow feature map, to generate three fused feature maps of different scales;
[0031] The fully connected module is used to fully connect the fused feature maps of three different scales to obtain the feature vector corresponding to the candidate image.
[0032] Preferably, the second-order shallow feature extraction is implemented using a matrix inner product operation.
[0033] Preferably, the content of feature extraction of the marked rice pests in each candidate image in step S3 includes the outline, shape and color of the rice pests.
[0034] A computer-readable storage device stores a computer program, and when the computer program is executed, the rice pest detection method based on the improved BCNN network is implemented.
[0035] A rice pest detection system based on an improved BCNN network includes a storage device, a processor, and a computer program stored in the storage device and executable on the processor. The processor executes the computer program to implement the rice pest detection method based on the improved BCNN network.
[0036] Advantages of the present invention:
[0037] The rice pest detection method based on the improved BCNN network in the present invention takes rice pest images as the research object, adopts the improved BCNN network to construct the rice pest detection method, and performs feature extraction through the improved BCNN network to ensure that a more accurate feature vector is obtained to provide an accurate data basis for the subsequent recognition process, further improve the accuracy of rice pest classification and counting, enhance the model robustness and generalization ability, and realize rice pest monitoring.
[0038] The pest detection method implemented by the improved BCNN network (i.e., MFA-BCNN) adopted in the present invention has improved detection speed and accuracy compared with the traditional BCNN, and has greatly improved the phenomena of missed detection and false detection, with the accuracy increasing from 83.74% to 96.74% and the recall rate increasing from 82.10% to 95.10%.
[0039] The present invention uses the improved BCNN network as the MFA-BCNN network, combining the feature extraction structure of the second-order shallow feature extraction module SFM and the multi-order feature fusion module MFM. In this structure, the second-order shallow feature extraction is set to be implemented as a matrix inner product operation, further reducing the number of model parameters and improving the speed of calculating the similarity between features. At the same time, the use of the multi-order feature fusion module MFM can solve the problem of reduced detection accuracy caused by the loss of shallow features as the number of network layers deepens, thereby improving the generalization ability of the model.
[0040] The present invention adds an axial attention mechanism to the improved BCNN network. By embedding the axial attention mechanism into the residual network, the network can better adjust the feature contribution rate of different channels within each residual block, make full use of channel features, focus on important information in the image, and improve the model accuracy and generalization ability. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 is a flow chart of the rice pest detection method based on the improved BCNN network of the present invention;
[0042] Figure 2 This is a structural diagram of the improved BCNN network;
[0043] Figure 3 It is a statistical graph of the number of 12 types of rice pests in the original dataset and the data-enhanced dataset provided by the invention;
[0044] Figure 4 It is a PR curve diagram of the rice pest detection method under different network feature extraction methods provided by the present invention. DETAILED DESCRIPTION
[0045] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. 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 making any creative efforts shall fall within the scope of protection of the present invention.
[0046] It should be noted that, in the absence of conflict, the embodiments of the present invention and the features in the embodiments may be combined with each other.
[0047] See also Figure 1 Description of Embodiment 1: The rice pest detection method based on the improved BCNN network described in this embodiment 1 includes the following steps:
[0048] S1. Image acquisition and preprocessing to obtain the data set:
[0049] S11, collecting images of insects in rice fields to obtain batches of original images;
[0050] S12. Preliminary screening of the batch of original images is performed based on the image clarity index to obtain multiple candidate images; specifically, the preliminary screening can be achieved by OSTU threshold segmentation method;
[0051] S13. Expand the candidate images using data augmentation technology, and use each expanded candidate image as a sample to form a data set. Specifically, the data augmentation technology includes data rotation, data flipping, image scaling, brightness adjustment, and noise addition.
[0052] S2. Labeled dataset:
[0053] Mark the rice pests on each candidate image in the dataset, mark the category of each rice pest and the coordinate information of the bounding box marked at the location of each rice pest;
[0054] S3. Feature extraction through the improved BCNN network:
[0055] Feature extraction is performed on the marked rice pests in each candidate image to obtain a feature vector. During the feature extraction process, the axial attention mechanism is used to adjust the feature contribution rates of different channels in the row and column directions of the candidate image, and deep and shallow feature extraction and feature fusion are combined to obtain three fused feature maps of different scales. The three fused feature maps of different scales are then fully connected to obtain the feature vector corresponding to the candidate image.
[0056] The improved BCNN network is used as the MFA-BCNN network. During the feature extraction process, self-attention is performed in the row and column directions respectively to obtain global information. The feature contribution rate of different channels is adjusted through the axial attention mechanism, so that the features of each channel can be better utilized, thereby obtaining a feature map with richer detailed information. The shallow feature deep feature extraction and feature fusion technology are combined to extract more refined and advanced features of the image, better capturing the details and semantic information in the image. Finally, features of different scales are integrated to enhance the expressive power of the feature map.
[0057] The content of feature extraction of the marked rice pests in each candidate image includes the outline, shape and color of the rice pests.
[0058] S4. Train the classifier model:
[0059] The feature vector is used as input data of the classifier model, and the category of the rice pest at each coordinate information on the candidate image corresponding to the input data is used as the true value, and the classifier model is trained to obtain a trained classifier model;
[0060] S5. Perform feature extraction on the current image to be detected through the improved BCNN network to obtain the feature vector to be identified, and use the trained classifier model to identify the feature vector to be identified to identify the category of rice pests.
[0061] For further information, see Figure 2 The improved BCNN network includes, from left to right, the convolution module, the first axial attention residual module, the first second-order shallow feature extraction module SFM, the second second-order shallow feature extraction module SFM, the second axial attention residual module, the third axial attention residual module, the second-order deep feature extraction module, the multi-order feature fusion module MFM and the fully connected module;
[0062] The convolution module is used to perform a first convolution operation on the received candidate image to obtain a feature map after the first convolution operation;
[0063] The first axial attention residual module is used to adjust the feature contribution rate of different channels and perform a second convolution operation on the feature map after the first convolution operation to obtain the feature map after the second convolution operation;
[0064] The first and second order shallow feature extraction module SFM is used to perform the first second order shallow feature extraction on the feature map after the second convolution operation to obtain the first and second order shallow feature maps;
[0065] A second second-order shallow feature extraction module SFM is used to perform a second second-order shallow feature extraction on the first second-order shallow feature map to obtain a second second-order shallow feature map;
[0066] The second axial attention residual module is used to adjust the feature contribution rate of different channels and perform a third convolution operation on the second-order shallow feature map to obtain the feature map after the third convolution operation;
[0067] The third-axis attention residual module is used to adjust the feature contribution rate of different channels and perform the fourth convolution operation on the feature map after the third convolution operation to obtain the feature map after the fourth convolution operation;
[0068] A second-order deep feature extraction module is used to extract second-order deep features from the feature map after the fourth convolution operation to obtain a second-order deep feature map;
[0069] After upsampling the second-order shallow feature map and the second-order deep feature map, they are sent to the multi-order feature fusion module MFM;
[0070] The multi-order feature fusion module MFM is used to fuse the upsampled second-order shallow feature map and the second-order deep feature map, as well as the first-order shallow feature map, to generate three fused feature maps of different scales;
[0071] The fully connected module is used to fully connect the fused feature maps of three different scales to obtain the feature vector corresponding to the candidate image.
[0072] In practical applications, second-order shallow feature extraction is implemented using matrix inner product operations. This requires significantly fewer parameters than vector outer product operations, allowing for faster calculation of feature similarities. Furthermore, matrix inner product operations lack the symmetry of vector outer product operations, allowing them to learn asymmetric relationships between inputs, improving model performance.
[0073] The improved BCNN network of the present invention combines the feature extraction structure of the second-order shallow feature extraction module SFM and the multi-order feature fusion module MFM. In this structure, changing the feature extraction method of SFM to the matrix inner product can greatly reduce the number of model parameters and improve the speed of calculating the similarity between features; at the same time, the use of the multi-order feature fusion module MFM can solve the problem of reduced detection accuracy caused by the loss of shallow features as the number of network layers increases, and improve the generalization ability of the model; the present invention adds an axial attention mechanism to the traditional BCNN model structure. By embedding the axial attention mechanism into the residual network, the network can better adjust the feature contribution rate of different channels within each residual block, make full use of channel features, focus on important information in the image, improve model accuracy and generalization ability, and also reduce the number of network parameters to avoid the problem of overfitting.
[0074] Embodiment 2: A computer-readable storage device storing a computer program, wherein the computer program, when executed, implements the rice pest detection method based on the improved BCNN network.
[0075] Implementation method three: A rice pest detection system based on an improved BCNN network, comprising a storage device, a processor, and a computer program stored in the storage device and executable on the processor. The processor executes the computer program to implement the rice pest detection method based on the improved BCNN network.
[0076] Verification test:
[0077] In the rice pest detection method based on the improved BCNN network, the improved BCNN network requires training before use. During training, the improved BCNN network was trained using Python 3.8 on a server with 32GB of RAM, an 8-core CPU, and 16GB of video memory. The network was trained and tested using the deep learning framework PyTorch, using the Ubuntu system. The Adam optimizer was used to optimize the network, with an initial learning rate of 0.001, a batch size of 16 for batch normalization, and 200 epochs.
[0078] Table 1 Ablation experiment table
[0079]
[0080] A rice pest dataset consisting of 12 pest species was constructed: rice leaf roller, rice stem borer, rice stem borer, and rice planthopper. Image augmentation was performed on the dataset, significantly increasing the number of images in the dataset and significantly improving the number of all 12 pest species. Ablation experiments were conducted on the three networks listed in Table 1: traditional BCNN, MF-BCNN, and MFA-BCNN. The traditional BCNN is a bilinear convolutional neural network model; the MF-BCNN introduces a second-order shallow feature extraction method into the traditional BCNN, replacing it with a matrix inner product, and further adds multi-order feature fusion. The MFA-BCNN introduces a second-order shallow feature extraction method into the traditional BCNN, replacing it with a matrix inner product, and further adds multi-order feature fusion and an axial attention mechanism. The MFA-BCNN is an improved BCNN.
[0081] In Table 1, A represents accuracy, P represents precision, R represents recall, and F1-score represents F1 score. As shown in Table 1, compared to the BCNN model, the MF-BCNN achieves an improvement in accuracy by 9.67% and a 10.85% improvement in recall. These numerical changes indicate that the multi-order feature fusion module effectively addresses the gradient degradation problem associated with an increase in the number of neural network layers, allowing it to capture more feature information of varying sizes from the image, thereby increasing classification accuracy. The MFA-BCNN achieves an improvement in accuracy and recall by approximately 13% compared to the BCNN. This indicates that the addition of the axial attention mechanism effectively integrates features between convolutional layers, focusing more on important information in the image, improving the model's recognition accuracy, image understanding, and generalization capabilities. Based on these indicators, the improved BCNN network (i.e., MFA-BCNN) can more accurately identify multi-scale, small-target rice pests, reducing both false positive and missed detection rates.
[0082] Table 2 Network complexity comparison table
[0083]
[0084] Table 2 analyzes the improved BCNN network (i.e., MFA-BCNN) from the perspective of network complexity. Data in Mark 2 demonstrates that the MFA-BCNN network offers significant advantages in terms of computational complexity and memory usage. Compared to traditional BCNNs, its improved approach filters out unimportant information, preventing the model from processing excessive amounts of useless information, which increases computational complexity and reduces efficiency. Table 2 shows that the MFA-BCNN reduces computational complexity by 31.84% and memory usage by 78.69% compared to the traditional B-VGG16 model. Compared to the traditional B-AlexNet model, the MFA-BCNN model reduces inference time per image by 0.03ms. In terms of the number of training parameters, the improved BCNN network (i.e., MFA-BCNN) employed in the present invention uses fewer parameters than the B-LeNet-5 and B-VGG16 models. These data demonstrate that the improved BCNN network (i.e., MFA-BCNN) is more suitable for rice pest detection. FLOPs represents floating-point operations per second.
[0085] PR curves of rice pest detection methods using MFA-BCNN, B-LeNet-5, B-AlexNet, and B-VGG164 different networks for feature extraction. Figure 4 ,from Figure 4It can be seen that the improved BCNN network (i.e., MFA-BCNN) of the present invention has significantly improved accuracy and recall compared with other networks. The network model has good convergence performance and improved robustness, providing accurate classification results for subsequent classification.
[0086] Although the present invention is described herein with reference to specific embodiments, it should be understood that these embodiments are merely illustrative of the principles and applications of the invention. It should be understood that many modifications may be made to the illustrative embodiments, and that other arrangements may be devised, without departing from the spirit and scope of the invention as defined by the appended claims. It should be understood that the various dependent claims and features described herein may be combined in ways other than those described in the original claims. It should also be understood that features described in conjunction with individual embodiments may be employed in conjunction with other described embodiments.
Claims
1. A rice pest detection method based on an improved BCNN network is characterized by: The method comprises the following steps: S1, image acquisition and preprocessing to obtain data sets; S2. Labeled dataset: Mark the rice pests on each candidate image in the dataset, mark the category of each rice pest and the coordinate information of the bounding box marked at the location of each rice pest; S3, feature extraction through the improved BCNN network; The improved BCNN network includes, from left to right, the convolution module, the first axial attention residual module, the first second-order shallow feature extraction module SFM, the second second-order shallow feature extraction module SFM, the second axial attention residual module, the third axial attention residual module, the second-order deep feature extraction module, the multi-order feature fusion module MFM and the fully connected module; The convolution module is used to perform a first convolution operation on the received candidate image to obtain a feature map after the first convolution operation; The first axial attention residual module is used to adjust the feature contribution rate of different channels and perform a second convolution operation on the feature map after the first convolution operation to obtain the feature map after the second convolution operation; The first and second order shallow feature extraction module SFM is used to perform the first second order shallow feature extraction on the feature map after the second convolution operation to obtain the first and second order shallow feature maps; A second second-order shallow feature extraction module SFM is used to perform a second second-order shallow feature extraction on the first second-order shallow feature map to obtain a second second-order shallow feature map; The second axial attention residual module is used to adjust the feature contribution rate of different channels and perform a third convolution operation on the second-order shallow feature map to obtain the feature map after the third convolution operation; The third-axis attention residual module is used to adjust the feature contribution rate of different channels and perform the fourth convolution operation on the feature map after the third convolution operation to obtain the feature map after the fourth convolution operation; A second-order deep feature extraction module is used to extract second-order deep features from the feature map after the fourth convolution operation to obtain a second-order deep feature map; After upsampling the second-order shallow feature map and the second-order deep feature map, they are sent to the multi-order feature fusion module MFM; The multi-order feature fusion module MFM is used to fuse the upsampled second-order shallow feature map and the second-order deep feature map, as well as the first-order shallow feature map, to generate three fused feature maps of different scales; The fully connected module is used to fully connect the fused feature maps of three different scales to obtain the feature vector corresponding to the candidate image; S4. Train the classifier model: The feature vector is used as input data of the classifier model, and the category of the rice pest at each coordinate information on the candidate image corresponding to the input data is used as the true value, and the classifier model is trained to obtain a trained classifier model; S5. Feature extraction is performed on the current image to be detected through the improved BCNN network to obtain the feature vector to be identified, and the trained classifier model is used to identify the feature vector to be identified to identify the category of rice pests.
2. The rice pest detection method based on the improved BCNN network according to claim 1, characterized in that: Step S1, image acquisition and preprocessing, to obtain a data set includes: S11, collecting images of insects in rice fields to obtain batches of original images; S12, preliminarily screening the batch of original images based on the image clarity index to obtain multiple candidate images; S13. Use data enhancement technology to expand the candidate images, and each expanded candidate image is used as a sample to form a data set.
3. The rice pest detection method based on the improved BCNN network according to claim 1, characterized in that: In step S13, data enhancement techniques include data rotation, data flipping, image scaling, brightness adjustment, and noise addition.
4. The rice pest detection method based on the improved BCNN network according to claim 1, characterized in that: Second-order shallow feature extraction is implemented using matrix inner product operations.
5. The rice pest detection method based on the improved BCNN network according to claim 1, characterized in that: Step S3: extracting features of the marked rice pests in each candidate image, including the outline, shape and color of the rice pests.
6. A computer-readable storage device storing a computer program, characterized in that: When the computer program is executed, the rice pest detection method based on the improved BCNN network as claimed in any one of claims 1 to 5 is implemented.
7. A rice pest detection system based on an improved BCNN network, comprising a storage device, a processor, and a computer program stored in the storage device and executable on the processor, characterized in that: The processor executes the computer program to implement the rice pest detection method based on the improved BCNN network as claimed in any one of claims 1 to 5.
Citation Information
Patent Citations
Rice insect pest recognition method, storage medium and equipment
CN116343026A
Automatic pest counting method based on combination of multi-scale feature fusion network and positioning model
WO2020047738A1