Method for detecting grain insect damage area, detection device and storage medium

By using semantic segmentation models and multi-scale feature fusion technology, the accuracy problem of detecting insect-infested areas in sorghum grains was solved, enabling rapid and accurate detection of insect-infested areas in grains.

CN117853787BActive Publication Date: 2026-11-24KWEICHOW MOUTAI COMPANY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311762347.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-20
Publication Date
2026-11-24
Estimated Expiration
2043-12-20

AI Technical Summary

Technical Problem

Existing technologies are insufficient for quickly and accurately identifying and segmenting insect-damaged areas in sorghum grains, making precise detection impossible.

Method used

A semantic segmentation model is adopted, which generates the first probability and the second probability of grain image through image processing sub-model and segmentation map generation sub-model, respectively representing the probability of a pixel being a grain area and an insect-damaged area. Combined with multi-scale feature fusion technology, accurate detection of insect-damaged areas of grain is achieved.

Benefits of technology

It enables precise detection of grain insect-damaged areas, improves detection accuracy and efficiency, reduces information loss, and lowers the number of model parameters.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117853787B_ABST
    Figure CN117853787B_ABST
Patent Text Reader

Abstract

The application provides a grain insect-eaten area detection method, a detection device and a storage medium. A grain image to be detected can be obtained, the grain image is input into a preset semantic segmentation model, first probabilities and second probabilities corresponding to each pixel point in the grain image are obtained, the first probability represents a probability that the pixel point is a point in a grain area, and the second probability represents a probability that the pixel point is a point in an insect-eaten area. According to the first probability and the second probability corresponding to each pixel point, a grain insect-eaten area is determined from the grain image, that is, a specific insect-eaten area can be detected from the grain, and accurate detection of the insect-eaten area in the grain is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image processing technology, and in particular to a method, detection equipment and storage medium for detecting insect-damaged areas of grain. Background Technology

[0002] Sorghum is an important crop; however, sorghum grains are susceptible to insect damage, affecting yield and quality. Therefore, quickly and accurately identifying and segmenting insect-infested areas is crucial for precise pest control. Because sorghum grains are small, the target areas of insect infestation are even more difficult to discern.

[0003] While there are some studies on sorghum detection in the existing technology, there are not many studies on using deep learning to detect insect-infested areas in sorghum. Most sorghum insect-infestation detection uses image classification algorithms based on deep learning. This method can only detect whether the sorghum is infested by insects, but cannot determine the specific location of the infested area, and cannot achieve accurate detection. Summary of the Invention

[0004] The purpose of this application is to provide a method, equipment, and storage medium for detecting insect-damaged areas in grain, in order to solve the above-mentioned technical problems.

[0005] On the one hand, a method for detecting grain insect-damaged areas is provided, the method comprising:

[0006] Acquire images of the grain to be inspected;

[0007] The grain image is input into a preset semantic segmentation model to obtain a first probability and a second probability corresponding to each pixel in the grain image; the first probability represents the probability that the pixel is a point in the grain region, and the second probability represents the probability that the pixel is a point in the insect-eaten region.

[0008] Based on the first probability and the second probability corresponding to each pixel, the grain insect-damaged area is determined from the grain image.

[0009] In one embodiment, the semantic segmentation model includes an image processing sub-model, a first segmentation map generation sub-model, and a second segmentation map generation sub-model; the step of inputting the grain image into the preset semantic segmentation model to obtain the first probability and the second probability corresponding to each pixel in the grain image includes:

[0010] The image processing sub-model generates a first feature image and a second feature image based on the grain image, and inputs the first feature image and the second feature image into the first segmentation image generation sub-model and the second segmentation image generation sub-model, respectively.

[0011] The first segmentation image generation sub-model generates a first segmentation image with the same size as the grain image based on the first feature image, and determines the first probability of the corresponding pixel in the grain image based on the first pixel value of each first pixel in the first segmentation image;

[0012] The second segmentation image generation sub-model generates a second segmentation image with the same size as the grain image based on the second feature image, and determines the second probability of the corresponding pixel in the grain image based on the second pixel value of each second pixel in the second segmentation image.

