A pest and disease identification method and device based on a ResNet residual network

CN115035511BActive Publication Date: 2026-11-03FOSHAN UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210536421.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-17
Publication Date
2026-11-03
Estimated Expiration
2042-05-17

AI Technical Summary

Technical Problem

Existing deep learning technologies for identifying strawberry diseases and pests suffer from limitations such as a wide range of identification types, insufficient feature points in training images, and a lack of diversity in identification scenarios. This results in poor model generalization ability, a lack of large-scale labeled datasets, low identification accuracy, and the model being easily affected by the background data.

Method used

By adopting the ResNet residual network, modifying the convolutional layers and adding pathways, and embedding the attention mechanism into the ResNeXt-50 network, an SE-ResNeXt-50 network is formed. The attention mechanism is used to adjust the feature weights, enhance the effective feature channels, suppress the influence of noise, and optimize the model training process by combining global average pooling and activation operations.

Benefits of technology

It improved the accuracy of strawberry disease and pest identification, reduced identification time, and enhanced the model's convergence speed and identification effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115035511B_ABST
    Figure CN115035511B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of deep learning, and particularly discloses a disease and pest identification method and device based on a ResNet residual network, which comprises the following steps: step S1, building a disease and pest detection and identification network based on ResNet; step S2, training and optimizing the disease and pest detection and identification network; step S3, collecting images of products to be detected, and pre-processing the images to obtain input images; and step S4, detecting and identifying the input images by using the trained and optimized disease and pest detection and identification network to obtain an identification result; the application has the advantages that the attention mechanism is embedded into the disease and pest detection and identification network, the identification accuracy of the disease and pest detection and identification network is effectively improved, and the judgment time of the fruit farmers on the diseases and pests of agricultural products is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of deep learning technology, and in particular to a method and apparatus for identifying pests and diseases based on ResNet residual networks. Background Technology

[0002] Pest and disease identification is a crucial technology in crop cultivation. With the increasing demand for fruits and vegetables, more fruit growers are choosing to cultivate crops in greenhouses with controlled temperature and humidity to maximize yield and improve quality. However, the suitable temperature and humidity in greenhouses also expose crops to various biotic and abiotic stresses, with pests and diseases being the biggest threat. Strawberries, often called the "Queen of Fruits," are no exception. There are as many as 15 common strawberry diseases, which significantly threaten both yield and quality. A large-scale outbreak can cause severe losses, while even small-scale outbreaks can lead to reduced yield and compromised quality. For inexperienced growers, seeking information on disease types and control measures from online forums or expert platforms is essential. Pest and disease identification technology can quickly analyze images to identify the specific diseases present, minimizing economic losses.

[0003] Existing deep learning technologies for identifying strawberry pests and diseases, or other crops, suffer from limitations such as an overly broad range of identification types, insufficient feature points in training images, and the need for focused, interference-free laboratory settings. These limitations prevent the final model from achieving high accuracy across diverse and complex strawberry pests and diseases in various scenarios, indicating a lack of generalization ability. Furthermore, deep learning requires massive amounts of data, and currently, there is no large-scale, fully labeled dataset of strawberry pests and diseases available online. Therefore, existing technologies suffer from insufficient training data and incomplete results. Many existing deep learning-based methods for plant pest and disease identification rely on deep convolutional neural networks without incorporating attention mechanisms. When faced with highly similar strawberry pest and disease images and significant background interference, the models are prone to fitting errors, and the model's "attention" function is affected. Summary of the Invention

[0004] To address the problems existing in the prior art, the present invention aims to provide a method and apparatus for identifying pests and diseases based on ResNet residual networks. By embedding an attention mechanism into the pest and disease detection and identification network, the method and apparatus can effectively improve the identification accuracy of the pest and disease detection and identification network, and also reduce the time that fruit farmers spend judging the pests and diseases of their agricultural products.

[0005] The above-mentioned technical objective of the present invention is achieved through the following technical solution:

[0006] First, to solve the above problems, this invention provides a pest and disease identification method based on ResNet residual network, the method comprising the following steps:

