Rice quality detection method, device, equipment and storage medium

By using a single-stage target detection network based on non-anchor boxes to extract multi-dimensional features from rice images, the problem of long detection time and low efficiency in existing rice detection methods is solved, and fast and efficient multi-grain rice quality detection is achieved.

CN116958095BActive Publication Date: 2026-01-09WUHAN POLYTECHNIC UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310924470.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-07-24
Publication Date
2026-01-09
Estimated Expiration
2043-07-24

AI Technical Summary

Technical Problem

Existing rice testing methods are time-consuming and inefficient, mainly focusing on the quality testing of individual grains of rice, and feature extraction relies on manual labor.

Method used

A single-stage target detection network based on non-anchor boxes is used to extract multi-dimensional features from rice images, including a pre-set convolution module, a feature extraction module, and a feature fusion module. The rice quality detection results are output through a pre-set detection head.

Benefits of technology

It reduces network complexity, decreases the number of parameters, increases detection speed, enables simultaneous detection of multiple grains of rice, and improves detection efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116958095B_ABST
    Figure CN116958095B_ABST
Patent Text Reader

Abstract

The application discloses a rice quality detection method, device and equipment and a storage medium. The method comprises the following steps: preprocessing a source rice image to obtain a target rice image, and a plurality of quantities of rice are present in the target rice image; performing multi-dimensional feature extraction on the target rice image through a preset feature detection network to obtain multi-dimensional rice features corresponding to the plurality of quantities of rice, wherein the preset feature detection network is a single-stage target detection network based on a non-anchor box; and inputting the multi-dimensional rice features into a preset detection head, so that the preset detection head outputs a rice quality detection result. The preset feature detection network is a single-stage target detection algorithm based on a non-anchor box, so that an anchor box of different sizes does not need to be designed in advance for a target to extract features, thereby reducing the parameter quantity and detection time. In addition, the application can simultaneously detect a plurality of rice images, so that the detection speed and efficiency can be further improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of electronic digital data processing, and in particular to a rice quality detection method, device, equipment and storage medium. BACKGROUND

[0002] In recent years, with the rapid development of deep learning, deep neural networks are gradually applied to grain detection. Nowadays, neural networks such as Probabilistic Neural Network (PNN), deep Convolutional Neural Networks (CNN) or lightweight semantic segmentation network (Enet) can be used for rice quality detection.

[0003] However, the extraction of features and the setting of extraction rules in the above method are all dependent on manual operation, and mainly focus on the detection of the quality of single rice grains. Therefore, the existing rice detection method is time-consuming and inefficient.

[0004] The above content is only used to assist in understanding the technical solutions of the present application and does not represent the acknowledgement of the above content as prior art. SUMMARY

[0005] The main purpose of the present application is to provide a rice quality detection method, device, equipment and storage medium, which aims to solve the technical problems of time-consuming and low efficiency of the existing rice detection method.

[0006] To achieve the above purpose, the present application provides a rice quality detection method, which comprises:

[0007] Pretreating a source rice image to obtain a target rice image, wherein a plurality of rice grains are presented in the target rice image;

[0008] Extracting multi-dimensional rice features corresponding to the plurality of rice grains through a preset feature detection network, wherein the preset feature detection network is a single-stage target detection network based on a non-anchor box;

[0009] Inputting the multi-dimensional rice features into a preset detection head to make the preset detection head output a rice quality detection result.

[0010] Optionally, the preset feature detection network comprises a preset convolution module, a preset feature extraction module and a preset feature fusion module; the step of extracting multi-dimensional rice features corresponding to the plurality of rice grains through the preset feature detection network comprises:

[0011] The preset convolution module is used for performing preset convolution processing on the target rice image to obtain an initial feature layer and an intermediate feature layer.

[0012] The preset feature extraction module is used for performing multi-scale maximum pooling on the intermediate feature layer to obtain a target feature layer.

[0013] The preset feature fusion module is used for performing feature fusion on the initial feature layer and the target feature layer to obtain multi-dimensional rice features corresponding to the plurality of quantities of rice.

[0014] Optionally, the initial feature layer includes a first feature layer and a second feature layer, and the step of performing preset convolution processing on the target rice image by the preset convolution module to obtain an initial feature layer and an intermediate feature layer includes:

[0015] The preset convolution module is used for performing first convolution processing on the target rice image to obtain the first feature layer.

[0016] The preset convolution module is used for performing second convolution processing on the first feature layer to obtain the second feature layer.

[0017] The preset convolution module is used for performing third convolution processing on the second feature layer to obtain the intermediate feature layer.

[0018] Optionally, the preset feature detection network includes a preset number of scale-different maximum pooling layers and a connection layer, and the step of performing multi-scale maximum pooling on the intermediate feature layer by the preset feature extraction module to obtain a target feature layer includes:

[0019] The preset number of scale-different maximum pooling layers are used for performing maximum pooling on the intermediate feature layer a preset number of times to obtain a preset number of corresponding pooling features.

[0020] The connection layer is used for performing feature splicing on the preset number of pooling features to obtain a target feature layer.

[0021] Optionally, the step of performing feature fusion on the initial feature layer and the target feature layer by the preset feature fusion module to obtain multi-dimensional rice features corresponding to the plurality of quantities of rice includes:

[0022] The preset feature fusion module is used for performing channel number adjustment on the target feature layer to obtain an adjusted target feature layer.