[0013] In one embodiment, the image processing sub-model generates a first feature image and a second feature image based on the grain image, including:

[0014] The image processing sub-model performs a convolution operation on the grain image for each channel to obtain a first convolutional processed feature image.

[0015] The first convolutional feature image is subjected to pooling processing to obtain the first pooling feature image;

[0016] The first pooling feature image is upsampled to obtain the first upsampled feature image.

[0017] The first upsampled feature image is fused with the grain image to obtain a first fused feature image corresponding to the channel.

[0018] The first fused feature image with 2c channels is separated into two parts according to the channel dimension to obtain a first feature image with c channels and a second feature image with c channels.

[0019] In one embodiment, the first segmentation image generation sub-model generates a first segmentation image with the same size as the grain image based on the first feature image, including:

[0020] The first segmentation image generation sub-model performs a convolution operation on the first feature image to obtain a second convolution-processed feature image.

[0021] The second convolutional feature image is upsampled to obtain a first segmented image with the same size as the grain image.

[0022] In one embodiment, the second segmentation image generation sub-model generates a second segmentation image with the same size as the grain image based on the second feature image, including:

[0023] The second segmentation image generation sub-model performs convolution operations on the second feature image according to different dilation rates to obtain a third convolutional feature image, and performs pooling operations on the second feature image to obtain a second pooling feature image.

[0024] The SE module is used to perform feature enhancement processing on the third convolutional feature image and the second pooling feature image respectively to obtain an enhanced feature image;

[0025] The enhanced feature image and the second feature image are fused to obtain the second fused feature image;

[0026] The second fused feature image is processed by convolution to obtain the fourth convolution-processed feature image.

[0027] The fourth convolutional feature image is upsampled to obtain a second segmentation image with the same size as the grain image.

[0028] In one embodiment, before inputting the grain image into a preset semantic segmentation model, the method includes:

[0029] Obtain a training dataset; the training dataset includes multiple grain sample images, and a first label and a second label for each sample pixel in each grain sample image; the first label is used to indicate whether the corresponding sample pixel is a point in a grain region or a point in a non-grain region; the second label is used to indicate whether the corresponding sample pixel is a point in an insect-eaten region or a point in a non-insect-eaten region.

[0030] The grain sample image is input into a preset initial semantic segmentation model to obtain the first sample probability and the second sample probability corresponding to each pixel in the grain sample image; the first sample probability represents the probability that the sample pixel is a point in the grain region, and the second sample probability represents the probability that the sample pixel is a point in the insect-eaten region.

[0031] A first loss value is calculated based on the first sample probability and the first label corresponding to each sample pixel in the grain sample image, and a second loss value is calculated based on the second sample probability and the second label corresponding to each sample pixel in the grain sample image.

[0032] Calculate the total loss of the initial semantic segmentation model based on the first loss value and the second loss value;

[0033] The initial semantic segmentation model is optimized based on the total loss to obtain the semantic segmentation model.

[0034] In one embodiment, the method further includes:

[0035] Based on the first probability and the second probability corresponding to each pixel, non-insect-damaged areas and non-grain areas are determined from the grain image.

[0036] In one embodiment, determining the grain insect-damaged area from the grain image based on the first probability and the second probability corresponding to each pixel includes:

[0037] When the first probability of a certain pixel is greater than a preset first probability threshold, and the second probability of the pixel is greater than a preset second probability threshold, the pixel is determined to be a point in the grain insect-eaten area.

[0038] The step of determining the non-insect-damaged grain region and the non-grain region from the grain image based on the first probability and the second probability corresponding to each pixel includes:

[0039] When the first probability of a certain pixel is greater than a preset first probability threshold, and the second probability of the pixel is less than or equal to a preset second probability threshold, the pixel is determined to be a point in the non-insect-damaged area of ​​the grain.

[0040] When the first probability of a certain pixel is less than or equal to a preset first probability threshold, and the second probability of the pixel is less than or equal to a preset second probability threshold, the pixel is determined to be a point in a non-grain area.

[0041] On the other hand, a detection device is provided, including a processor and a memory, wherein the memory stores a computer program, and the processor executes the computer program to implement any of the methods described above.