[0007] Step S1: Build a ResNet-based pest and disease detection and identification network;

[0008] Step S2: Train and optimize the pest and disease detection and identification network;

[0009] Step S3: Acquire an image of the product to be inspected and preprocess the image to obtain the input image;

[0010] Step S4: Use the trained and optimized pest and disease detection and recognition network to detect and recognize the input image to obtain the recognition results;

[0011] Step S1 includes the following steps:

[0012] Step S11: Modify the first two convolutional layers of each block in ResNet to twice the original size, keep the last layer unchanged, and add multiple pathways to obtain the ResNeXt-50 (32x4d) network;

[0013] Step S12: Embed the attention mechanism into each residual module in the ResNeXt-50(32x4d) model to obtain the SE-ResNeXt-50(32x4d) network.

[0014] Compared to existing technologies, this invention embeds an attention mechanism into each residual module of the ResNeXt-50 (32x4d) network. This attention mechanism can learn and adjust the feature weights of each channel through network learning, assisting the model in collecting semantic information that is more helpful to the target domain, enhancing effective feature channels, suppressing the weights of ineffective or less effective elements as well as noise and other interference elements, and reducing their adverse effects on the model's recognition performance, thereby enabling the training model to achieve better results. At the same time, the ResNeXt-50 (32x4d) network itself contains a large number of residual modules, which can effectively solve the problem of reduced training performance as the number of convolutional layers increases, resulting in faster model convergence and higher recognition accuracy.

[0015] As a preferred embodiment of the present invention, step S4, which involves using a trained and optimized pest and disease detection and recognition network to detect and recognize the input image and obtain the recognition result, includes the following steps:

[0016] Step S41: Perform convolution processing on the input image to obtain the first output feature;

[0017] Step S42: Compress the first output feature to obtain the compressed feature;

[0018] Step S43: Perform excitation processing on the compressed features to obtain the weight adjustment parameters between feature channels;

[0019] Step S44: Multiply the weight value by the first output feature to obtain the second output feature;

[0020] Step S45: Identify the second output feature to obtain the identification result.

[0021] As a preferred embodiment of the present invention, step S42, which involves compressing the first output feature to obtain the compressed feature, is as follows: Global average pooling is performed on the first output feature to obtain the compressed feature, as shown in the formula:

[0022]

[0023] Among them, z c F represents the compressed features. sq () represents the compression operation function, u c The first output feature is represented by W and H, which represent the width and height of the first output feature, respectively. i and j represent the coordinate positions on the first output feature, and C represents the number of feature channels of the first output feature.

[0024] As a preferred embodiment of the present invention, step S43, which involves performing excitation processing on the compressed features to obtain the weight adjustment parameters between feature channels, includes the following steps:

[0025] Step S431: Connect the compressed features to the first fully connected layer to reduce the dimensionality of the compressed features and obtain the dimensionality-reduced features;

[0026] Step S432: Input the dimensionality-reduced features into the first activation function to obtain the activated features;

[0027] Step S433: Connect the activated features to the second fully connected layer to restore the dimensions of the activated features, thus obtaining the restored features;

[0028] Step S434: Input the recovered features into the second activation function to obtain the weight adjustment parameters between feature channels;

[0029] The formula is:

[0030] s = F ex (z c W i )=δ(W2σ(W1z c )),

[0031] Where s represents the inter-channel weight adjustment parameter, F ex δ represents the activation function, σ represents the second activation function, and σ represents the first activation function.

[0032] As a preferred embodiment of the present invention, the formula for multiplying the weight value by the first output feature in step S44 to obtain the second output feature is as follows:

[0033]

[0034] in, F represents the second output feature. scale This represents a recalibration operation on the first output feature, s c The weight adjustment parameter represents the Cth feature channel.

[0035] As a preferred embodiment of the present invention, step S2, training and optimizing the pest and disease detection and identification network, includes the following steps:

[0036] Step S21: Obtain sample data of pest and disease images, and clean and label them to obtain training data;