[0023] The preset feature fusion module is used for performing feature fusion on the first feature layer, the second feature layer, the target feature layer, and the adjusted target feature layer to obtain a multi-dimensional rice feature layer corresponding to the plurality of quantities of rice.

[0024] Optionally, before the pre-processing of the source rice image to obtain the target rice image, the method comprises:

[0025] performing data transformation on the sample rice image set to obtain an expanded rice image set;

[0026] performing preset image compression on the expanded rice image set to obtain a target sample rice image set;

[0027] based on the target sample rice image set, performing model iterative training to obtain a preset feature detection network.

[0028] Optionally, after the model iterative training based on the target sample rice image set to obtain the preset feature detection network, the method further comprises:

[0029] obtaining a target loss value corresponding to the rice quality detection result through a preset loss function;

[0030] updating the preset feature detection network based on the target loss value.

[0031] In addition, in order to achieve the above-mentioned purpose, the application further provides a rice quality detection device, which comprises:

[0032] an image preprocessing module, configured to pre-process a source rice image to obtain a target rice image, wherein a plurality of quantities of rice are present in the target rice image;

[0033] a feature detection module, configured to perform multi-dimensional feature extraction on the target rice image through a preset feature detection network to obtain multi-dimensional rice features corresponding to the plurality of quantities of rice, wherein the preset feature detection network is a single-stage target detection network based on a non-anchor box;

[0034] a prediction module, configured to input the multi-dimensional rice features into a preset detection head, so that the preset detection head outputs a rice quality detection result.

[0035] In addition, in order to achieve the above-mentioned purpose, the application further provides a rice quality detection device, which comprises: a memory, a processor, and a rice quality detection program stored on the memory and executable on the processor, wherein the rice quality detection program is configured to implement the steps of the rice quality detection method as described above.

[0036] In addition, in order to achieve the above-mentioned purpose, the application further provides a storage medium, wherein the storage medium stores a rice quality detection program, and the rice quality detection program is executed by a processor to implement the steps of the rice quality detection method as described above.

[0037] The application discloses a rice quality detection method, device, equipment and storage medium, and relates to the technical field of rice quality detection. BRIEF DESCRIPTION OF DRAWINGS

[0038] Figure 1 FIG. 1 is a structural schematic diagram of a rice quality detection device of a hardware running environment related to an embodiment scheme of the application;

[0039] Figure 2 FIG. 2 is a flowchart of a first embodiment of the rice quality detection method of the application;

[0040] Figure 3 FIG. 3 is a flowchart of a second embodiment of the rice quality detection method of the application;

[0041] Figure 4 FIG. 4 is a process schematic diagram of preset convolution processing of a preset convolution module in the second embodiment of the rice quality detection method of the application;

[0042] Figure 5 FIG. 5 is a process schematic diagram of scale pooling of a preset feature detection network in the second embodiment of the rice quality detection method of the application;

[0043] Figure 6 FIG. 6 is a process schematic diagram of multi-dimensional feature integration of a preset feature fusion module in the second embodiment of the rice quality detection method of the application;

[0044] Figure 7 FIG. 7 is a structural block diagram of a first embodiment of the rice quality detection device of the application.

[0045] The implementation, functional features and advantages of the application will be further described with reference to the embodiments and the accompanying drawings. DETAILED DESCRIPTION

[0046] It should be understood that the specific embodiments described herein merely serve to explain the application and are not intended to limit the application.

[0047] Referring to Figure 1 , Figure 1 The hardware environment of the embodiment of the present application relates to the structure of the rice quality detection device.

[0048] As Figure 1 shown, the rice quality detection device can include a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. The communication bus 1002 is used to realize the connection and communication between the components. The user interface 1003 can include a display screen, an input unit such as a keyboard, and can also include a standard wired interface, a wireless interface. The network interface 1004 can optionally include a standard wired interface, a wireless interface (such as a wireless fidelity (WI-FI) interface). The memory 1005 can be a high-speed random access memory (RAM), and can also be a stable non-volatile memory (NVM), such as a disk memory. The memory 1005 can also be a storage device independent of the aforementioned processor 1001.

[0049] Those skilled in the art can understand that Figure 1 the structure shown in the figure does not constitute a limitation on the rice quality detection device, and can include more or fewer components than the figure, or combine certain components, or different component arrangements.

[0050] As Figure 1 shown, the memory 1005 as a storage medium can include an operating system, a data storage module, a network communication module, a user interface module, and a rice quality detection program.

[0051] In Figure 1 the rice quality detection device, the network interface 1004 is mainly used for data communication with a network server; the user interface 1003 is mainly used for data interaction with a user; the processor 1001 and the memory 1005 in the rice quality detection device of the present application can be arranged in the rice quality detection device, and the rice quality detection device calls the rice quality detection program stored in the memory 1005 through the processor 1001, and executes the rice quality detection method provided by the embodiment of the present application.

[0052] The embodiment of the present application provides a rice quality detection method, referring to Figure 2 , Figure 2A flowchart of a first embodiment of the rice quality detection method of the present application is shown in the figure.

[0053] In this embodiment, the rice quality detection method comprises the following steps:

[0054] Step S10: Preprocessing the source rice image to obtain a target rice image, wherein a plurality of rice grains are presented in the target rice image.

[0055] It should be noted that the execution subject of the method of the present embodiment can be a computing service device with functions of data processing, network communication, program running, model training, and image recognition, such as a tablet computer, a personal computer, etc., and can also be other electronic devices capable of achieving the same or similar functions. Hereinafter, the rice quality detection method provided by the present embodiment and the following embodiments will be specifically described with the above rice quality detection device (referred to as detection device).