[0042] On the other hand, a computer-readable storage medium is provided, characterized in that the computer-readable storage medium stores a computer program, which, when executed by at least one processor, implements any of the methods described above.

[0043] The grain insect-damaged area detection method, detection equipment, and storage medium provided in this application can acquire an image of the grain to be detected, input the grain image into a preset semantic segmentation model, and obtain a first probability and a second probability corresponding to each pixel in the grain image. The first probability represents the probability that the pixel is a point in the grain area, and the second probability represents the probability that the pixel is a point in the insect-damaged area. Based on the first probability and the second probability corresponding to each pixel, the grain insect-damaged area can be determined from the grain image. That is, a specific insect-damaged area can be detected from the grain, realizing the accurate detection of insect-damaged areas in grain. Attached Figure Description

[0044] Figure 1 This is a flowchart illustrating the grain insect-damaged area detection method provided in Embodiment 1 of this application;

[0045] Figure 2 This is a partial structural diagram of the semantic segmentation model provided in Embodiment 1 of this application;

[0046] Figure 3 This is a partial structural schematic diagram of the second segmentation map generation sub-model provided in Embodiment 1 of this application;

[0047] Figure 4 This is a schematic diagram of the SE module provided in Embodiment 1 of this application;

[0048] Figure 5 A schematic diagram of a grain image provided in Embodiment 1 of this application;

[0049] Figure 6 A schematic diagram of the first segmented image provided in Embodiment 1 of this application;

[0050] Figure 7 A schematic diagram of the second segmented image provided in Embodiment 1 of this application;

[0051] Figure 8 This is a schematic diagram of the detection device provided in Embodiment 2 of this application. Detailed Implementation

[0052] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0053] Example 1:

[0054] This application provides a method for detecting grain insect-damaged areas. This method is based on a semantic segmentation model. The task of semantic segmentation is to classify all pixels in an image into their respective categories, thereby enabling deeper analysis and understanding of the image. It mainly utilizes an encoder-decoder structure. The encoder can use convolutional neural networks and downsampling to reduce resolution and extract image feature maps, while the decoder can transform the low-resolution image and feature maps into segmented images, thereby achieving pixel-level prediction.

[0055] Specifically, please see Figure 1 As shown in the embodiments of this application, the method for detecting grain insect-damaged areas may include the following steps:

[0056] S11: Obtain the image of the grain to be detected.

[0057] S12: Input the grain image into the preset semantic segmentation model to obtain the first probability and the second probability corresponding to each pixel in the grain image; the first probability represents the probability that the pixel is a point in the grain region, and the second probability represents the probability that the pixel is a point in the insect-eaten region.

[0058] S13: Determine the grain insect-damaged area from the grain image based on the first probability and the second probability corresponding to each pixel.

[0059] In step S11, an image of the grain to be detected can be acquired using a camera device to obtain an image of the grain to be detected. In some embodiments, the image acquired by the camera device can be directly input into a preset semantic segmentation model as the image of the grain to be detected. In other embodiments, the image acquired by the camera device can be preprocessed, for example, the pixel values ​​of each pixel in the image can be divided by 255 for normalization, and then the normalized image can be input into the preset semantic segmentation model as the image of the grain to be detected.

[0060] It should be noted that the grain in the embodiments of this application can be sorghum, or other types of grain such as barley and rice, and in particular, it can be a grain-type grain.

[0061] In step S12, the grain image is input into a preset semantic segmentation model to obtain a first probability and a second probability corresponding to each pixel in the grain image. That is, for each pixel in the grain image, its corresponding first probability and second probability can be obtained.

[0062] The semantic segmentation model in this application embodiment can be a trained model, which may include an image processing sub-model, a first segmentation map generation sub-model, and a second segmentation map generation sub-model.

[0063] In step S12, the image processing sub-model generates a first feature image and a second feature image based on the grain image, and inputs the first feature image and the second feature image into the first segmentation image generation sub-model and the second segmentation image generation sub-model, respectively; the first segmentation image generation sub-model generates a first segmentation image with the same size as the grain image based on the first feature image, and determines the first probability of the corresponding pixel in the grain image based on the first pixel value of each first pixel in the first segmentation image; the second segmentation image generation sub-model generates a second segmentation image with the same size as the grain image based on the second feature image, and determines the second probability of the corresponding pixel in the grain image based on the second pixel value of each second pixel in the second segmentation image.