[0037] Step S22: Input the training dataset into the pest and disease detection and recognition network to obtain the training output values;

[0038] Step S23: Input the training output value and the preset value into the loss function to obtain the loss value;

[0039] Step S24: Adjust the parameters of the pest and disease detection and identification network according to the loss value to obtain the trained and optimized pest and disease detection and identification network.

[0040] As a preferred embodiment of the present invention, in step S2, training and optimizing the pest and disease detection and identification network, the loss function adopted is the cross-entropy loss function for multi-class classification in PyTorch, with the following formula:

[0041]

[0042] Here, class represents the label value, which is not directly involved in the calculation. It refers to the current category, x refers to the data in the current category, and j refers to the number of categories.

[0043] As a preferred embodiment of the present invention, step S3, which involves acquiring an image of the product to be inspected and preprocessing the image to obtain the input image, includes the following steps:

[0044] Step S31: Capture an image of the product to be inspected using a camera, and convert the image format to obtain the converted image;

[0045] Step S32: Adjust the image size of the converted image to obtain the adjusted image;

[0046] Step S33: Standardize the adjusted image to obtain the input image.

[0047] As a preferred embodiment of the present invention, step S33: standardize the adjusted image to obtain the standardization formula in the input image as follows:

[0048]

[0049]

[0050] Where x is the image matrix, μ is the mean of the image, σ is the standard deviation of the image pixel values, and N is the number of pixels in image x.

[0051] To achieve another objective of the present invention, the present invention also provides a pest and disease identification device based on a ResNet residual network, corresponding to the above method, comprising:

[0052] A module is built to construct a ResNet-based pest and disease detection and identification network.

[0053] The training module is used to train and optimize the pest and disease detection and identification network;

[0054] The acquisition module is used to acquire images of the product to be inspected and to preprocess the images to obtain the input image;

[0055] The recognition module uses a trained and optimized pest and disease detection and recognition network to detect and recognize the input image and obtain the recognition result.

[0056] The construction module includes:

[0057] Modify the submodules by doubling the number of the first two convolutional layers in each block of ResNet, leaving the last layer unchanged, and adding multiple pathways to obtain the ResNeXt-50 (32x4d) network.

[0058] The attention mechanism is embedded into each residual module of the ResNeXt-50(32x4d) model to obtain the SE-ResNeXt-50(32x4d) network.

[0059] Compared to existing technologies, this invention embeds an attention mechanism into each residual module of the ResNeXt-50 (32x4d) network. This attention mechanism can learn and adjust the feature weights of each channel through network learning, assisting the model in collecting semantic information that is more helpful to the target domain, enhancing effective feature channels, suppressing the weights of ineffective or less effective elements as well as noise and other interference elements, and reducing their adverse effects on the model's recognition performance, thereby enabling the training model to achieve better results. At the same time, the ResNeXt-50 (32x4d) network itself contains a large number of residual modules, which can effectively solve the problem of reduced training performance as the number of convolutional layers increases, resulting in faster model convergence and higher recognition accuracy. Attached Figure Description

[0060] The present invention will now be described in further detail with reference to the accompanying drawings and embodiments.

[0061] Figure 1 This is a flowchart of a pest and disease identification method based on ResNet residual network according to the present invention.

[0062] Figure 2 A partial structural comparison diagram of the ResNet network and the ResNeXt-50 network with embedded SE modules;

[0063] Figure 3 This is a flowchart illustrating the training data acquisition, labeling, cleaning, and storage process in a pest and disease identification method based on ResNet residual network according to the present invention.

[0064] Figure 4 This is a schematic diagram of the network structure of a pest and disease identification method based on ResNet residual network according to the present invention.

[0065] Figure 5 This is a block diagram of a pest and disease identification device based on a ResNet residual network according to the present invention.

[0066] Figure 6 This is a block diagram of the modules built in a pest and disease identification device based on ResNet residual network according to the present invention.