[0056] It should be understood that the source rice image can be an image of the rice to be detected. In the present embodiment, the detection device can be used to detect and classify each rice grain in the source rice image. The specific categories can include whole rice, yellow rice, and broken rice. Therefore, it can be understood that the source rice image contains a large number of rice grains with different shapes, sizes, and colors. In order to reduce the risk of overfitting of the subsequent neural network, the present embodiment can also perform data processing such as image random horizontal flipping, vertical flipping, rotation, brightness change, and / or Gaussian blur on the source rice image. These affine transformations help the neural network to better adapt to various variations of the image. In addition, in order to meet the requirements of constructing the preset feature detection network pre-constructed in the present embodiment, the present embodiment can also compress the width and height of the source rice image without distortion, compressing the rice image into a target pixel corresponding to the input of the preset feature detection network. In the present embodiment, the target pixel can be 512x512 pixels, but the specific value of the target pixel is not limited in the present embodiment.

[0057] Step S20: performing multi-dimensional feature extraction on the target rice image through a preset feature detection network to obtain multi-dimensional rice features corresponding to the plurality of rice grains, wherein the preset feature detection network is a single-stage target detection network based on a non-anchor box.

[0058] It should be noted that, compared with the anchor box based target detection algorithm commonly used in the existing rice detection method, the preset feature detection network based on CenterNet can be used for rice detection in the embodiment. CenterNet is a single-stage target detection algorithm based on non-anchor box. Therefore, the preset feature detection network in the embodiment does not need to design anchor boxes of different sizes in advance to extract features for the rice to be detected, which reduces the complexity of the network, reduces the parameter amount, and at the same time, the single-stage model is generally faster than the two-stage model. Therefore, the preset feature detection network in the embodiment has shorter detection time and faster speed compared with the existing rice detection network. At the same time, the preset feature detection network proposed in the embodiment can detect a plurality of quantities of rice in the target rice image at the same time, and obtain multi-dimensional rice features corresponding to the plurality of quantities of rice. Therefore, compared with the existing method of detecting a single rice, the embodiment can further improve the detection speed.

[0059] It can be understood that the preset feature detection network is a neural network model that has been pre-trained and iterated. Therefore, further, before step S10, the embodiment further includes:

[0060] Step S00: performing data transformation on the sample rice image set to obtain an expanded rice image set;

[0061] Step S01: performing preset image compression on the expanded rice image set to obtain a target sample rice image set;

[0062] Step S02: performing model iterative training based on the target sample rice image set to obtain a preset feature detection network.

[0063] It needs to be understood that the above sample rice image set and the source rice image can be collected with black paperboard as the background when the rice is shot, so as to highlight the rice in the images of the sample rice image set and the source rice image. In order to improve the generalization and robustness of the preset feature detection network, the embodiment can perform data transformation on the sample rice image set, for example, the image data can be expanded by image rotation, so as to obtain an expanded rice image set, so that the total number of images corresponding to the expanded rice image set is much larger than that of the sample rice image set. At the same time, the embodiment can label the rice by using LabelImg, and label the whole rice as whole_rice, the broken rice as broken_rice, and the yellow rice as yellow_rice, and save the label file in PASCAL VOC data format. All images are randomly divided into a training set and a verification test set according to a ratio of 9:1. It can be understood that when the model is trained by using the sample, in order to meet the input requirements of the preset feature detection network, the embodiment also needs to compress the width and height of the source rice image without distortion, and compress the rice image to the target pixel corresponding to the input of the preset feature detection network, that is, the above-mentioned preset image compression, to obtain a target sample rice image set.

[0064] Step S30: inputting the multi-dimensional rice features into a preset detection head, so that the preset detection head outputs a rice quality detection result.

[0065] It needs to be understood that the above-mentioned preset detection head can be used to decode the multi-dimensional rice features, and can be composed of three deconvolution networks, so that the final rice detection image is output with higher resolution, wherein each time the deconvolution, the width and height of the feature layer will become 2 times of the original, and after three times of deconvolution, a feature map with a width and height of 8 times of the above-mentioned multi-dimensional rice features is obtained, and the feature map is input into the Center-Head to obtain the final prediction result.

[0066] It needs to be explained that the above-mentioned Center-Head can perform heat point prediction, heat point bias prediction and width-height prediction based on the feature map with a width and height of 8 times of the above-mentioned multi-dimensional rice features, respectively, to obtain a heat prediction map, that is, the above-mentioned rice quality detection result, wherein the heat point prediction represents the existence of the object and the type of the object; the heat point bias prediction represents the situation that the center of each object is offset from the heat point; and the width-height prediction represents the prediction situation of the width and height of each object; therefore, the heat prediction map finally output by the Center-Head can display the existence of the object, the position of the object and the type of the object, and can very intuitively display the distribution of the whole rice, the yellow rice and the broken rice in the rice.

[0067] Therefore, further, in the embodiment, after step S30, there are still:

[0068] Step S40: obtaining a target loss value corresponding to the rice quality detection result through a preset loss function;

[0069] Step S50: model updating of the preset feature detection network according to the target loss value.

[0070] It can be understood that after the model updating through the preset feature monitoring network, the embodiment can also compare the real data with the prediction result, calculate the loss value and perform model updating based on the loss value. The above target loss value can be divided into three parts: heat point prediction loss value, heat point bias prediction loss value and width-height prediction loss value. Specifically, the preset loss function can include a heat point prediction loss function, a heat point bias prediction loss function and a width-height prediction loss function. The heat point prediction loss value can be obtained based on the heat point prediction loss function, the heat point bias prediction loss value can be obtained based on the heat point bias prediction loss function, and the width-height prediction loss value can be obtained based on the width-height prediction loss function.