[0064] The image processing sub-model can generate a corresponding first fused feature image for each channel. Specifically, for each channel of the image processing sub-model, it can perform convolution operation on the grain image to obtain a first convolutional feature image, then perform pooling operation on the first convolutional feature image to obtain a first pooling feature image, then perform upsampling operation on the first pooling feature image to obtain a first upsampled feature image, and then fuse the first upsampled feature image with the grain image to obtain a first fused feature image corresponding to that channel. The first fused feature image with 2c channels is separated into two parts according to the channel dimension to obtain a first feature image with c channels and a second feature image with c channels. That is, 2c represents the total number of channels of the image processing sub-model.

[0065] This section explains the process of fusing the first upsampled feature image with the grain image to obtain the first fused feature image corresponding to the output channel.

[0066] The first upsampled feature image has the same size as the grain image. Feature fusion of the first upsampled feature image and the grain image can be achieved by concatenating the first upsampled feature image with the grain image along the channel dimension, thereby obtaining a fused image. In some embodiments, the image processing sub-model can directly output this fused image as the first fused feature image. For other embodiments, please refer to... Figure 2 As shown, the fused image can be used as the first layer image. This first layer image is then fused with the second layer image. The newly fused third layer image is output as the first fused feature image of the image processing sub-model. The second layer image can be obtained by sequentially performing convolution, pooling, and upsampling operations on the first pooling feature image. It should be noted that the image processing sub-model can have more convolutional layers, pooling layers, and upsampling layers to sequentially perform convolution, pooling, and upsampling operations on the second layer image to obtain a fourth layer image. Then, the third and fourth layer images are fused to obtain a fifth layer image. The newly fused fifth layer image is output as the first fused feature image of the image processing sub-model. It is understood that in some other embodiments, the above structure can be used to continue sequentially performing convolution, pooling, and upsampling operations on the fourth layer image, and then the processing result can be fused with the fifth layer image to obtain the first fused feature image of the image processing sub-model. Figure 2 The 'f' in the equation will not be elaborated upon here.

[0067] Taking the size of the grain image input to the image processing sub-model as H×W as an example, the image processing sub-model can use a 3×3 convolution kernel for convolution processing during the convolution process. The pooling operation in the input image processing sub-model can be max pooling, which finally yields a first fused feature image with 2c channels and a size of H×W. These first fused feature images are then separated into two parts according to the channel dimension, resulting in a first feature image f1 with c channels and a size of H×W and a second feature image f2 with c channels and a size of H×W.

[0068] The first feature image with c channels is input into the first segmentation image generation sub-model to obtain a first segmentation image with the same size as the grain image. The first segmentation image generation sub-model can perform a convolution operation on the first feature image to obtain a second convolutionally processed feature image, and then upsample the second convolutionally processed feature image to obtain the first segmentation image with the same size as the grain image. Figure 2 B in the middle.

[0069] Specifically, the first segmentation image generation sub-model can perform convolution operations on the first feature images with c channels respectively to obtain several second convolution processed feature images. Then, each second convolution processed feature image is upsampled to obtain several second upsampled processed feature images. Finally, these second upsampled processed feature images are fused to obtain a first segmentation image with the same size as the grain image.

[0070] The second feature image with c channels is input into the second segmentation image generation sub-model to obtain a second segmentation image with the same size as the grain image. The second segmentation image generation sub-model can perform convolution operations on the second feature image according to different dilation rates to obtain a third convolutional feature image, and then perform pooling operations on the second feature image to obtain a second pooling feature image. The SE module then performs feature enhancement processing on the third convolutional feature image and the second pooling feature image respectively to obtain enhanced feature images. The enhanced feature image and the second feature image are then fused to obtain a second fused feature image. The second fused feature image is then convolutionally processed to obtain a fourth convolutional feature image. Finally, the fourth convolutional feature image is upsampled to obtain the second segmentation image with the same size as the grain image. Figure 2 S in the middle.