[0067] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0068] To make the technical problems solved by the present invention, the technical solutions adopted, and the technical effects achieved clearer, the technical solutions of the embodiments of the present invention will be further described in detail below. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0069] Example 1

[0070] Reference Figures 1 to 4 The pest and disease identification method based on ResNet residual network is shown. For example, in this embodiment, the pest and disease detection object is strawberry. The strawberry pest and disease identification method includes the following steps:

[0071] Step S1: Construct a ResNet-based network for detecting and identifying strawberry diseases and pests;

[0072] Step S2: Train and optimize the strawberry disease and pest detection and identification network;

[0073] Step S3: Acquire an image of the strawberry to be detected and preprocess the image to obtain the input image;

[0074] Step S4: Use the trained and optimized strawberry pest and disease detection and recognition network to detect and recognize the input image to obtain the recognition results;

[0075] Step S1 includes the following steps:

[0076] Step S11: Modify the first two convolutional layers of each block in ResNet to twice the original size, keep the last layer unchanged, and add multiple pathways to obtain the ResNeXt-50 (32x4d) network;

[0077] Step S12: Embed the attention mechanism into each residual module in the ResNeXt-50(32x4d) model to obtain the SE-ResNeXt-50(32x4d) network.

[0078] Specifically, step S11 includes:

[0079] The first two convolutional layers of each block in ResNet were doubled, while the last layer remained unchanged. Following the principle of Inception-v3, 32 additional pathways were added to obtain the ResNeXt-50 (32x4d) network. This pre-trained model on the ImageNet dataset was then used as a pre-trained model for strawberry pest and disease identification, and transfer learning was performed on it. The ResNeXt-50 (32×4d) used 3, 4, 6, and 3 residual blocks respectively, totaling 48 residual units. Adding the 7×7 convolutional layer and fully connected layer of conv1, there are a total of 50 layers (pooling layers are not counted here). It significantly alleviates the gradient vanishing problem through feature mapping.

[0080] Specifically, step S12 includes:

[0081] The SE module is the core structure of the attention mechanism. It mainly includes two operations: squeezing and excitation, and can be applied to any mapping F. tr :X→U,X∈R H′×W’×C‘ ,U∈R H×W×C Taking convolution as an example, the convolution kernel is V = [v1, v2, ..., v c ], where v c If the c-th convolutional kernel is represented, then the output U = [u1, u2, ..., u] is obtained. c ]:

[0082]

[0083] Where * represents the convolution operation, and A 2D convolutional kernel representing an s-channel input takes spatial features from one channel as input and learns spatial relationships between those features. However, because the convolution results of each channel are summed, the channel feature relationships are mixed with the spatial relationships learned by the convolutional kernel. The SE module is designed to extract this mixture, allowing the model to directly learn the channel feature relationships.

[0084] Since convolution operates only within a local space, it's difficult for U to capture enough information to extract relationships between channels, resulting in a small receptive field. To adjust the weight relationships between channels, information from all channels needs to be compressed. Through a compression (squeeze) operation, the input feature map of size C×H×W (where C, H, and W are the number of feature channels, length, and width of the input feature map, respectively) undergoes global average pooling to obtain a C×1×1 feature vector. This vector represents the global information of the C feature maps in this layer, giving it a global receptive field. The formula is:

[0085]

[0086] Among them, z c F represents the compressed features. sq () represents the compression operation function, u c The first output feature is represented by W and H, which represent the width and height of the first output feature, respectively. i and j represent the coordinate positions on the first output feature, and C represents the number of feature channels of the first output feature.

[0087] Then, an excitation operation is performed, combining the compressed global information obtained in the previous operation with the dimension... The first fully connected layer serves as a dimensionality reduction layer. The dimensionality reduction coefficient *r* is a hyperparameter that reduces computational complexity. This coefficient is then input into the first activation function to obtain the activated features. Finally, these activated features are connected to the second fully connected layer, which restores the activated features to their original dimensionality, ensuring that the input and output feature channels have the same dimension. The final second activation function calculates the weight adjustment parameters for each feature channel, using ReLU as the first activation function and Sigmoid as the second activation function. The formula is:

[0088] s = F ex (z c W i )=δ(W2σ(W1z c ))

[0089] Where s represents the parameter for adjusting the weights between channels, F ex δ represents the excitation function, σ represents the sigmoid function, and σ represents the ReLU activation function.

[0090] Finally, the learned weights of each channel are multiplied by the first output feature to obtain the second output feature. The formula is:

[0091]

[0092] in, F represents the second output feature. scale This represents a recalibration operation on the first output feature, s c The weight adjustment parameter represents the Cth feature channel.

[0093] For a detailed structural diagram of the ResNeXt-50 with the SE module added, please refer to [link / reference]. Figure 2 .

[0094] Specifically, step S2: training and optimizing the pest and disease detection and identification network involves:

[0095] ① Collection of strawberry disease and pest data

[0096] Relevant strawberry pest and disease image data was collected online. Methods for collecting data online included, but were not limited to: downloading strawberry pest and disease images through plant pest and disease related software apps; searching major agricultural technology service platforms; and using Python web scraping technology to obtain publicly uploaded images of strawberry pests and diseases from technical forums where such images were available. Secondly, strawberry pest and disease image data could also be obtained through on-site visits, such as visiting nearby strawberry farms and using photographic equipment to photograph the affected areas of strawberry plants pointed out by farmers. In this experiment, using the above image data collection methods, over 50,000 unwashed images were initially collected.

[0097] ② Cleaning images of strawberry diseases and pests