[0071] It should be noted that the heat point prediction loss function corresponding formula can be as follows:

[0072]

[0073] In the formula, L k is the heat point prediction loss value, is the prediction value of a heat point, Y xyc = 1 indicates that the coordinate position (x, y) detects a heat point of class c, Y xyc is the true value, N is the number of heat points in the input image, and a and β are hyperparameters of the heat point preset loss function. In the embodiment, the values of a and β can be set to 2 and 4 respectively.

[0074] The heat point bias prediction loss function corresponding formula can be as follows:

[0075]

[0076] In the formula, L off is the heat point bias prediction loss value, is the prediction value of the heat point offset, p represents the center point of each class c, and R is the down-sampling factor of the heat map relative to the input image, which can be set to 4; is the heat point equivalent to p on the heat map after down-sampling R times.

[0077] Meanwhile, the width-height prediction loss function corresponding formula can be as follows:

[0078]

[0079] In the formula, L sizeFor the width and height prediction loss value, p k For a target object k of a class c; For the width and height prediction value of the heat point, s k For the size of the target k.

[0080] Finally, the total loss value can be the weighted sum of the above three loss values, as shown in the following formula:

[0081] L det= L k +λ off L off +A size L size ,

[0082] In the formula, L det is the total loss value, λ off is the first parameter, and λ size is the second parameter.

[0083] The above λ off and λ size can be used to measure the loss. Specifically, the present embodiment can set λ off = 1 and λ size = 0.1.

[0084] It should be understood that in actual application, the present embodiment can first use the VOC data set to pre-train the preset feature detection network to obtain the pre-training weight of the model, which is used for iterative training of the preset feature detection network on the target sample rice image set. In the training process, two optimizers, SGD (Stochastic Gradient Descent) and Adam (Adaptive Moment Estimation), can be used. The present embodiment can use the Adam optimizer to optimize the model because Adam can adaptively adjust the learning rate and dynamically adjust the direction and size of parameter update during the training process, thereby accelerating the convergence and improving the generalization ability of the model, so that the model quickly adapts to the target sample rice image set with multiple rice images. In the training process, the maximum learning rate of the preset feature detection network can be set to 0.001, the weight decay momentum can be set to 0.9, and the multi-thread setting can be set to 4. The number of model training iterations is measured in “epochs” and is set to 200.

[0085] The embodiment discloses a rice quality detection method, which comprises the following steps: performing data transformation on a sample rice image set to obtain an expanded rice image set; performing preset image compression on the expanded rice image set to obtain a target sample rice image set; and performing model iterative training based on the target sample rice image set to obtain a preset feature detection network. The source rice image is preprocessed to obtain a target rice image, and a plurality of quantities of rice are presented in the target rice image. The preset feature detection network is used to perform multi-dimensional feature extraction on the target rice image to obtain multi-dimensional rice features corresponding to the plurality of quantities of rice. The preset feature detection network is a single-stage target detection network based on a non-anchor box. The multi-dimensional rice features are input into a preset detection head to make the preset detection head output a rice quality detection result. A target loss value corresponding to the rice quality detection result is obtained through a preset loss function. The preset feature detection network is updated according to the target loss value. Therefore, unlike the existing method of manually extracting features, the preset feature detection network proposed in the embodiment is a single-stage target detection algorithm based on a non-anchor box, so it is not necessary to design anchor boxes of different sizes in advance to extract features, thereby reducing the complexity of the network, reducing the parameter amount, and reducing the detection time. At the same time, unlike the existing quality detection of single rice grains, the embodiment can detect multiple rice grain images at the same time, further improving the detection speed and thus improving the detection efficiency.

[0086] Reference Figure 3 , Figure 3 The figure is a flowchart of a second embodiment of the rice quality detection method, which is based on the above-mentioned embodiment. Figure 2 The second embodiment of the rice quality detection method is proposed based on the above-mentioned embodiment.

[0087] It can be understood that the inconsistency between the shooting environment of the target rice image and the natural light may affect the feature extraction effect, and the rice grain shape is small and occupies a small proportion of the image pixels, so the detection difficulty of rice detection is high and the precision is low.

[0088] It should be understood that, in order to solve the above-mentioned problems, the embodiment can perform hierarchical processing and multi-dimensional fusion on the image features in the target rice image, thereby improving the precision of the extracted features. Specifically, the embodiment can improve the single-stage anchor-free target detection algorithm CenterNet with strong real-time performance, replace the original backbone network of CenterNet with GhostNet, and introduce a spatial pyramid pooling (SPP) network to increase the richness of the extracted features. Finally, PANet (path aggregation network) is used for feature fusion to effectively utilize multi-layer features to improve the detection precision.

[0089] Therefore, further in the embodiment, the preset feature detection network comprises: a preset convolution module, a preset feature extraction module and a preset feature fusion module, as shown in Figure 3 Step S20 can comprise:

[0090] Step S201: performing preset convolution processing on the target rice image through the preset convolution module to obtain an initial feature layer and an intermediate feature layer;