[0071] For example, please see Figure 3As shown, for each second feature image, four convolution operations and one global average pooling are performed. Then, each feature enters the SE module for feature enhancement, resulting in five enhanced feature images. These five enhanced feature images are then fused with the second feature image to obtain a second fused feature image. The second fused feature image is then subjected to a convolution operation to obtain a fourth convolutional feature image. The fourth convolutional feature image is then upsampled to obtain a second segmentation image with the same size as the grain image.

[0072] Figure 3 The convolution process was performed using convolution kernels with dilatation rates of 1, 2, 4, and 8, respectively. It is understood that convolution kernels with other dilatation rates can also be used in other embodiments.

[0073] The following describes the feature enhancement process performed by the SE module. Please refer to [link / reference]. Figure 4 As shown, for each feature image input to the SE module, the SE module first performs Global Average Pooling on the input features. The feature images here include the feature images processed by the third convolution and the second pooling of the input SE module. Global average pooling means that the a×b features can be averaged to 1×1. Then, two fully connected layers are connected and a sigmoid function is added. After that, it is multiplied with the feature image input to the SE module, and the result of the multiplication is used as the output of the SE module, that is, the result of the multiplication is used as the enhanced feature image for output.

[0074] It should be noted that in this embodiment, the first pixel value of each first pixel in the first segmented image can be normalized using the Sigmoid function, and the result of the normalization process is used as the first probability of the corresponding pixel in the grain image. Sigmoid(x1) = 1 / (1+e -x1 x1 represents the first pixel value of a certain first pixel point in the first segmented image, and Sigmoid(x1) represents the first probability of the corresponding pixel point in the grain image.

[0075] Similarly, the second probability of a corresponding pixel in the grain image can be determined based on the Sigmoid function and the second pixel value of each second pixel in the second segmented image. Sigmoid(x2) = 1 / (1+e^(x2)) -x2 x2 represents the second pixel value of a certain second pixel point in the second segmented image, and Sigmoid(x2) represents the second probability of the corresponding pixel point in the grain image.

[0076] The process of training the semantic segmentation model is described below. In this embodiment, the obtained training dataset can be input into a preset initial semantic segmentation model for training to obtain the semantic segmentation model. Specifically, before step S12, the following steps can be performed:

[0077] Step 1: Obtain the training dataset; the training dataset includes multiple grain sample images, and a first label and a second label for each sample pixel in each grain sample image; the first label is used to indicate whether the corresponding sample pixel is a point in the grain region or a point in the non-grain region; the second label is used to indicate whether the corresponding sample pixel is a point in the insect-eaten region or a point in the non-insect-eaten region.

[0078] The grain sample images in this embodiment can be pre-processed images. Specifically, the grain sample images can be acquired by a camera device to obtain sample images, and then the pixel values ​​of each pixel in the sample image are divided by 255 for normalization processing to obtain the grain sample images.

[0079] Step 2: Input the grain sample image into a preset initial semantic segmentation model to obtain the first sample probability and the second sample probability corresponding to each pixel in the grain sample image; the first sample probability represents the probability that the sample pixel is a point in the grain region, and the second sample probability represents the probability that the sample pixel is a point in the insect-eaten region.

[0080] Step 3: Calculate the first loss value based on the first sample probability and the first label corresponding to each sample pixel in the grain sample image, and calculate the second loss value based on the second sample probability and the second label corresponding to each sample pixel in the grain sample image.

[0081] Step 4: Calculate the total loss of the initial semantic segmentation model based on the first loss value and the second loss value.

[0082] The initial semantic segmentation model comprises the aforementioned image processing sub-model, the first segmentation map generation sub-model, and the second segmentation map generation sub-model. Assuming the first segmentation map generation sub-model outputs a first segmentation image B for a given grain sample image, image B, after being processed by the Sigmoid function, can be combined with the first label in the grain sample image to calculate the first loss value BCELoss_B. Assuming the second segmentation map generation sub-model outputs a second segmentation image S for a given grain sample image, image S, after being processed by the Sigmoid function, can be combined with the second label in the grain sample image to calculate the second loss value BCELoss_S. The first and second loss values ​​are added together to obtain the final total loss. Finally, backpropagation is used to update the parameter weights.

[0083] In this embodiment of the application, for each sample pixel of the grain sample image, its corresponding first loss value and second loss value can be calculated using the following formula:

[0084] BCELoss(p,y)=-y*log(p)-(1-y)log(1-p);

[0085] Where p represents the predicted value output by the initial semantic segmentation model, such as the first or second sample probability of a certain sample pixel, and y represents the corresponding label value.

[0086] Step 5: Optimize the initial semantic segmentation model based on the total loss to obtain the semantic segmentation model.

[0087] In practical applications, the non-insect-damaged areas and non-grain areas of grain can also be determined from the grain image based on the first probability and the second probability corresponding to each pixel.

[0088] For example, when the first probability of a pixel in a grain image is greater than a preset first probability threshold, and the second probability of the pixel is greater than a preset second probability threshold, the pixel is identified as a point in the grain insect-eaten area.

[0089] When the first probability of a pixel in a grain image is greater than a preset first probability threshold, and the second probability of the pixel is less than or equal to a preset second probability threshold, the pixel is identified as a point in the non-insect-damaged area of ​​the grain.

[0090] When the first probability of a pixel in a grain image is less than or equal to a preset first probability threshold, and the second probability of the pixel is less than or equal to a preset second probability threshold, the pixel is determined to be a point in a non-grain region.

[0091] The set of points in all grain insect-damaged areas constitutes the grain insect-damaged areas in the grain image; the set of points in all grain non-insect-damaged areas constitutes the grain non-insect-damaged areas in the grain image; and the set of points in all non-grain areas constitutes the non-grain areas in the grain image.

[0092] In this application embodiment, the specific values ​​of the preset first probability threshold and the preset second probability threshold can be flexibly set by the developer, for example, both can be set to 0.5.

[0093] Taking a preset first probability threshold and a preset second probability threshold of 0.5 as an example, for the first segmented image, if the first probability corresponding to a certain pixel is greater than 0.5, then the pixel is assigned to the foreground category, that is, a point in the grain region; otherwise, it is assigned to the background category, that is, a point in the non-grain region. For the second segmented image, if the second probability corresponding to a certain pixel is greater than 0.5, then the pixel is assigned to the foreground category, that is, a point in the insect-eaten region; otherwise, it is assigned to the background category, that is, a point in the non-insect-eaten region.

[0094] Let R(H×W) be the final target segmented image, that is, the image that distinguishes between areas of grain damaged by insects, areas of grain not damaged by insects, and areas of non-grain. B(H×W) and S(H×W) are the first and second segmented images output by the semantic segmentation model, respectively. Please refer to [link to relevant documentation]. Figure 5 As shown, Figure 5 For grain images, Figure 6 This is the first segmented image of the grain image. Figure 7 This is the second segmented image of the grain image. The target segmented image can be obtained based on the first and second segmented images. i represents the horizontal coordinate, and j represents the vertical coordinate. The categories represented by pixels R(i,j) are shown in Table 1 below:

[0095] Table 1

[0096]

[0097] For example, we can first determine whether S(i,j) is a foreground category. If so, we can determine that this area is a worm-eaten category.

[0098] Otherwise, determine whether B(i,j) is a foreground category. If it is, then determine that this area is a non-insect-damaged grain category.

[0099] Otherwise, this area is determined to be a background area.

[0100] The grain insect-damaged area detection method provided in this application employs multi-scale feature fusion technology, splicing deep and shallow features to reduce information loss and balance global information with local details. A feature is divided into two feature layers: one part is directly used to extract large target features of the grain, while the other part needs to be extracted as small target features of the insect-damaged area through the SE module. This solves the problem of difficult small target extraction and reduces the number of parameters. Simultaneously, the loss values ​​of the large and small targets are calculated, and the sum of these losses is used as the final loss value. Therefore, both grain segmentation and insect-damaged segmentation results are good. By judging the two binary classification outputs of the model, a three-category segmentation map is obtained: insect-damaged, non-insect-damaged grain, and background, which improves the model's segmentation performance to a certain extent. The model provided in this application has a small number of parameters and memory usage, and its detection is fast.

[0101] It should be understood that although the steps in the flowchart above are shown sequentially as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowchart above may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.

[0102] Example 2:

[0103] This application also provides a detection device; please refer to [link to relevant documentation]. Figure 8 As shown, it includes a processor 801 and a memory 802. The memory 802 stores a computer program. The processor 801 and the memory 802 communicate through a communication bus. The processor 801 executes the computer program to implement the steps of the method described above, which will not be repeated here.

[0104] It should be noted that the detection device in this application embodiment can be a terminal or a server. The terminal can be a smartphone, tablet, laptop, personal computer (PC), smart home device, wearable electronic device, VR / AR device, in-vehicle computer, etc. The server can be an interconnection server between multiple heterogeneous systems or a backend server, or it can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, and big data and artificial intelligence platforms, etc.

[0105] The processor 801 can be an integrated circuit chip with signal processing capabilities. The processor 801 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), an off-the-shelf programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor.