[0098] The main task is to perform preliminary manual image data cleaning, which involves deleting images with low resolution (blurry images), images containing large areas of irrelevant content (such as the photographer's hand), images with overly prominent information (such as red caps on strawberry fruits), and images with a large number of diseased individuals (multiple strawberry plants showing disease in an image).

[0099] ③ Labeling of strawberry disease and pest images

[0100] The images were labeled with pest and disease information provided by the app; the images were also labeled with pest and disease information provided by multiple fruit farmers; and the images were labeled with pest and disease information obtained from responses by technical experts in the corresponding forums. The resulting cleaned data comprised 32 categories.

[0101] The processed image data is then stored. A flowchart illustrating the entire data acquisition, annotation, cleaning, and storage workflow is provided below. Figure 3 .

[0102] ④ Image data preprocessing

[0103] Based on the model's structural requirements, we need to preprocess the images. This mainly involves selecting JPG images as input to the model; other image formats are also acceptable, but the model's input data will need to be modified. Then, the image size is resized to 224x224.

[0104] ⑤ Image data enhancement

[0105] Data augmentation is primarily used to expand existing image datasets. It involves performing a series of data augmentation operations on the original data, including X-axis symmetry, Y-axis symmetry, random rotation, random brightness and contrast, and random application of affine transformations. Finally, the image data is standardized to improve model accuracy and convergence speed. Data standardization better preserves sample spacing and conforms to statistical assumptions. The standardization formula is shown below:

[0106]

[0107]

[0108] Where x is the image matrix, μ is the mean of the image, σ is the standard deviation of the image pixel values, and N is the number of pixels in image x.

[0109] ⑥ Parameter settings

[0110] After data preprocessing and data augmentation, the image names ("name") and category ("label") of the image dataset are read using Python and stored in an Excel file. A data reading function is constructed to input the data into the model. The model's input shape parameter is 224*224*3, representing 3 channels, corresponding to the image size mentioned above; the batch size is 64; the learning rate is 1e-3; the number of workers (num_workers) is 0; the number of iterations (epochs) is 200; the L2 weight decay is set to 1e-5; and the number of output categories (out_features) is set to 18, indicating that we only train on 18 categories of data with sufficient quantity.

[0111] The learning rate annealing function calc_learning_rate is constructed to adjust the learning rate during training by reducing the learning rate according to a predefined schedule, so that the model adaptively adjusts the learning rate as the number of training iterations increases.

[0112] The optimizer chosen for the model is AdamW, which is a weight decay-based optimizer. It combines the Adam optimizer with L2 regularization, and sets a weight decay parameter weight_decay = 1e-5 to adjust the L2 regularization.

[0113] Setting the activation function for each layer to ReLU can overcome the vanishing gradient problem and speed up training. It primarily converts all negative values ​​to 0, while leaving positive values ​​unchanged. Its formula is...

[0114] f(x) = max(0,x)

[0115] A global average pooling layer is set up to reduce the dimensionality of pest and disease feature data and remove redundant information.

[0116] The loss function chosen is PyTorch's multi-class cross-entropy loss function, CrossEntropyLoss, which combines LogSoftmax and NLLLoss methods into one class. LogSoftmax is essentially performing an additional log operation on the softmax result. Therefore, CrossEntropyLoss can be understood as combining Softmax, Log, and NLLLoss into a single step. The values ​​after softmax are all between 0 and 1; taking the log again and replacing multiplication with addition reduces computation and ensures the function's monotonicity; the output result and corresponding label values ​​are then subjected to NLLLoss, negative signs are removed, and the mean is calculated. The formula is as follows:

[0117]

[0118] The label value (class) is not directly involved in the calculation; it refers to the current category, x refers to the data in the current category, and j refers to the total number of categories. For example, if we input three categories 0, 1, and 2, with a batch size of 1 and specific values ​​[-0.8, -0.6, -0.4], the loss value for the data belonging to category 0 would be calculated as...

[0119] 0.8+log(exp(-0.8)+exp(-0.6)+exp(-0.4))≈1.3119

[0120] For model evaluation, the StratifiedKFold cross-validation method was used, specifically five-fold cross-validation, meaning the ratio of training to validation sets was 4:1. StratifiedKFold employs stratified sampling to ensure that the proportion of samples from each class in the training and validation sets is the same as in the original dataset. The data was randomly shuffled during StratifiedKFold sampling. The model's evaluation metrics were accuracy and F1 score.

[0121] Step S3: Acquire an image of the product to be inspected and preprocess the image to obtain the input image, specifically:

[0122] Take an image of the strawberry to be detected. If the image format is not JPG, convert the image format to obtain a JPG image of the strawberry to be detected. Adjust the size of the strawberry image to 224*224. Finally, perform normalization processing to obtain the input image.

[0123] Step S4 involves using the trained and optimized pest and disease detection and recognition network to detect and recognize the input image, yielding the following recognition results:

[0124] The input image is convolved to obtain the first output feature; the first output feature is compressed to obtain the compressed feature; the compressed feature is activated to obtain the weight adjustment parameters between feature channels; the weight values ​​are multiplied by the first output feature to obtain the second output feature; the second output feature is used for identification to obtain the strawberry disease and pest identification result.

[0125] Example 2

[0126] refer to Figures 5 to 6 The pest and disease identification device based on ResNet residual network shown is used to implement the method of Embodiment 1. Exemplarily, in this embodiment, the object of pest and disease detection is strawberry, and the strawberry pest and disease identification device includes:

[0127] Module 601 is used to build a ResNet-based strawberry pest and disease detection and identification network;

[0128] Training module 602 is used to train and optimize the strawberry disease and pest detection and identification network;

[0129] The acquisition module 603 is used to acquire images of the strawberries to be detected and to preprocess the images to obtain the input image;

[0130] The recognition module 604 uses a trained and optimized strawberry pest and disease detection and recognition network to detect and recognize the input image, and obtain the strawberry pest and disease recognition result.

[0131] The construction module includes:

[0132] Modify submodule 6011 to double the number of the first two convolutional layers in each block of ResNet, keep the last layer unchanged, and add multiple pathways to obtain the ResNeXt-50 (32x4d) network.

[0133] Embedded submodule 6012 embeds the attention mechanism into each residual module in the ResNeXt-50(32x4d) model, resulting in the SE-ResNeXt-50(32x4d) network.

[0134] The pest and disease identification method based on ResNet residual network in Embodiment 1 of this invention can be implemented via a WeChat mini-program. Demonstratively, we encapsulate image preprocessing, the reading model, and the strawberry pest and disease identification network within the Flask framework, and then deploy this Flask framework on an Alibaba Cloud server using Docker. When a user opens the WeChat mini-program and takes a photo or uploads an image of the strawberry to be detected, the image is uploaded to the Alibaba Cloud server using cloud functions. The Flask framework, deployed on the Alibaba Cloud server via Docker, preprocesses the strawberry image, converting it to JPG format and adjusting its size to 224*224. Finally, it is standardized to obtain the input image. The strawberry pest and disease identification network detects and identifies the input image, and searches the cloud database based on the detected pest and disease results to obtain information such as symptoms, solutions, and preventative measures. Finally, the identification results are displayed on the WeChat mini-program client using WXML, WXSS, and JavaScript.

[0135] The term "comprising," and any variations thereof, used in the description herein are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or modules is not limited to the steps or modules listed, but may optionally include other steps or modules not listed, or may optionally include other steps or modules inherent to those processes, methods, products, or apparatuses. The terms "first" and "second" used herein are used merely for descriptive distinction and have no particular meaning.

[0136] Furthermore, it should be understood that although this specification describes embodiments, not every embodiment contains only one independent technical solution. This narrative style is merely for clarity. Those skilled in the art should consider the specification as a whole, and the technical solutions in each embodiment can also be appropriately combined to form other embodiments that can be understood by those skilled in the art.

[0137] The technical principles of the present invention have been described above with reference to specific embodiments. These descriptions are merely for explaining the principles of the invention and should not be construed as limiting the scope of protection of the invention in any way. Based on this explanation, those skilled in the art can readily conceive of other specific embodiments of the invention without inventive effort, and these embodiments will all fall within the scope of protection of the present invention.

Claims

1. A method for identifying pests and diseases based on ResNet residual networks, characterized in that, The method is used for identifying strawberry diseases and pests, and includes the following steps: Step S1: Build a ResNet-based pest and disease detection and identification network; Step S2: Train and optimize the pest and disease detection and identification network; Step S3: Acquire an image of the product to be inspected and preprocess the image to obtain an input image with a size of 224×224; Step S4: Use the trained and optimized pest and disease detection and recognition network to detect and recognize the input image to obtain the recognition results; Step S1 includes the following steps: Step S11: Modify the first two convolutional layers of each block in ResNet to twice the original size, keep the last layer unchanged, and add 32 pathways to obtain the ResNeXt-50 (32x4d) network; Step S12: Embed the attention mechanism into each residual module in the ResNeXt-50 (32x4d) model to obtain the SE-ResNeXt-50 (32x4d) network; SE modules are set between the first convolutional layer and the max pooling layer of the SE-ResNeXt-50 (32x4d) network and between the last residual stage and the global average pooling layer of the SE-ResNeXt-50 (32x4d) network; both SE modules are independent of each residual module and each includes, in sequence, a global average pooling layer, a first fully connected layer, a first activation function, a second fully connected layer, and a second activation function.

2. The pest and disease identification method based on ResNet residual network as described in claim 1, characterized in that, In step S4, the trained and optimized pest and disease detection and recognition network is used to detect and recognize the input image to obtain the recognition result, which includes the following steps: Step S41: Perform convolution processing on the input image to obtain the first output feature; Step S42: Compress the first output feature to obtain the compressed feature; Step S43: Perform excitation processing on the compressed features to obtain the weight adjustment parameters between feature channels; Step S44: Multiply the weight value by the first output feature to obtain the second output feature; Step S45: Identify the second output feature to obtain the identification result.

3. The pest and disease identification method based on ResNet residual network as described in claim 2, characterized in that, Step S42 compresses the first output feature to obtain the compressed feature: Global average pooling is performed on the first output feature to obtain the compressed feature, as shown in the formula: , in, Represents the compressed features. This represents the compression operation function. The first output feature is represented by W and H, which represent the width and height of the first output feature, respectively. i and j represent the coordinate positions on the first output feature, and C represents the number of feature channels of the first output feature.

4. The pest and disease identification method based on ResNet residual network as described in claim 2, characterized in that: Step S43, which involves excitation processing of the compressed features to obtain the weight adjustment parameters between feature channels, includes the following steps: Step S431: Connect the compressed features to the first fully connected layer to reduce the dimensionality of the compressed features and obtain the dimensionality-reduced features; Step S432: Input the dimensionality-reduced features into the first activation function to obtain the activated features; Step S433: Connect the activated features to the second fully connected layer to restore the dimensions of the activated features, thus obtaining the restored features; Step S434: Input the recovered features into the second activation function to obtain the weight adjustment parameters between feature channels; The formula is: , Where 's' represents the inter-channel weight adjustment parameter. Represents the excitation operation function. Represents the second activation function. Represents the first activation function. , .

5. The pest and disease identification method based on ResNet residual network as described in claim 2, characterized in that: Step S44 multiplies the weight value by the first output feature to obtain the formula for the second output feature: , in, Represents the second output feature. This represents a recalibration operation on the first output feature. The weight adjustment parameter represents the Cth feature channel.

6. The pest and disease identification method based on ResNet residual network as described in claim 1, characterized in that, Step S2, which trains and optimizes the pest and disease detection and identification network, includes the following steps: Step S21: Obtain sample data of pest and disease images, and clean and label them to obtain training data; Step S22: Input the training dataset into the pest and disease detection and recognition network to obtain the training output values; Step S23: Input the training output value and the preset value into the loss function to obtain the loss value; Step S24: Adjust the parameters of the pest and disease detection and identification network according to the loss value to obtain the trained and optimized pest and disease detection and identification network.

7. The pest and disease identification method based on ResNet residual network as described in claim 1, characterized in that: In step S2, training and optimizing the pest and disease detection and identification network, the loss function used is the CrossEntropyLoss function for multi-class classification in PyTorch, with the following formula: , Here, class represents the label value, which is not directly involved in the calculation. It refers to the current category, x refers to the data in the current category, and j refers to the number of categories.

8. The pest and disease identification method based on ResNet residual network as described in claim 1, characterized in that, Step S3 involves acquiring an image of the product to be inspected and preprocessing the image to obtain the input image, including the following steps: Step S31: Capture an image of the product to be inspected using a camera, and convert the image format to obtain the converted image; Step S32: Adjust the image size of the converted image to obtain the adjusted image; Step S33: Standardize the adjusted image to obtain the input image.

9. The pest and disease identification method based on ResNet residual network as described in claim 8, characterized in that: Step S33: Standardize the adjusted image to obtain the standardization formula for the input image: , , in It is an image matrix. The mean of the image. It is the standard deviation of the image pixel values. It is an image The number of pixels.

10. A pest and disease identification device based on a ResNet residual network, characterized in that, The device is used for identifying strawberry diseases and pests, and includes: A module is built to construct a ResNet-based pest and disease detection and identification network. The training module is used to train and optimize the pest and disease detection and identification network; The acquisition module is used to acquire images of the product to be inspected and preprocess the images to obtain an input image with a size of 224×224. The recognition module uses a trained and optimized pest and disease detection and recognition network to detect and recognize the input image and obtain the recognition result. The construction module includes: Modify the submodules by doubling the number of the first two convolutional layers in each block of ResNet, leaving the last layer unchanged, and adding 32 pathways to obtain the ResNeXt-50 (32x4d) network. An embedding submodule is used to embed the attention mechanism into each residual module of the ResNeXt-50 (32x4d) model, resulting in an SE-ResNeXt-50 (32x4d) network. A first SE module is set between the first convolutional layer and the max pooling layer of the SE-ResNeXt-50 (32x4d) network, and a second SE module is set between the last residual stage and the global average pooling layer of the SE-ResNeXt-50 (32x4d) network. Both the first SE module and the second SE module are independent of each residual module and each includes, in sequence, a global average pooling layer, a first fully connected layer, a first activation function, a second fully connected layer, and a second activation function.