[0091] It should be noted that the preset feature detection network can take the above target rice image as input and perform feature extraction of the target rice image layer by layer. The shallow network can extract some low-level features (such as edges, lines, textures, etc.) of the target rice image, and the deep network can further combine the shallow features and gradually abstract the features of the target rice image, so that the image features of the target rice image experience a process from low-level to high-level and from simple to abstract in the network. The role of the above preset convolution module is to perform preliminary feature extraction on the above target rice image. The feature extraction process is completed by convolution kernel (kernel) and image pixel value (or certain features) convolution operation. A new set of features, called feature map (feature map), is obtained through convolution operation, which is the above initial feature layer.

[0092] Further in the embodiment, step S201 can comprise:

[0093] Step S2011: performing first convolution processing on the target rice image through the preset convolution module to obtain the first feature layer;

[0094] Step S2012: performing second convolution processing on the first feature layer through the preset convolution module to obtain the second feature layer;

[0095] Step S2013: performing third convolution processing on the second feature layer through the preset convolution module to obtain the intermediate feature layer.

[0096] It should be understood that in the embodiment, the above preset convolution module can be a GhostNet network. The GhostNet network bottleneck structure mainly has two kinds: when the width and height of the feature layer do not need to be compressed, the step length of the Ghost bottleneck structure is set to 1; when the width and height of the feature layer need to be compressed, the step length of the Ghost bottleneck structure is set to 2, and a depth separable convolution layer with a step length of 2x2 is inserted between the two Ghost modules to compress the width and height of the feature layer. In order to facilitate understanding, an example is taken to illustrate, Figure 4 for example, Figure 4 is a process diagram of the preset convolution module in the second embodiment of the rice quality detection method of the application, as shown in Figure 4As shown, the embodiment can input the target rice image into the preset convolution module, first perform the above-mentioned first convolution processing through a common 1x1 convolution block with a channel number of 16 and a step of 2 to obtain the above-mentioned first feature layer; then perform the above-mentioned second convolution processing through a block stacked by a Ghost bottleneck structure to obtain the above-mentioned second feature layer; finally perform the above-mentioned third convolution processing through three 1x1 convolution blocks to adjust the channel number, and finally obtain the above-mentioned intermediate feature layer. It is easy to understand that the dimensions of the above-mentioned first feature layer, second feature layer and intermediate feature layer and the specific processing process of the first convolution processing, first convolution processing and third convolution processing can be adjusted according to actual conditions, and the embodiment does not limit this.

[0097] Step S202: performing multi-scale maximum pooling on the intermediate feature layer through the preset feature extraction module to obtain a target feature layer;

[0098] It should be understood that, without affecting the complexity of the network and enhancing the feature extraction capability of the network, the embodiment can use a spatial pyramid pooling (SPP) network as the above-mentioned preset feature extraction network to perform multi-scale maximum pooling on the intermediate feature layer to obtain the target feature layer.

[0099] Further, in the embodiment, the preset dual attention module can include a preset channel attention unit, a preset spatial attention unit and a preset fusion unit, and the above-mentioned step S202 can include:

[0100] Step S2021: performing maximum pooling on the intermediate feature layer a preset number of times through a preset number of scale-different maximum pooling layers to obtain a corresponding preset number of pooling feature layers;

[0101] Step S2022: performing feature splicing on the preset number of pooling features through the connection layer to obtain a target feature layer.

[0102] It should be noted that the spatial pyramid pooling network, i.e. the above-mentioned preset feature extraction network, can include multiple pooling layers, and the scales of the pooling layers are different, i.e. the pooling kernels of the pooling layers are different. Each pooling layer can select the pixel point with the maximum value in a certain regional sub-block of the input intermediate feature layer as the maximum pooling result. Therefore, the above-mentioned preset number of scale-different maximum pooling layers can select different feature points, and finally the results of the pooling layers are spliced, thereby greatly increasing the receptive field and extracting the most significant features from the intermediate feature layer, and further improving the feature extraction accuracy. In actual application, the embodiment can use four maximum pooling layers with different scales to extract features. In order to facilitate understanding, an example is taken to illustrate, Figure 5 Figure 5 ​This is a schematic diagram illustrating the scale pooling process of a preset feature detection network in the second embodiment of the rice quality detection method of the present invention, as shown below. Figure 5 As shown, in this embodiment, the preset feature detection module may include: first to fourth max pooling layers, and the pooling kernel sizes of the first to fourth max pooling layers may be 13×13, 9×9, 5×5, and 1×1, respectively. After inputting the first to fourth max pooling layers into the intermediate feature layer, the first to fourth pooling features can be obtained. Figure 5 The “⊕” symbol represents the aforementioned connection layer, which can perform concatenation operations on the first to fourth pooling features to obtain the target feature layer, thereby greatly increasing the receptive field and extracting the most significant features from the intermediate feature layer.

[0103] Step S203: The initial feature layer and the target feature layer are fused by the preset feature fusion module to obtain multi-dimensional rice features corresponding to the number of rice grains.

[0104] It's important to understand that the existing CenterNet model only uses the highest-level feature maps for object detection, even though the high-level feature layers obtained through the backbone feature extraction network contain rich semantic information.

[0105] However, the low resolution makes it difficult to accurately preserve the location information of the detected rice. Therefore, this embodiment uses PANet to fuse features from multiple dimensions, enhancing the network's ability to preserve complete features of the rice and improving the network's detection accuracy.

[0106] Further, in this embodiment, step S203 includes:

[0107] Step S2031: Adjust the number of channels in the target feature layer through the preset feature fusion module to obtain the adjusted target feature layer;