[0106] The memory 802 may include, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable read-only memory (EPROM), electrically erasable read-only memory (EEPROM), etc.

[0107] This embodiment also provides a computer-readable storage medium, such as a floppy disk, optical disk, hard disk, flash memory, USB flash drive, SD card, MMC card, etc., in which one or more programs implementing the above steps are stored. These one or more programs can be executed by one or more processors to implement the steps of the method in the first embodiment above, which will not be described again here.

[0108] It should be noted that the illustrations provided in this embodiment are only schematic representations of the basic concept of the present invention. Therefore, the drawings only show components relevant to the present invention and are not drawn according to the actual number, shape, and size of components in implementation. In actual implementation, the form, quantity, and proportion of each component can be arbitrarily changed, and the component layout may be more complex. The structures, proportions, sizes, etc., depicted in the accompanying drawings are only for illustrative purposes to aid those skilled in the art and are not intended to limit the implementation conditions of the present invention. Therefore, they have no substantial technical significance. Any modifications to the structure, changes in proportions, or adjustments to size, without affecting the effects and objectives of the present invention, should still fall within the scope of the technical content disclosed in the present invention. Furthermore, the terms such as "upper," "lower," "left," "right," "middle," and "one" used in this specification are only for clarity of description and are not intended to limit the scope of the present invention. Changes or adjustments to their relative relationships, without substantially altering the technical content, should also be considered within the scope of the present invention.

