A pest identification method and system based on image analysis
By combining YOLO, Mask R-CNN and SVM technologies, efficient identification and evaluation of pest species, detailed images and pest disasters are achieved, and the problem of difficulty in accurately judging pest development stages and pest disasters in the existing technology is solved, ensuring the safety of crop yields.
Patent Information
- Application Number
- CN202311549471.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-21
- Publication Date
- 2025-03-07
- Estimated Expiration
- 2043-11-21
AI Technical Summary
The existing YOLO target detection algorithm is difficult to accurately judge the development stage of pests and whether pest disasters occur, resulting in the inability to take timely response measures. The pests may spread rapidly, resulting in a decline in crop yields.
Using a pest recognition method based on image analysis, the pest species are determined through the YOLO algorithm, the Mask R-CNN algorithm segments the pest detail images, and uses the SVM support vector machine to evaluate whether a pest disaster has occurred.
It has achieved a timely and accurate assessment of the pest development stage and pest disasters, and can take timely prevention and control measures to avoid the spread of pests and protect crop yields.
Smart Images

Figure CN117649549B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of image data processing, and in particular relates to an insect pest identification method and system based on image analysis. Background Art
[0002] my country is a large agricultural country, and agriculture is the foundation of the national economy. The prevention and control of pests and diseases during crop growth is a major problem faced by farmers. Traditional pest and disease identification mainly relies on agricultural experts or experienced farmers to identify pests by observing their morphology, characteristics and other characteristics with the naked eye. On the one hand, this method of manual judgment is often mixed with some uncontrollable factors, such as the unevenness of the relevant professions of practitioners, which will lead to misjudgment of the target identification, and it is not possible to monitor and classify in real time. On the other hand, there are few professional pest researchers, and the relevant knowledge is not widely popularized among farmers, which cannot meet the needs of actual production.
[0003] With the rapid development of technologies such as pattern recognition, machine vision, and deep learning, as well as the country's strong promotion of smart agriculture, more and more modern technologies are being applied to agricultural production. Target detection algorithms represented by YOLO have been widely used in real-time pest detection, improving recognition accuracy and work efficiency, and saving a lot of manpower and material resources.
[0004] However, although the existing YOLO target detection algorithm can relatively accurately identify whether an image contains pests and the specific types of pests, it is difficult to further accurately determine the developmental stage of the pests and whether a pest disaster has occurred. It is difficult to effectively prevent the outbreak of pest disasters, resulting in the inability to take timely response measures. Pests may spread rapidly in a short period of time, and delayed treatment will lead to a serious decline in crop yields. Summary of the invention
[0005] In order to solve the technical problems that the existing YOLO target detection algorithm is difficult to further accurately determine the development stage of pests and whether a pest disaster has occurred, and it is difficult to effectively prevent the outbreak of pest disasters, resulting in the inability to take timely countermeasures, the pests may spread rapidly in a short period of time, and delayed treatment will lead to a serious decline in crop yields and cause economic losses to farmers, the present invention provides a pest identification method and system based on image analysis.
[0006] First aspect
[0007] The present invention provides an insect pest identification method based on image analysis, comprising:
[0008] S101: Acquire original pest images of different types for target crops;
[0009] S102: preprocessing the original pest image;
[0010] S103: constructing a pest dataset according to the preprocessed pest images;
[0011] S104: constructing a pest image recognition model based on the YOLO algorithm, so as to determine the specific type of the pest in the pest image through the pest image recognition model;
[0012] S105: constructing a pest image segmentation model based on the Mask R-CNN algorithm, so as to segment a pest detail image from the pest image through the pest image segmentation model;
[0013] S106: constructing an insect pest disaster assessment model based on an SVM support vector machine, so as to assess whether an insect pest disaster occurs according to the insect detail image through the insect pest disaster assessment model;
[0014] S107: training the pest image recognition model, the pest image segmentation model and the pest disaster assessment model using the pest dataset;
[0015] S108: Acquire the image to be detected;
[0016] S109: Determine whether the image to be detected contains pests and the specific type of the pests through the pest image recognition model;
[0017] S110: When the image to be detected contains pests, segmenting a pest detail image from the image to be detected using the pest image segmentation model;
[0018] S111: using the pest disaster assessment model to assess whether a pest disaster has occurred based on the pest detail image.
[0019] Second aspect
[0020] The present invention provides an insect pest identification system based on image analysis, which is used to execute the insect pest identification method based on image analysis in the first aspect.
[0021] Compared with the prior art, the present invention has at least the following beneficial technical effects:
[0022] In the present invention, on the basis of using the YOLO algorithm to determine the specific types of pests in the pest image, the Mask R-CNN algorithm is further used to segment the pest detail image from the pest image, and the SVM support vector machine is used to evaluate in real time whether a pest disaster has occurred based on the pest detail image. It can timely and accurately evaluate whether a pest disaster has occurred, and when it is predicted that a pest disaster has occurred or is about to occur, timely and effective countermeasures can be taken to prevent the outbreak of the pest disaster, avoid the further spread of pests in a short period of time, avoid a serious decline in crop yields due to pest disasters, and save farmers' economic losses. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] The preferred implementation modes will be described below in a clear and understandable manner with reference to the accompanying drawings to further illustrate the above-mentioned characteristics, technical features, advantages and implementation methods of the present invention.
[0024] Figure 1 It is a schematic diagram of a process of an insect pest identification method based on image analysis provided by the present invention;
[0025] Figure 2 It is a structural schematic diagram of an insect pest identification method based on image analysis provided by the present invention. DETAILED DESCRIPTION
[0026] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the specific implementation methods of the present invention will be described below with reference to the accompanying drawings. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings and other implementation methods can be obtained based on these drawings without creative work.
[0027] In order to simplify the drawings, only the parts related to the invention are schematically shown in each figure, and they do not represent the actual structure of the product. In addition, in order to simplify the drawings and facilitate understanding, in some figures, only one of the parts with the same structure or function is schematically drawn or marked. In this article, "one" not only means "only one", but also means "more than one".
[0028] It should be further understood that the term "and / or" used in the present description and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0029] In this document, it should be noted that, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense. For example, it can be a fixed connection, a detachable connection, or an integral connection. It can be a mechanical connection or an electrical connection. It can be directly connected or indirectly connected through an intermediate medium, and it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0030] In addition, in the description of the present invention, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0031] Example 1
[0032] In one embodiment, the reference specification Figure 1 , which shows a schematic diagram of the process of the pest identification method based on image analysis provided by the present invention. Figure 2 , showing a structural schematic diagram of an insect pest identification method based on image analysis provided by the present invention.
[0033] The present invention provides an insect pest identification method based on image analysis, comprising:
[0034] S101: Acquire original pest images of different types for target crops.
[0035] The target crops may be various crops such as rice, cotton, corn, etc. The present invention does not limit the specific type of the target crops.
[0036] Among them, the types of pests include gnawing insects, sucking insects, piercing insects, boring insects, etc. The present invention does not limit the specific types of insects.
[0037] Specifically, raw pest images can be captured by drones.
[0038] S102: Preprocessing the original pest image.
[0039] Among them, preprocessing can include rotation, filtering and noise reduction, brightness equalization, etc.
[0040] In a possible implementation, S102 specifically includes sub-steps S1021 to S1023:
[0041] S1021: Rotate the original pest image according to the offset angle of the original pest image:
[0042]
[0043] Among them, (x0, y0) represents the coordinates of the pixel before rotation, (x t ,y t ) represents the coordinates of the pixel after rotation, and θ represents the offset angle.
[0044] It should be noted that the original image may have inconsistent directions of pests in the image due to different shooting angles. Through rotation correction, the directions of pests in the image can be made more uniform, which helps the subsequent algorithms to work more accurately in pest location and identification.
[0045] S1022: Filter and reduce noise on the rotated pest image according to the following formula:
[0046]
[0047] Among them, f m (x, y) represents the pixel value after filtering and denoising at the pixel point (x, y), x represents the horizontal coordinate of the pixel point, y represents the vertical coordinate of the pixel point, σ represents the standard deviation of the pixel value in the neighborhood, and e represents the natural logarithm.
[0048] It should be noted that pest images in farmland environments may be subject to varying degrees of noise interference, such as noise from the photosensitive device of the camera equipment, atmospheric interference, etc. Filtering and noise reduction can reduce these interferences, making the image clearer, and helping the algorithm to more accurately extract pest features in subsequent processing.
[0049] Furthermore, the Gaussian filter performs a weighted average of the pixels in the neighborhood, with the weight gradually decreasing as the distance increases, which means that farther pixels have less influence on the current pixel, and closer pixels have a greater influence. This local weighted average allows the filtered image to maintain edge clarity while being smooth.
[0050] In the present invention, Gaussian filtering can effectively eliminate high-frequency noise in the image while retaining the edge information of the image. Gaussian filtering performs well in blurring images, reducing noise and smoothing images, so it is suitable for noise and interference problems that may exist in pest images.
[0051] It should be noted that the different lighting conditions in the farmland may cause uneven image brightness. Brightness equalization can make different parts of the image have a more uniform brightness level, thereby improving the readability of the image and the visibility of pest features. Brightness equalization can remap the pixel values in the image so that the brightness range is more evenly distributed, thereby highlighting the details in the image and improving the visual effect of the image.
[0052] S1023: Brightness equalization is performed on the pest image after noise reduction filtering according to the following formula:
[0053] I out=255c·F γ
[0054]
[0055] γ=log2(mF m )
[0056] Among them, I out Indicates the brightness value after brightness equalization processing, I in represents the brightness value before brightness equalization processing, c represents the proportional coefficient, F represents the normalized brightness value, γ represents the gamma correction index, and F m represents the median value of the brightness before brightness equalization processing, m represents the target brightness mean, and m can be obtained in the following way:
[0057]
[0058] in, represents the mean of the brightness values before brightness equalization processing, and round(·) represents the rounding function.
[0059] In the present invention, brightness equalization can remap an image with uneven brightness distribution to a more uniform distribution, which helps to highlight the details in the image. The details of both dark and bright parts can be displayed more clearly, thereby improving the visual effect of the image. In the image preprocessing process, brightness equalization can provide a better basis for subsequent image processing steps. For example, in recognition or analysis tasks, the image after brightness equalization can better show the target features, thereby improving the accuracy of subsequent processing.
[0060] In the present invention, preprocessing helps to improve image quality, reduce noise, and enhance image features, thereby providing better image data for subsequent pest image recognition, segmentation, and analysis. It helps to optimize image features so that pest algorithms can more effectively extract useful information from images, thereby improving the accuracy and reliability of pest detection and analysis.
[0061] S103: Construct a pest dataset based on the preprocessed pest images.
[0062] S104: Based on the YOLO algorithm, a pest image recognition model is constructed to determine the specific type of pests in the pest image through the pest image recognition model.
[0063] Among them, the YOLO algorithm (You Only Look Once) is a popular real-time target detection algorithm, whose main feature is to detect and locate objects simultaneously in a single forward pass. The YOLO algorithm has been widely used in the field of target detection due to its high speed, real-time and accuracy.
[0064] In a possible implementation, the present invention makes a creative improvement to the existing YOLO algorithm, and S104 specifically includes sub-steps S1041 to S1045:
[0065] S1041: Input the pest image into the CSPDarknet-53 backbone network, wherein the CSPDarknet-53 backbone network includes a CBM component and 5 CSP components. The CBM component includes a Conv convolution layer, a BN batch normalization layer, and a Mish activation function. The CSP component includes a convolution layer and several Resunit modules. The Resunit module adopts a ResNet residual structure.
[0066] In the present invention, compared with the existing YOLO algorithm, the CSPDarknet-53 backbone network is added, so that the learning ability of the convolutional neural network is effectively enhanced. While ensuring the lightweight of the network, it not only maintains the accuracy, but also reduces the memory usage cost, and breaks through the computing bottleneck.
[0067] S1042: In the CBM component, the Conv convolution layer uses the convolution kernel to perform convolution operations to extract different features in the pest image. The BN batch normalization layer is used to normalize the convolution output. The Mish activation function is used to introduce nonlinearity and enhance the expressiveness of the features.
[0068] S1043: In the CSP component, the convolution layer uses the convolution kernel to perform convolution operations on the features. The Resunit module uses the ResNet residual structure to perform feature processing.
[0069] S1044: An upsampling layer and an SPP module are set on each prediction branch. The upsampling layer is used to enlarge the size of the feature map to finely express the local features. The SPP module is used to extract features from different scales using a maximum pooling operation to perform feature fusion.
[0070] In the present invention, compared with the existing YOLO algorithm, an upsampling layer and an SPP module are set on each prediction branch. The upsampling layer is used to enlarge the size of the feature map and finely express the local features. The SPP module is used to extract features from different scales using the maximum pooling operation to perform feature fusion.
[0071] S1045: Through the classifier, the fused features are mapped to each possible pest type, and the softmax activation function is used to output the probability of each category.
[0072] In the present invention, through the classifier, the network can map the fused features to each possible pest type, realizing multi-category pest image recognition. This is very important for distinguishing different types of pests. The softmax activation function is used to output the probability of each category, which allows the algorithm to give the confidence of each pest category. This helps users understand the credibility of the recognition results.
[0073] In summary, the innovative improvements to the YOLO algorithm have significantly improved the accuracy, robustness, and efficiency of the pest image recognition algorithm. The network can better capture features and make accurate classification decisions, which will help achieve more accurate pest monitoring and control in the agricultural field and improve crop yield and quality.
[0074] S105: Based on the Mask R-CNN algorithm, a pest image segmentation model is constructed to segment pest detail images from the pest image through the pest image segmentation model.
[0075] Among them, the Mask R-CNN algorithm is a deep learning algorithm widely used in the field of target detection. It is an extension of the traditional FasterR-CNN target detection algorithm. It can simultaneously realize target detection and pixel-level target segmentation, that is, it generates an accurate mask of the target based on the target to achieve accurate image segmentation.
[0076] In a possible implementation, the present invention makes a creative improvement to the existing Mask R-CNN algorithm, and S105 specifically includes sub-steps S1051 to S1054:
[0077] S1051: Extracting image features from the pest image through a backbone feature extraction network.
[0078] S1052: Determine a region of interest based on image features.
[0079] In a possible implementation manner, S1052 specifically includes:
[0080] The region of interest is determined from the pest image according to the following formula:
[0081] ROI={(x,y)|minT≤f(x,y)≤maxT}
[0082] Wherein, ROI represents the region of interest, which is the set of pixels whose image feature values are between the minimum threshold and the maximum threshold, minT represents the minimum threshold, maxT represents the maximum threshold, and f(x,y) represents the image feature value at the pixel point (x,y).
[0083] In the present invention, not all pixels in the pest image contribute important information to the generation and segmentation of the target detail image. By determining the region of interest based on image features, parts that are unlikely to contain pest details can be excluded, thereby reducing the complexity and cost of subsequent calculations. Focusing on the key region of interest can make the generated pest detail image more accurate and clear. This helps to improve the quality of the segmented image, making the shape and texture of the pest more realistic and accurate.
[0084] S1053: Align the region of interest.
[0085] It should be noted that during the process of pooling and quantizing the region of interest, there will be a mismatch between the position of the region of interest and the feature map, so the region of interest needs to be aligned.
[0086] In a possible implementation, sub-step S1053 specifically includes sub-steps S10531 to S10533:
[0087] S10531: Obtain four pixel points N around the virtual pixel point P in the feature image 11 (x1,y1),N 12 (x1,y2),N 21 (x2,y1),N 22 Image feature value of (x2,y2).
[0088] S10532: Interpolate the virtual pixel point P in the x direction:
[0089]
[0090] Among them, f(x s ,y1) represents the point after interpolation in the x direction (x s ,y1), f(x1,y1) represents the image feature value at pixel N 11 The image feature value at (x1, y1), f(x2, y1) represents the pixel point N 21 Image feature value at (x2,y1).
[0091]
[0092] Among them, f(x s ,y2) represents the point after interpolation in the x direction (x s ,y2), f(x1,y2) represents the image feature value at pixel point N 12 The image feature value at (x1, y2), f(x2, y2) represents the pixel point N 22 Image feature value at (x2,y2).
[0093] S10533: interpolate the virtual pixel point P in the y direction to calculate the image feature value of the virtual pixel point P:
[0094]
[0095] Among them, f(x s ,y s ) represents the virtual pixel point P(x s ,y s ) is the image feature value at .
[0096] S10534: Using the image feature value at the virtual pixel point P in the feature image as the image feature value of the pixel point P′ in the aligned target image.
[0097] In the present invention, the alignment process can more accurately map the information of the region of interest to the target image. This helps to improve the accuracy of segmentation, retain more target details, and thus obtain a more accurate pest detail image. Furthermore, the pooling and quantization process may cause information loss, especially in the case of mismatch. Through the alignment process, the inaccuracy introduced by information mismatch can be avoided, ensuring that the segmentation result is more reliable.
[0098] S1054: Segment the pest detail image from the region of interest through the segmentation branch in the head.
[0099] In the present invention, the pest image segmentation model based on the Mask R-CNN algorithm can generate a label for each pixel and associate each part in the image with the corresponding pest details. This allows the detail image to not only contain the overall shape of the pest, but also provide detailed information about the pest's body structure, texture and characteristics. The pest detail image can be accurately and detailedly segmented, providing more reliable data and basis for tasks such as pest analysis, development stage judgment and pest disaster assessment.
[0100] S106: Based on the SVM support vector machine, a pest disaster assessment model is constructed to assess whether a pest disaster occurs according to the pest detail image through the pest disaster assessment model.
[0101] Among them, Support Vector Machine (SVM) is a supervised learning algorithm, mainly used for classification and regression problems. Its main goal is to find a hyperplane that can separate sample points of different categories as much as possible and maximize the distance from the hyperplane to the nearest sample point (support vector). SVM performs well in processing high-dimensional data and complex nonlinear classification problems.
[0102] In a possible implementation manner, the present invention makes a creative improvement to the existing SVM support vector machine, and S106 specifically includes sub-steps S1061 to S1066:
[0103] S1061: Extract feature vectors of pest detail images of each test sample.
[0104] S1062: Input the feature vector of each pest detail image into the support vector machine.
[0105] S1063: Construct the objective function minL(ω,b,ξ) of the support vector machine:
[0106]
[0107] Among them, ω represents the normal vector of the hyperplane, b represents the offset of the hyperplane, ξ represents the slack variable, ξ i represents the slack variable of the i-th pest detail image, ξ j represents the slack variable of the jth pest detail image. The slack variable ξ is used to handle the inseparable situation. Y represents the input pest disaster assessment result. i represents the pest disaster assessment result of the i-th pest detail image, Y j represents the pest disaster assessment result of the jth pest detail image, K(X i ·X j ) represents the kernel function, which is used to map samples to high-dimensional feature space, indicating that X i With X j The similarity between them, g represents the kernel parameter, X represents the feature vector of the input pest detail image, X i represents the feature vector of the i-th pest detail image, X j represents the feature vector of the jth pest detail image, C represents the penalty factor, and the penalty factor C is used to control the complexity of the model. N represents the number of samples, i = 1, 2, ..., N, j = 1, 2, ..., N.
[0108] Among them, introducing the penalty factor C in the objective function can play a role in controlling the complexity of the model in the objective function of the support vector machine. A larger penalty factor C will cause the model to pursue correct classification more strictly, but it may make the model too complex and overfit the training data; while a smaller penalty factor C will make the model easier to adapt to the training data, but it may lead to poor generalization ability. Therefore, by adjusting the penalty factor C, the bias and variance of the model can be balanced to obtain better generalization performance.
[0109] Among them, the kernel function is introduced to process the similarity of feature vectors, which enables the model to better capture the complex relationship between pest detail images.
[0110] S1064: By searching for the optimal penalty factor and kernel parameter, the normal vector ω, offset b and slack variable ξ of the optimal hyperplane are calculated. Then the optimal hyperplane f(X i ,X j ) can be expressed as:
[0111]
[0112] Among them, the sgn() function is used to return the positive or negative value of the independent variable.
[0113] S1065: Project the feature vector of the pest detail image onto the optimal hyperplane.
[0114] S1066: When the projection of the feature vector of the pest detail image on the optimal hyperplane is located on the first side of the optimal hyperplane, the presence of pest disaster is taken as the pest disaster assessment result. When the projection of the feature vector of the pest detail image on the optimal hyperplane is located on the second side of the optimal hyperplane, the presence of pest disaster is taken as the pest disaster assessment result.
[0115] It should be noted that by constructing a pest disaster assessment model based on SVM support vector machine, the pest detail images can be effectively classified and evaluated, which is adaptable to complex problems, has high accuracy and interpretability, and provides a powerful tool and decision-making support for agricultural pest control.
[0116] In the present invention, the pest disaster assessment model based on the SVM support vector machine can evaluate in real time whether a pest disaster has occurred based on the pest detail image. It can timely and accurately evaluate whether a pest disaster has occurred. When it is predicted that a pest disaster has occurred or is about to occur, timely and effective countermeasures can be taken to prevent the outbreak of the pest disaster, avoid the further spread of pests in a short period of time, avoid a serious decline in crop yields due to pest disasters, and save farmers' economic losses.
[0117] S107: Train the pest image recognition model, pest image segmentation model and pest disaster assessment model using the pest dataset.
[0118] In a possible implementation, the training steps of the pest image recognition model are:
[0119] Construct the loss function of the pest image recognition model:
[0120] L=λ1L CIOU +λ2L cls +λ3L conf
[0121] Where L represents the loss function of the pest image recognition model, L CIOUrepresents the bounding box loss function, λ1 represents the weight of the bounding box loss function, and L cls represents the cross entropy loss function, λ2 represents the weight of the cross entropy loss function, L conf represents the confidence loss function, and λ3 represents the weight of the confidence loss function.
[0122] Among them, those skilled in the art can set the weight λ1 of the bounding box loss function, the weight λ2 of the cross entropy loss function, and the weight λ3 of the confidence loss function according to actual conditions, and the present invention does not limit this.
[0123] Among them, the bounding box loss is used to ensure the accuracy of the bounding box. In object detection, each bounding box is represented by its bounding box coordinates (position and size). The bounding box loss evaluates the gap between the bounding box coordinates of the bounding box and the true bounding box coordinates so that the model can better locate the object.
[0124] Among them, cross entropy loss is used to solve the classification problem, that is, to classify the input data into different categories. In object detection, the model needs to classify each prediction box, that is, to determine which category the object in the prediction box belongs to. Cross entropy loss measures the difference between the model's prediction result and the true category.
[0125] Among them, confidence loss refers to whether each detection box predicted by the model contains the target. Confidence loss is used to evaluate the prediction accuracy of the model on confidence. For boxes containing targets, the model needs to predict high confidence, and for boxes that do not contain targets, the model needs to predict low confidence.
[0126] Among them, the bounding box loss function L CIOU Specifically:
[0127]
[0128] d 2 =ρ 2 (b,b gt )
[0129]
[0130]
[0131] Among them, IOU represents the intersection-over-union ratio of the predicted box and the true box, d represents the Euclidean distance between the center points of the predicted box and the true box, c represents the diagonal length of the minimum closure between the true box and the predicted box, α represents the trade-off parameter, v represents the consistency parameter, ρ() represents the center point Euclidean distance calculation function, b represents the predicted box, b gt represents the real box, w gt Indicates the width of the real box, h gtrepresents the height of the real box, w represents the width of the predicted box, and h represents the height of the predicted box.
[0132] Among them, the cross entropy loss function L cls Specifically:
[0133]
[0134] Where m represents the number of samples, i = 1, 2, ..., m, S represents the number of categories, j = 1, 2, ..., S, p ij Indicates the classification of the i-th sample belonging to the j-th category. When the i-th sample belongs to the j-th category, p ij =1, otherwise, p ij =0,q ij It represents the predicted probability that the i-th sample belongs to the j-th category.
[0135] Among them, the confidence loss function L conf Specifically:
[0136]
[0137] Where m represents the number of samples, i = 1, 2, ..., m, S represents the number of categories, j = 1, 2, ..., S, q ij represents the predicted probability that the i-th sample belongs to the j-th category, β represents the hyperparameter for balancing the number of positive and negative samples, and γ represents the hyperparameter for balancing the prediction accuracy of positive and negative samples.
[0138] The pest image recognition model is trained with the goal of minimizing the loss function.
[0139] In the present invention, by combining different types of loss functions, the pest image recognition model can be optimized in multiple aspects, thereby learning the target more comprehensively. Different loss functions are comprehensively optimized for different aspects of the model, such as the accuracy of the bounding box, the accuracy of the category classification, and the reliability of the confidence. The use of multiple loss functions to comprehensively optimize the training of the pest image recognition model can improve the overall performance, generalization ability, and robustness of the model, so that it can more accurately classify and locate pest images.
[0140] S108: Acquire the image to be detected.
[0141] S109: Determine whether the image to be detected contains pests and the specific type of the pests through the pest image recognition model.
[0142] S110: When the image to be detected contains pests, a pest image detail image is segmented from the image to be detected using a pest image segmentation model.
[0143] S111: Using the pest disaster assessment model, assess whether a pest disaster has occurred based on the pest detail images.
[0144] In a possible implementation, the pest identification method based on image analysis further includes:
[0145] S112: Display whether the image to be detected contains pests, the specific types of pests, and the pest disaster assessment result.
[0146] In the present invention, by simultaneously presenting whether there are pests, the specific types of pests, and the pest disaster assessment results in the final display, more comprehensive information is provided, allowing users to understand the pest situation in the image at a glance. Furthermore, by displaying the pest types and pest disaster assessment results in the image to be detected, farmers or agricultural managers can be helped to take necessary countermeasures as soon as possible.
[0147] Compared with the prior art, the present invention has at least the following beneficial technical effects:
[0148] In the present invention, on the basis of using the YOLO algorithm to determine the specific types of pests in the pest image, the Mask R-CNN algorithm is further used to segment the pest detail image from the pest image, and the SVM support vector machine is used to evaluate in real time whether a pest disaster has occurred based on the pest detail image. It can timely and accurately evaluate whether a pest disaster has occurred, and when it is predicted that a pest disaster has occurred or is about to occur, timely and effective countermeasures can be taken to prevent the outbreak of the pest disaster, avoid the further spread of pests in a short period of time, avoid the serious decline in crop yields due to pest disasters, and save farmers' economic losses.
[0149] Example 2
[0150] In one embodiment, the present invention provides an image analysis-based pest identification system, which is used to execute the image analysis-based pest identification method in Example 1.
[0151] The pest identification system based on image analysis provided by the present invention can realize the steps and effects of the pest identification method based on image analysis in the above-mentioned embodiment 1. To avoid repetition, the present invention will not elaborate on them.
[0152] Compared with the prior art, the present invention has at least the following beneficial technical effects:
[0153] In the present invention, on the basis of using the YOLO algorithm to determine the specific types of pests in the pest image, the Mask R-CNN algorithm is further used to segment the pest detail image from the pest image, and the SVM support vector machine is used to evaluate in real time whether a pest disaster has occurred based on the pest detail image. It can timely and accurately evaluate whether a pest disaster has occurred, and when it is predicted that a pest disaster has occurred or is about to occur, timely and effective countermeasures can be taken to prevent the outbreak of the pest disaster, avoid the further spread of pests in a short period of time, avoid the serious decline in crop yields due to pest disasters, and save farmers' economic losses.
[0154] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0155] The above embodiments only express several implementation methods of the present invention, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for those of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present invention, and these all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention shall be subject to the attached claims.
Claims
1. A pest identification method based on image analysis, characterized in that: include: S101: Acquire original pest images of different types for target crops; S102: preprocessing the original pest image; S103: constructing a pest dataset according to the preprocessed pest images; S104: constructing a pest image recognition model based on the YOLO algorithm, so as to determine the specific type of the pest in the pest image through the pest image recognition model; S105: constructing a pest image segmentation model based on the Mask R-CNN algorithm, so as to segment a pest detail image from the pest image through the pest image segmentation model; S106: constructing an insect pest disaster assessment model based on an SVM support vector machine, so as to assess whether an insect pest disaster occurs according to the insect detail image through the insect pest disaster assessment model; S107: training the pest image recognition model, the pest image segmentation model and the pest disaster assessment model using the pest dataset; S108: Acquire the image to be detected; S109: Determine whether the image to be detected contains pests and the specific type of the pests through the pest image recognition model; S110: When the image to be detected contains pests, segmenting a pest detail image from the image to be detected using the pest image segmentation model; S111: using the pest disaster assessment model to assess whether a pest disaster has occurred according to the pest detail image; The S105 specifically includes: S1051: extracting image features from the pest image through a backbone feature extraction network; S1052: Determine a region of interest according to image features; S1053: performing alignment processing on the region of interest; S1054: Segmenting the pest detail image from the region of interest through the segmentation branch in the head; Wherein, the S1052 is specifically: The region of interest is determined from the pest image according to the following formula: ROI={(x,y)|minT≤f(x,y)≤maxT} Wherein, ROI represents a region of interest, which is a set of pixel points whose image feature values are between a minimum threshold and a maximum threshold, minT represents the minimum threshold, maxT represents the maximum threshold, and f(x, y) represents the image feature value at the pixel point (x, y); Wherein, the S1053 specifically includes: S10531: Obtain four pixel points N around the virtual pixel point P in the feature image 11 (x1,y1),N 12 (x1,y2),N 21 (x2,y1),N 22 Image feature value of (x2,y2); S10532: Interpolate the virtual pixel point P in the x direction: Among them, f(x s ,y1) represents the image feature value at the point (xs,y1) after interpolation in the x direction, and f(x1,y1) represents the pixel point N 11 The image feature value at (x1, y1), f(x2, y1) represents the pixel point N 21 Image feature value at (x2,y1); Among them, f(x s ,y2) represents the image feature value at the point (xs,y2) after interpolation in the x direction, and f(x1,y2) represents the pixel point N 12 The image feature value at (x1, y2), f(x2, y2) represents the pixel N 22 Image feature value at (x2,y2); S10533: interpolate the virtual pixel point P in the y direction to calculate the image feature value of the virtual pixel point P: Among them, f(x s ,y s ) represents the virtual pixel point P(x s ,y s ) at the image feature value; S10534: taking the image feature value at the virtual pixel point P in the feature image as the image feature value of the pixel point P' in the aligned target image; Wherein, the S106 specifically includes: S1061: extracting feature vectors of pest detail images of each test sample; S1062: Inputting the feature vector of each pest detail image into a support vector machine; S1063: Construct the objective function minL(ω, b, ξ) of the support vector machine: Among them, ω represents the normal vector of the hyperplane, b represents the offset of the hyperplane, ξ represents the slack variable, ξ i represents the slack variable of the i-th pest detail image, ξ j represents the slack variable of the jth pest detail image. The slack variable ξ is used to handle the inseparable situation. Y represents the input pest disaster assessment result. i represents the pest disaster assessment result of the i-th pest detail image, Y j represents the pest disaster assessment result of the jth pest detail image, K(X i ·X j ) represents the kernel function, which is used to map samples to high-dimensional feature space, indicating that X i With X j The similarity between them, g represents the kernel parameter, X represents the feature vector of the input pest detail image, X i represents the feature vector of the i-th pest detail image, X j represents the feature vector of the jth pest detail image, C represents the penalty factor, and the penalty factor C is used to control the complexity of the model, N represents the number of samples, i = 1, 2, ..., N, j = 1, 2, ..., N; S1064: By searching for the optimal penalty factor and kernel parameter, the normal vector ω, offset b and slack variable ξ of the optimal hyperplane are calculated. Then the optimal hyperplane f(X i ,X j ) can be expressed as: Among them, the sgn() function is used to return the positive or negative value of the independent variable; S1065: Projecting the feature vector of the pest detail image onto the optimal hyperplane; S1066: when the projection of the feature vector of the pest detail image on the optimal hyperplane is located on the first side of the optimal hyperplane, the existence of pest disaster is taken as the pest disaster assessment result; when the projection of the feature vector of the pest detail image on the optimal hyperplane is located on the second side of the optimal hyperplane, the existence of pest disaster is taken as the pest disaster assessment result; Wherein, the S104 specifically includes: S1041: Input the pest image into the CSPDarknet-53 backbone network, wherein the CSPDarknet-53 backbone network includes a CBM component and 5 CSP components, the CBM component includes a Conv convolution layer, a BN batch normalization layer, and a Mish activation function, the CSP component includes a convolution layer and several Resunit modules, and the Resunit module adopts a ResNet residual structure; S1042: In the CBM component, the Conv convolution layer is used to perform a convolution operation using a convolution kernel to extract different features in the pest image; the convolution output is normalized through the BN batch normalization layer; and the Mish activation function is used to introduce nonlinearity to enhance the expression ability of the features; S1043: In the CSP component, a convolution operation is performed on the features using a convolution kernel through the convolution layer; and a ResNet residual structure is used to perform feature processing through the Resunit module; S1044: setting an upsampling layer and an SPP module on each prediction branch, and using the upsampling layer to enlarge the size of the feature map and finely express the local features; using the SPP module to extract features from different scales using a maximum pooling operation to perform feature fusion; S1045: Map the fused features to each possible pest type through the classifier, and use the softmax activation function to output the probability of each category; The training steps of the pest image recognition model are as follows: Construct the loss function of the pest image recognition model: L=λ1L CIOU +λ2L cls +λ3L conf Wherein, L represents the loss function of the pest image recognition model, L CIOU represents the bounding box loss function, λ1 represents the weight of the bounding box loss function, and L cls represents the cross entropy loss function, λ2 represents the weight of the cross entropy loss function, L conf represents the confidence loss function, λ3 represents the weight of the confidence loss function; Among them, the bounding box loss function L CIOU Specifically: d 2 =ρ 2 (b,b gt ) Among them, IOU represents the intersection-over-union ratio of the predicted box and the true box, d represents the Euclidean distance between the center points of the predicted box and the true box, c represents the diagonal length of the minimum closure between the true box and the predicted box, α represents the trade-off parameter, v represents the consistency parameter, ρ() represents the center point Euclidean distance calculation function, b represents the predicted box, b gt represents the real box, w gt Indicates the width of the real box, h gt represents the height of the real box, w represents the width of the predicted box, and h represents the height of the predicted box; Among them, the cross entropy loss function L cls Specifically: Where m represents the number of samples, i = 1, 2, ..., m, S represents the number of categories, j = 1, 2, ..., S, p ij Indicates the classification of the i-th sample belonging to the j-th category. When the i-th sample belongs to the j-th category, p ij =1, otherwise, p ij =0,q ij Indicates the predicted probability that the i-th sample belongs to the j-th category; Among them, the confidence loss function L conf Specifically: Where m represents the number of samples, i = 1, 2, ..., m, S represents the number of categories, j = 1, 2, ..., S, q ij represents the predicted probability that the i-th sample belongs to the j-th category, β represents the hyperparameter for balancing the number of positive and negative samples, and γ represents the hyperparameter for balancing the prediction accuracy of positive and negative samples; The pest image recognition model is trained with the goal of minimizing the loss function.
2. The method for identifying pests based on image analysis according to claim 1, characterized in that: The S102 specifically includes: S1021: Rotate the original pest image according to the offset angle of the original pest image: Among them, (x0, y0) represents the coordinates of the pixel before rotation, (x t ,y t ) represents the coordinates of the pixel after rotation, and θ represents the offset angle; S1022: Filter and reduce noise on the rotated pest image according to the following formula: Among them, f m (x, y) represents the pixel value after filtering and denoising at the pixel point (x, y), x represents the horizontal coordinate of the pixel point, y represents the vertical coordinate of the pixel point, σ represents the standard deviation of the pixel value in the neighborhood, and e represents the natural logarithm; S1023: Brightness equalization is performed on the pest image after noise reduction filtering according to the following formula: I out =255c·F γ γ=log2(mF m ) Among them, I out Indicates the brightness value after brightness equalization processing, I in represents the brightness value before brightness equalization processing, c represents the proportional coefficient, F represents the normalized brightness value, γ represents the gamma correction index, and F m represents the median value of the brightness before brightness equalization processing, m represents the target brightness mean, and m can be obtained in the following way: in, represents the mean of the brightness values before brightness equalization processing, and round(·) represents the rounding function.
3. The method for identifying pests based on image analysis according to claim 1, characterized in that: Also includes: S112: Display whether the image to be detected contains pests, the specific types of pests, and the pest disaster assessment result.
4. An insect pest identification system based on image analysis, characterized in that: Used to execute the pest identification method based on image analysis according to any one of claims 1 to 3.
Citation Information
Patent Citations
Corn disease grading method and system and computer equipment
CN111553240A
Field wheat scab occurrence degree evaluation method based on improved YloV4
CN114120203A
Wheat stripe rust severity assessment method based on supervised learning
CN114997300A
Agricultural pest model construction method, agricultural pest model detection method and agricultural pest model detection device
CN115578624A