[0108] Step S2032: The first feature layer, the second feature layer, the target feature layer and the adjusted target feature layer are fused by a preset feature fusion module to obtain a multi-dimensional rice feature layer corresponding to the number of rice grains.

[0109] It should be noted that in this embodiment, the features of the aforementioned multiple dimensions may include: the first feature layer, the second feature layer, and the target feature layer. It is easy to understand that the dimensions of each feature layer are not consistent, but ensuring consistent dimensions during feature fusion allows the model to process all categories of features more balancedly, thereby improving the model's prediction accuracy. Therefore, in this embodiment, the number of channels in the target feature layer can be adjusted first to obtain the adjusted target feature layer. For ease of understanding, let's use... Figure 6 Let's take an example to illustrate this. Figure 6This is a schematic diagram illustrating the process of multi-dimensional feature integration performed by the preset feature fusion module in the second embodiment of the rice quality detection method of the present invention, as shown below. Figure 6 As shown, this embodiment adjusts the target feature layer through upsampling, and then concatenates the adjusted target feature layer with the second feature layer. Next, the adjusted target feature layer and the second feature layer are further upsampled and concatenated with the first feature layer. Furthermore, this embodiment includes a preset feature fusion module that can downsample the concatenated features to ensure that the downsampled features match the size of the target feature layer when passed down, thereby enabling effective fusion of features from each layer to obtain a multi-dimensional rice feature layer. In other words, this embodiment uses a combination of upsampling and downsampling to fuse the first feature layer, the second feature layer, and the target feature layer, further improving feature extraction accuracy.

[0110] This embodiment performs a first convolutional process on the target rice image using a preset convolutional module to obtain a first feature layer; then performs a second convolutional process on the first feature layer using the same preset convolutional module to obtain a second feature layer; and finally performs a third convolutional process on the second feature layer using the same preset convolutional module to obtain an intermediate feature layer. The intermediate feature layer is then subjected to a preset number of max-pooling operations using max-pooling layers of different scales to obtain corresponding pooled feature layers of a preset number. These pooled feature layers are then concatenated using a connection layer to obtain a target feature layer. The target feature layer's channel count is adjusted using a preset feature fusion module to obtain an adjusted target feature layer. Finally, the first feature layer, second feature layer, target feature layer, and adjusted target feature layer are fused using the same preset feature fusion module to obtain a multi-dimensional rice feature layer corresponding to a certain number of rice grains. Therefore, considering the poor shooting environment of the target rice image, this embodiment replaces the original backbone network of CenterNet with GhostNet and introduces a spatial pyramid pooling network to increase the richness of extracted features. At the same time, compared with the existing CenterNet model that only uses the highest level feature map for target detection, this embodiment can effectively perform multi-dimensional feature fusion of the first feature layer, the second feature layer and the target feature layer at different size levels through the PANet network, effectively utilizing multi-layer features and improving detection accuracy; and further improves feature extraction accuracy by using PANet to perform feature fusion of the first feature layer, the second feature layer and the target feature layer by combining upsampling and downsampling.

[0111] Furthermore, this embodiment of the invention also proposes a storage medium storing a rice quality detection program, which, when executed by a processor, implements the steps of the rice quality detection method described above.

[0112] refer to Figure 7 , Figure 7A structural block diagram of a first embodiment of a rice quality detection device of the present application.

[0113] As shown in Figure 7 The rice quality detection device comprises:

[0114] An image preprocessing module 701 is configured to preprocess a source rice image to obtain a target rice image, and the target rice image presents a plurality of quantities of rice.

[0115] A feature detection module 702 is configured to perform multi-dimensional feature extraction on the target rice image by using a preset feature detection network to obtain multi-dimensional rice features corresponding to the plurality of quantities of rice, and the preset feature detection network is a single-stage target detection network based on a non-anchor box.

[0116] A prediction module 703 is configured to input the multi-dimensional rice features into a preset detection head to make the preset detection head output a rice quality detection result.

[0117] Further, as an implementable manner, in the present embodiment, the image preprocessing module 701 is further configured to perform data transformation on a sample rice image set to obtain an expanded rice image set.

[0118] The image preprocessing module 701 is further configured to perform preset image compression on the expanded rice image set to obtain a target sample rice image set.

[0119] The image preprocessing module 701 is further configured to perform model iterative training based on the target sample rice image set to obtain the preset feature detection network.

[0120] Further, as an implementable manner, in the present embodiment, the prediction module 703 is further configured to obtain a target loss value corresponding to the rice quality detection result by using a preset loss function.

[0121] The prediction module 703 is further configured to perform model updating on the preset feature detection network according to the target loss value.

[0122] The embodiment obtains an expanded rice image set by performing data transformation on a sample rice image set, obtains a target sample rice image set by performing preset image compression on the expanded rice image set, and obtains a preset feature detection network based on iterative training of the target sample rice image set. The source rice image is preprocessed to obtain a target rice image, and a plurality of quantities of rice are presented in the target rice image. The preset feature detection network is used for multi-dimensional feature extraction on the target rice image to obtain multi-dimensional rice features corresponding to the plurality of quantities of rice. The preset feature detection network is a single-stage target detection network based on a non-anchor box. The multi-dimensional rice features are input into a preset detection head, so that the preset detection head outputs a rice quality detection result. A target loss value corresponding to the rice quality detection result is obtained by using a preset loss function. The preset feature detection network is updated based on the target loss value. Therefore, unlike the existing feature extraction method, the preset feature detection network proposed in the embodiment is a single-stage target detection algorithm based on a non-anchor box, so that the network complexity is reduced, the parameter amount is reduced, and the detection time is reduced. At the same time, unlike the existing single-grain rice quality detection, the embodiment can detect multiple rice images at the same time, further improving the detection speed and thus improving the detection efficiency.