[0109] The technical features of the above embodiments can be combined in any way. For the sake of brevity, 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.

[0110] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.

Claims

1. A method for detecting insect-damaged areas in grain, characterized in that, include: Acquire images of the grain to be inspected; The grain image is input into a preset semantic segmentation model to obtain a first probability and a second probability corresponding to each pixel in the grain image; the first probability represents the probability that the pixel is a point in the grain region, and the second probability represents the probability that the pixel is a point in the insect-eaten region. Based on the first probability and the second probability corresponding to each pixel, the grain insect-damaged area is determined from the grain image; based on the first probability and the second probability corresponding to each pixel, the grain non-insect-damaged area and the non-grain area are determined from the grain image. The semantic segmentation model includes an image processing sub-model, a first segmentation image generation sub-model, and a second segmentation image generation sub-model. The step of inputting the grain image into the preset semantic segmentation model to obtain a first probability and a second probability corresponding to each pixel in the grain image includes: the image processing sub-model generating a first feature image and a second feature image based on the grain image, and inputting the first feature image into the first segmentation image generation sub-model and the second feature image into the second segmentation image generation sub-model; the first segmentation image generation sub-model generating a first segmentation image with the same size as the grain image based on the first feature image, and determining the first probability of the corresponding pixel in the grain image based on the first pixel value of each first pixel in the first segmentation image; the second segmentation image generation sub-model generating a second segmentation image with the same size as the grain image based on the second feature image, and determining the second probability of the corresponding pixel in the grain image based on the second pixel value of each second pixel in the second segmentation image. The image processing sub-model generates a first feature image and a second feature image based on the grain image, including: the image processing sub-model processes each channel to obtain a first fused feature image corresponding to the channel; the first fused feature image with 2c channels is separated into two parts according to the channel dimension to obtain a first feature image with c channels and a second feature image with c channels; The step of determining the grain insect-damaged area from the grain image based on the first probability and the second probability corresponding to each pixel includes: when the first probability of a certain pixel is greater than a preset first probability threshold and the second probability of the pixel is greater than a preset second probability threshold, the pixel is determined as a point in the grain insect-damaged area. The step of determining the non-insect-damaged grain region and the non-grain region from the grain image based on the first probability and the second probability corresponding to each pixel includes: when the first probability of a certain pixel is greater than a preset first probability threshold and the second probability of the pixel is less than or equal to a preset second probability threshold, the pixel is determined as a point in the non-insect-damaged grain region; when the first probability of a certain pixel is less than or equal to the preset first probability threshold and the second probability of the pixel is less than or equal to the preset second probability threshold, the pixel is determined as a point in the non-grain region.