[0123] Based on the above-mentioned first embodiment of the rice quality detection device of the present application, a second embodiment of the rice quality detection device of the present application is proposed.

[0124] In the embodiment, the preset feature detection network comprises a preset convolution module, a preset feature extraction module and a preset feature fusion module.

[0125] The feature detection module 702 is further configured to perform preset convolution processing on the target rice image by using the preset convolution module to obtain an initial feature layer and an intermediate feature layer.

[0126] The feature detection module 702 is further configured to perform multi-scale maximum pooling on the intermediate feature layer by using the preset feature extraction module to obtain a target feature layer.

[0127] The feature detection module 702 is further configured to perform feature fusion on the initial feature layer and the target feature layer by using the preset feature fusion module to obtain multi-dimensional rice features corresponding to the plurality of quantities of rice.

[0128] Further, as an implementable manner, in the embodiment, the initial feature layer comprises a first feature layer and a second feature layer.

[0129] The feature detection module 702 is further configured to perform first convolution processing on the target rice image by using the preset convolution module to obtain the first feature layer.

[0130] The feature detection module 702 is further configured to perform second convolution processing on the first feature layer by using the preset convolution module to obtain a second feature layer.

[0131] The feature detection module 702 is further configured to perform third convolution processing on the second feature layer by using the preset convolution module to obtain an intermediate feature layer.

[0132] Further, as an implementable manner, in the embodiment, the preset feature detection network comprises: a preset number of scale-different max-pooling layers and a connection layer.

[0133] The feature detection module 702 is further configured to perform the preset number of times of max-pooling on the intermediate feature layer by using the preset number of scale-different max-pooling layers respectively to obtain a corresponding preset number of pooling features.

[0134] The feature detection module 702 is further configured to perform feature splicing on the preset number of pooling features by using the connection layer to obtain a target feature layer.

[0135] Further, as an implementable manner, in the embodiment, the feature detection module 702 is further configured to perform channel number adjustment on the target feature layer by using a preset feature fusion module to obtain an adjusted target feature layer.

[0136] The feature detection module 702 is further configured to perform feature fusion on the first feature layer, the second feature layer, the target feature layer and the adjusted target feature layer by using a preset feature fusion module to obtain a plurality of multi-dimensional rice feature layers corresponding to the plurality of quantities of rice.

[0137] The embodiment obtains a first feature layer by performing first convolution processing on the target rice image through a preset convolution module, obtains a second feature layer by performing second convolution processing on the first feature layer through the preset convolution module, and obtains an intermediate feature layer by performing third convolution processing on the second feature layer through the preset convolution module. A preset number of maximum pooling layers with different scales are used to perform maximum pooling on the intermediate feature layer for a preset number of times to obtain a corresponding preset number of pooling feature layers; a connection layer is used to perform feature splicing on the preset number of pooling features to obtain a target feature layer. A preset feature fusion module is used to adjust the channel number of the target feature layer to obtain an adjusted target feature layer; and the preset feature fusion module is used to perform feature fusion on the first feature layer, the second feature layer, the target feature layer, and the adjusted target feature layer to obtain a plurality of multi-dimensional rice feature layers corresponding to a plurality of quantities of rice. Therefore, in view of the poor shooting environment of the target rice image, the embodiment replaces the original backbone network of the CenterNet with the GhostNet, and introduces the spatial pyramid pooling network to increase the richness of the extracted features. At the same time, compared with the existing CenterNet model that only uses the highest level feature map for target detection, the embodiment can effectively perform multi-dimensional feature fusion on the first feature layer, the second feature layer, and the target feature layer of different size levels through the PANet network, effectively utilize the multi-layer features, and improve the detection accuracy; and the PANet is used to combine the up-sampling and the down-sampling to perform feature fusion on the first feature layer, the second feature layer, and the target feature layer, thereby further improving the feature extraction accuracy.

[0138] Other embodiments or specific implementations of the rice quality detection device can refer to the above-mentioned method embodiments, which will not be described here.

[0139] It should be noted that in this document, the terms "comprising", "including", or any other variant thereof are intended to cover non-exclusive inclusion, so that processes, methods, articles, or systems that include a series of elements not only include those elements, but also include other elements not explicitly listed, or inherent to such processes, methods, articles, or systems. Without more limitations, the element defined by the statement "including a" does not exclude the presence of other identical elements in the process, method, article, or system that includes the element.

[0140] The above-mentioned embodiment numbers of the application are only for description, and do not represent the advantages and disadvantages of the embodiments.

[0141] Those skilled in the art can clearly understand the above-mentioned embodiment method can be realized by means of software and the necessary general hardware platform, of course, can also be through hardware, but in many cases the former is a better embodiment. Based on such understanding, the technical solutions of the present application essentially or say the part of the prior art contribution can be embodied in the form of software products, the computer software product is stored in a storage medium (such as ROM / RAM, magnetic disc, optical disc) as described above, including a number of instructions to make a terminal device (may be a mobile phone, computer, server, air conditioner, or network equipment, etc.) executes the method described in various embodiments of the present application.

[0142] The above is only the preferred embodiment of the present application, not therefore limit the patent scope of the present application, any equivalent structure or equivalent flow transformation made by using the content of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.

Claims

1. A method for detecting the quality of rice, characterized by, The rice quality detection method comprises: Pretreating a source rice image to obtain a target rice image, the target rice image presenting a plurality of quantities of rice; Extracting multi-dimensional rice features corresponding to the plurality of quantities of rice from the target rice image by a preset feature detection network, the preset feature detection network being a single-stage target detection network based on a non-anchor box; the preset feature detection network comprises a preset convolution module, a preset feature extraction module, and a preset feature fusion module; Inputting the multi-dimensional rice features into a preset detection head to enable the preset detection head to output a rice quality detection result; The step of extracting multi-dimensional rice features corresponding to the plurality of quantities of rice from the target rice image by the preset feature detection network comprises: Performing preset convolution processing on the target rice image by the preset convolution module to obtain an initial feature layer and an intermediate feature layer; the initial feature layer comprises a first feature layer and a second feature layer; Performing multi-scale maximum pooling on the intermediate feature layer by the preset feature extraction module to obtain a target feature layer; the preset feature extraction module comprises a preset number of scale-different maximum pooling layers and a connection layer; Performing feature fusion on the initial feature layer and the target feature layer by the preset feature fusion module to obtain multi-dimensional rice features corresponding to the plurality of quantities of rice; The step of performing preset convolution processing on the target rice image by the preset convolution module to obtain an initial feature layer and an intermediate feature layer comprises: Performing first convolution processing on the target rice image by the preset convolution module to obtain the first feature layer; Performing second convolution processing on the first feature layer by the preset convolution module to obtain the second feature layer; Performing third convolution processing on the second feature layer by the preset convolution module to obtain an intermediate feature layer; The step of performing multi-scale maximum pooling on the intermediate feature layer by the preset feature extraction module to obtain a target feature layer comprises: Performing maximum pooling on the intermediate feature layer by the preset number of scale-different maximum pooling layers a preset number of times to obtain a corresponding preset number of pooling features; Performing feature splicing on the preset number of pooling features by the connection layer to obtain a target feature layer.

2. The method for detecting the quality of rice according to Claim 1, wherein The step of performing feature fusion on the initial feature layer and the target feature layer by the preset feature fusion module to obtain multi-dimensional rice features corresponding to the plurality of quantities of rice comprises: Adjusting the target feature layer in channel number by the preset feature fusion module to obtain an adjusted target feature layer; Performing feature fusion on the first feature layer, the second feature layer, the target feature layer, and the adjusted target feature layer by the preset feature fusion module to obtain multi-dimensional rice feature layers corresponding to the plurality of quantities of rice.

3. The method for detecting the quality of rice according to claim 2, wherein Before the step of pretreating a source rice image to obtain a target rice image, the method comprises: Performing data transformation on a sample rice image set to obtain an expanded rice image set; Pre-set image compression is performed on the expanded rice image set to obtain a target sample rice image set; Model iterative training is performed based on the target sample rice image set to obtain a pre-set feature detection network.

4. The method for detecting the quality of rice according to Claim 3, wherein After the model iterative training based on the target sample rice image set to obtain the pre-set feature detection network, the method further includes: A target loss value corresponding to the rice quality detection result is obtained through a pre-set loss function; The pre-set feature detection network is updated based on the target loss value.

5. A rice quality detecting apparatus characterized by comprising: The rice quality detection device includes: An image preprocessing module configured to preprocess a source rice image to obtain a target rice image, the target rice image including a plurality of quantities of rice; A feature detection module configured to extract multi-dimensional rice features corresponding to the plurality of quantities of rice from the target rice image through a pre-set feature detection network, the pre-set feature detection network being a single-stage target detection network based on a non-anchor box; the pre-set feature detection network including a pre-set convolution module, a pre-set feature extraction module, and a pre-set feature fusion module; A prediction module configured to input the multi-dimensional rice features into a pre-set detection head to output a rice quality detection result; The feature detection module is further configured to perform pre-set convolution processing on the target rice image through the pre-set convolution module to obtain an initial feature layer and an intermediate feature layer; the initial feature layer including a first feature layer and a second feature layer; the intermediate feature layer is subjected to multi-scale maximum pooling through the pre-set feature extraction module to obtain a target feature layer; the pre-set feature extraction module including a pre-set number of scale-different maximum pooling layers and a connection layer; the initial feature layer and the target feature layer are subjected to feature fusion through the pre-set feature fusion module to obtain the multi-dimensional rice features corresponding to the plurality of quantities of rice; The feature detection module is further configured to perform first convolution processing on the target rice image through the pre-set convolution module to obtain the first feature layer; perform second convolution processing on the first feature layer through the pre-set convolution module to obtain the second feature layer; and perform third convolution processing on the second feature layer through the pre-set convolution module to obtain the intermediate feature layer; The feature detection module is further configured to perform maximum pooling on the intermediate feature layer a pre-set number of times through the pre-set number of scale-different maximum pooling layers to obtain a corresponding pre-set number of pooling features; and perform feature splicing on the pre-set number of pooling features through the connection layer to obtain the target feature layer.

6. A rice quality detecting apparatus characterized by comprising: The device includes a memory, a processor, and a rice quality detection program stored on the memory and executable on the processor, the rice quality detection program being configured to implement the steps of the rice quality detection method according to any one of claims 1 to 5.

7. A storage medium, characterized by The storage medium stores a rice quality detection program, and the rice quality detection program is executed by the processor to implement the steps of the rice quality detection method according to any one of claims 1 to 5.