2. The method for detecting grain insect-damaged areas as described in claim 1, characterized in that, The image processing sub-model processes each channel to obtain a first fused feature image corresponding to the channel, including: The image processing sub-model performs a convolution operation on the grain image for each channel to obtain a first convolutional processed feature image. The first convolutional feature image is subjected to pooling processing to obtain the first pooling feature image; The first pooling feature image is upsampled to obtain the first upsampled feature image. The first upsampled feature image is fused with the grain image to obtain a first fused feature image corresponding to the channel.

3. The method for detecting grain insect-damaged areas as described in claim 1, characterized in that, The first segmentation image generation sub-model generates a first segmentation image with the same size as the grain image based on the first feature image, including: The first segmentation image generation sub-model performs a convolution operation on the first feature image to obtain a second convolution-processed feature image. The second convolutional feature image is upsampled to obtain a first segmented image with the same size as the grain image.

4. The method for detecting grain insect-damaged areas as described in claim 1, characterized in that, The second segmentation image generation sub-model generates a second segmentation image with the same size as the grain image based on the second feature image, including: The second segmentation image generation sub-model performs convolution operations on the second feature image according to different dilation rates to obtain a third convolutional feature image, and performs pooling operations on the second feature image to obtain a second pooling feature image. The SE module is used to perform feature enhancement processing on the third convolutional feature image and the second pooling feature image respectively to obtain an enhanced feature image; The enhanced feature image and the second feature image are fused to obtain the second fused feature image; The second fused feature image is processed by convolution to obtain the fourth convolution-processed feature image. The fourth convolutional feature image is upsampled to obtain a second segmentation image with the same size as the grain image.

5. The method for detecting grain insect-damaged areas as described in claim 1, characterized in that, Before inputting the grain image into a preset semantic segmentation model, the method includes: Obtain a training dataset; the training dataset includes multiple grain sample images, and a first label and a second label for each sample pixel in each grain sample image; the first label is used to indicate whether the corresponding sample pixel is a point in a grain region or a point in a non-grain region; the second label is used to indicate whether the corresponding sample pixel is a point in an insect-eaten region or a point in a non-insect-eaten region. The grain sample image is input into a preset initial semantic segmentation model to obtain the first sample probability and the second sample probability corresponding to each pixel in the grain sample image; the first sample probability represents the probability that the sample pixel is a point in the grain region, and the second sample probability represents the probability that the sample pixel is a point in the insect-eaten region. A first loss value is calculated based on the first sample probability and the first label corresponding to each sample pixel in the grain sample image, and a second loss value is calculated based on the second sample probability and the second label corresponding to each sample pixel in the grain sample image. Calculate the total loss of the initial semantic segmentation model based on the first loss value and the second loss value; The initial semantic segmentation model is optimized based on the total loss to obtain the semantic segmentation model.

6. A testing device, characterized in that, It includes a processor and a memory, wherein the memory stores a computer program, and the processor executes the computer program to implement the method as described in any one of claims 1-5.

7. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by at least one processor, implements the method as described in any one of claims 1-5.

Citation Information

Patent Citations

  • Apparatus and method for lesions segmentation

    US10115197B1

  • Model training method and device, and defect detection method and device

    WO2020211823A1