Rice recognition method and system based on YOLOv11 model and two-stage data enhancement

By using the YOLOv11 model and a two-stage data augmentation method for rice identification, the problems of low efficiency and insufficient robustness in identifying rice grains are solved, and the accuracy and adaptability of rice identification are improved, especially the detection capability under conditions of light variation and shading.

CN122391850APending Publication Date: 2026-07-14INST OF AGRI RESOURCES & ENVIRONMENT GUANGDONG ACADEMY OF AGRI SCI

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
INST OF AGRI RESOURCES & ENVIRONMENT GUANGDONG ACADEMY OF AGRI SCI
Filing Date
2026-04-04
Publication Date
2026-07-14

AI Technical Summary

Technical Problem

Existing methods for identifying rice grains are inefficient and susceptible to subjective influences, making it difficult to meet the needs of high-throughput plant phenotypic analysis. Furthermore, changes in light intensity and background clutter in field or indoor environments lead to insufficient identification accuracy and robustness.

Method used

A rice identification method based on the YOLOv11 model and two-stage data augmentation is adopted. Through techniques such as image transformation, hard sample screening, region overlay and illumination simulation, the robustness of the model to illumination and occlusion is enhanced, thereby improving the accuracy of rice identification.

Benefits of technology

It significantly improves the accuracy of rice detection under small target and occlusion conditions, enhances the model's adaptability to rotation, perspective and noise, and enables the learning of richer grain morphology and illumination variation features.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122391850A_ABST
    Figure CN122391850A_ABST
Patent Text Reader

Abstract

The application provides a rice recognition method and system based on a YOLOv11 model and two-stage data enhancement, wherein the method comprises image transformation on N1 rice images, first-stage training of the YOLOv11 model by using an initial image set, recognition of N2 rice images by using a benchmark model, screening of difficult samples, extraction of rice regions of the difficult samples, superposition of each rice region to a background image, adjustment of occlusion conditions and illumination conditions of a combined image set, enhancement of the combined image set and the initial image set, second training of the benchmark model by using the enhanced image set, input of to-be-detected rice images into a final detection model for recognition, and obtaining of rice recognition results. The two-stage data expansion strategy is adopted, so that the model learns more abundant grain morphology, stacking mode and illumination change characteristics, and the detection accuracy of the final detection model after training is greatly improved for small targets, occlusions and adhered grains.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of target detection technology, and in particular to a method and system for identifying rice grains based on the YOLOv11 model and two-stage data augmentation. Background Technology

[0002] In rice genetic breeding research and agricultural production management, accurate identification of rice grains is a crucial foundation for grain phenotypic analysis, yield prediction, variety classification, and quality testing. Traditional manual identification methods rely on visual observation and manual counting, which are not only inefficient but also easily influenced by subjective experience, resulting in insufficient data repeatability and objectivity, making it difficult to meet the needs of modern high-throughput plant phenotypic analysis.

[0003] With the rapid development of computer vision technology, deep learning-based object detection algorithms have provided new possibilities for the automated extraction of agricultural phenotypic characteristics. However, rice grain identification faces a series of unique challenges: the grains are small in size, elongated in shape, and highly similar, resulting in severe stacking and occlusion in images. Meanwhile, interference factors such as changes in lighting conditions in the field or indoors, and background debris (such as rice awns and broken leaves) mean that existing single models still have bottlenecks in terms of recognition accuracy and robustness.

[0004] In summary, there is an urgent need for a rice identification method that, based on deep learning algorithms, can selectively synthesize and enhance difficult samples while being robust to illumination and occlusion. Summary of the Invention

[0005] To overcome the problems existing in related technologies, the purpose of this invention is to provide a method and system for rice identification based on the YOLOv11 model and two-stage data augmentation. The method, based on deep learning algorithms, can selectively synthesize and augment difficult samples, while being robust to illumination and occlusion.

[0006] A rice identification method based on the YOLOv11 model and two-stage data augmentation includes: Perform image transformation on N1 images of rice to obtain an initial image set; The YOLOv11 model was trained in the first stage using the initial image set to obtain the baseline model; The benchmark model is used to identify N2 rice images and filter out difficult samples; the difficult samples are those that the benchmark model does not detect rice in. Extract the rice grain regions from the difficult samples, and overlay each rice grain region onto the background image to obtain a combined image set; Adjust the occlusion and illumination conditions of the combined image set to obtain a synthetic image set; The synthesized image set and the initial image set are enhanced to obtain an enhanced image set; The base model is trained a second time using the enhanced image set to obtain the final detection model; The image of the rice grain to be detected is input into the final detection model for recognition, and the rice grain recognition result is obtained.

[0007] In a preferred embodiment of the present invention, the step of overlaying each of the rice paddies onto a background image to obtain a combined image set includes: Select a background image containing multiple rice grains; M rice paddy regions are pre-overlaid on the background image, and the intersection-union ratio (IUU) of the rice paddy regions and the rice paddies already placed in the background image is detected; wherein, the illumination directions of the M rice paddy regions are different, and M≥1; If the cross-over ratio is less than the first overlap threshold or greater than the second overlap threshold, the rice region is rotated until the cross-over ratio is greater than or equal to the first overlap threshold and less than or equal to the second overlap threshold, resulting in a rotated rice region; the second overlap threshold is greater than the first overlap threshold. The rotated rice paddy region is merged into the background image using a Poisson fusion method to obtain a combined image set.

[0008] In a preferred embodiment of the present invention, adjusting the occlusion and illumination conditions of the combined image set to obtain the composite image set includes: The upper and lower layers of rice in each composite image in the composite image set are distinguished based on the height difference between adjacent rice grains and the length of the projection line. The visible area of ​​the lower layer of rice was randomly selected and masked to simulate a scenario where the lower layer of rice was completely or partially obscured by the upper layer of rice. Gaussian shadows are added to each composite image in the composite image set to simulate lighting variations in a real haystack.

[0009] In a preferred embodiment of the present invention, enhancing the synthesized image set and the initial image set to obtain an enhanced image set includes: The synthesized image set and the initial image set are combined to obtain the combined image set; The combined image set is subjected to any of the following transformations: random rotation, random perspective transformation, random scaling, Gaussian blur, addition of white point noise, and addition of black point noise, to obtain an enhanced image set.

[0010] In a preferred embodiment of the present invention, the first-stage training of the YOLOv11 model using the initial image set includes: Train a YOLOv11 model using the following two-stage loss function: ; ; ; Where Loss represents the two-stage loss function, IoU represents the intersection-over-union ratio, and b p Represents the prediction box, b g Represents the true bounding box. represents the square of the Euclidean distance between the predicted bounding box and the ground truth bounding box; c represents the diagonal distance of the smallest closure region that simultaneously contains both the predicted bounding box and the ground truth bounding box. Represents the balance parameters. Indicates the aspect ratio consistency parameter; y i p represents the value of the i-th tag, total represents the total number of tag categories, and p i This represents the probability of the YOLOv11 model predicting the i-th class, where log represents the logarithmic function with base to the natural constant; arctan represents the arctangent function; and w... g h represents the width of the actual bounding box. g Indicates the height of the actual bounding box; w p h represents the width of the prediction box. p This indicates the height of the prediction box.

[0011] In a preferred embodiment of the present invention, the step of using the enhanced image set to perform secondary training on the baseline model to obtain the final detection model includes: The enhanced image set is used as the training set, and the baseline model is trained a second time based on the two-stage loss function until the recognition error rate of the baseline model is less than or equal to the recognition error rate threshold, thus obtaining the final detection model.

[0012] In a preferred embodiment of the present invention, after obtaining the rice identification result, the method further includes: Count all detection boxes in the rice identification results; Calculate the distance function value between adjacent first and second detection boxes; where the confidence level of the first detection box is con1, the confidence level of the second detection box is con2, and con1 < con2; If the distance function value is less than the distance threshold, then the first detection box is removed.

[0013] In a preferred embodiment of the present invention, the step of performing image transformation on N1 rice images to obtain an initial image set includes: For each rice image, perform any number of transformations, including random rotation, random perspective transformation, random scaling, Gaussian blur, adding white noise, and adding black noise, to obtain the initial image set.

[0014] In a preferred embodiment of the present invention, after obtaining the rice identification result, the method further includes: Extract the grain size, aspect ratio, and integrity of each detected rice grain; Rice with an aspect ratio less than a first aspect ratio threshold or greater than a second aspect ratio threshold is classified as first-category unqualified rice; the first aspect ratio threshold is less than the second aspect ratio threshold. Rice with an integrity score of less than 0.85 is classified as the second category of substandard rice. Subtracting twice the standard deviation of rice grain size from the average rice grain size in the training set yields the lower limit of grain size; adding twice the standard deviation of rice grain size to the average rice grain size in the training set yields the upper limit of grain size. Rice with a particle size smaller than the lower limit or larger than the upper limit is classified as the third category of substandard rice.

[0015] This invention also provides a rice identification system based on the YOLOv11 model and two-stage data augmentation, comprising: The image transformation module is used to transform N1 images of rice to obtain an initial image set. The first-stage training module is used to perform the first-stage training of the YOLOv11 model using the initial image set to obtain the baseline model. The difficult sample screening module is used to identify N2 rice images using the benchmark model and screen out difficult samples; the difficult samples are those that the benchmark model did not detect as rice. The rice region overlay module is used to extract the rice regions of the difficult samples using a region segmentation algorithm, and overlay each rice region onto the background image to obtain a combined image set. An image adjustment module is used to adjust the occlusion and lighting conditions of the combined image set to obtain a synthetic image set; The image enhancement module is used to enhance the synthesized image set and the initial image set to obtain an enhanced image set; The second-stage training module is used to perform secondary training on the baseline model using the enhanced image set to obtain the final detection model. The rice grain recognition module is used to input the image of the rice grain to be detected into the final detection model for recognition, and obtain the rice grain recognition result.

[0016] The beneficial effects of this invention are as follows: The rice recognition method based on the YOLOv11 model and two-stage data augmentation provided by this invention includes image transformation of N1 rice images to obtain an initial image set. Image transformation expands the sample and enhances the adaptability of the YOLOv11 model to rotation, perspective, scaling, and noise. The initial image set is used to train the YOLOv11 model in the first stage to obtain a baseline model. The baseline model is used to identify N2 rice images, filtering out difficult samples; difficult samples are those rice grains not detected by the baseline model. For the difficult samples, this invention uses a region segmentation algorithm to extract the rice regions of the difficult samples, and superimposes each rice region onto the background image to obtain a combined image set. The rice regions are rotated, and rotation stops when the intersection-union ratio (IU / U) of the rice region of the difficult sample with the neighboring rice grains in the background image is within a certain range, thereby achieving a controllable dense stacking effect. Rice regions with different lighting directions are superimposed, and Gaussian shadows and mask erasure are added to simulate occlusion and lighting changes. The system combines a synthetic image set with the initial image set and performs enhancement processing, including random rotation, random perspective transformation, random scaling, Gaussian blur, adding white point noise, adding black point noise, and various brightness adjustments. The enhanced image set is then used to retrain the baseline model, adjusting model parameters and improving its ability to recognize difficult samples. The rice grain image to be detected is then input into the final detection model for recognition, yielding the rice grain identification result. This invention employs a two-stage data augmentation strategy, enabling the model to learn richer grain morphology, stacking patterns, and illumination variation features. The trained final detection model significantly improves the detection accuracy for small targets, occluded grains, and adhered grains. Attached Figure Description

[0017] Figure 1 This is a flowchart of the rice identification method based on the YOLOv11 model and two-stage data augmentation of the present invention; Figure 2 This is the original image of the rice grains in this invention before image transformation; Figure 3 This is the result of rotating the rice image of the present invention; Figure 4 This is the result of perspective transformation of the rice image of the present invention; Figure 5 This is a scaled-down image of the rice grains from the present invention. Figure 6 This is the result of Gaussian blurring the rice image of the present invention; Figure 7 This is the result image of the rice grain image after adding black dot noise according to the present invention; Figure 8 This is the result of darkening the overall brightness of the rice image in this invention; Figure 9This is the result image of the rice grain image after the overall brightness has been increased according to the present invention; Figure 10 This is a diagram showing the rice grain identification results of the present invention; Figure 11 This is a diagram showing the rice recognition result after the suppression of repeated detection boxes according to the present invention. Detailed Implementation

[0018] Preferred embodiments of the invention will now be described in more detail with reference to the accompanying drawings. While preferred embodiments of the invention are shown in the drawings, it should be understood that the invention can be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that the invention will be thorough and complete, and will fully convey the scope of the invention to those skilled in the art.

[0019] Example 1 like Figure 1 As shown, this embodiment provides a rice identification method based on the YOLOv11 model and two-stage data augmentation, including: S1: Perform image transformation on N1 rice images to obtain the initial image set.

[0020] S2: The YOLOv11 model is trained in the first stage using the initial image set to obtain the baseline model.

[0021] S3: The benchmark model is used to identify N2 rice images and filter out difficult samples; the difficult samples are those that the benchmark model does not detect rice in.

[0022] S4: Use a region segmentation algorithm to extract the rice region of the difficult sample, and superimpose each rice region onto the background image to obtain a combined image set.

[0023] S5: Adjust the occlusion and illumination conditions of the combined image set to obtain a synthetic image set.

[0024] S6: Enhance the synthesized image set and the initial image set to obtain an enhanced image set.

[0025] S7: The base model is trained a second time using the enhanced image set to obtain the final detection model.

[0026] S8: Input the image of the rice grain to be detected into the final detection model for recognition, and obtain the rice grain recognition result.

[0027] This embodiment uses the YOLOv11m model, which is a medium-sized object detection model in the YOLOv11 series. The backbone network employs an improved C3k2 module and a C2PSA attention mechanism to enhance feature extraction capabilities for small objects. The neck structure uses a multi-scale feature pyramid to improve robustness to detecting objects of different sizes. The head branch supports unified detection, segmentation, pose estimation, bounding box rotation, and classification tasks. Its lightweight design significantly reduces the number of parameters and computational overhead while maintaining high accuracy, making it suitable for edge deployment.

[0028] The step of overlaying each of the rice paddies onto the background image to obtain a combined image set includes: S42: Select a background image containing multiple grains of rice; S43: Pre-overlay the M rice paddy regions onto the background image, and detect the intersection-over-union ratio (IoU) between the rice paddy regions and the rice paddies already placed in the background image; wherein the illumination directions of the M rice paddy regions are different; S44: If the crossover ratio is less than the first overlap threshold or greater than the second overlap threshold, then the rice region is rotated until the crossover ratio is greater than or equal to the first overlap threshold and less than or equal to the second overlap threshold, to obtain the rotated rice region; the second overlap threshold is greater than the first overlap threshold. S45: Using Poisson fusion, the rotated rice region is fused into the background image to obtain a combined image set.

[0029] Before S42, step S41 is included: extracting the rice region of the difficult sample. The difficult samples are manually identified, and the LabelImg tool is used to mark the detection boxes of the difficult samples in which no rice is detected. The difficult samples are assigned a first-class label, and the coordinates of the four vertices of the detection box of the difficult sample are stored. The detection box of the difficult sample is rectangular.

[0030] After labeling, read the coordinates of the four vertices of each difficult sample corresponding to the first type of label, and crop out the rice region of each difficult sample according to the coordinates of the four vertices.

[0031] Select another background image containing multiple rice grains. Randomly select M center points in the background image, and pre-overlay a rice grain region at each center point. After pre-overlay, detect the cross-union ratio (CUI) between each pre-overlayed rice grain region in the background image and its neighboring already placed rice grains. The CUI represents the extent of overlap between the two regions. The already placed rice grains refer to the rice grains in the background image before the pre-overlayed rice grain regions.

[0032] In this embodiment, the first overlap threshold is 0.3 and the second overlap threshold is 0.7. When the IoU between each pre-stacked rice region and all adjacent placed rice regions is greater than or equal to 0.3 and less than or equal to 0.7, the rotation of the corresponding rice region is stopped, and the rotated rice region is obtained, thereby achieving a controllable dense stacking effect.

[0033] We introduce edge feathering processing based on Poisson fusion, using the rotated rice region as the foreground image. This allows the edges of the rotated rice region to naturally transition into the background region, preserving the local texture of the rotated rice region and avoiding synthesis artifacts.

[0034] The method for distinguishing the upper and lower layers of rice in each composite image in the image set is to calculate the grain of each rice grain. i The rice grains were selected based on their height difference with the rice above them. i Above and rice grains i Target rice grains with a height difference less than or equal to the height difference threshold j Target rice j rice grain i Projecting the length of the projection line onto the horizontal line containing the major axis yields the length of the projection line. Calculate the projection line length by dividing by the grain size. i The ratio of the grain length to the target rice grain length; if the ratio is greater than a certain threshold, then the target rice grain will be... j The rice grains were separated and placed in the upper layer. i The rice was divided into lower layers.

[0035] A portion of the visible area of ​​the lower layer of rice is randomly selected for mask erasure to simulate a scenario where the lower layer of rice is completely or partially occluded by the upper layer. Specifically, a mask with a value of 0 is used to completely obscure the lower layer of rice in the composite image, simulating the situation where the lower layer is completely occluded by the upper layer. Alternatively, a portion of the mask on the lower layer of rice in the composite image is randomly erased, and the image information of the erased area is restored to simulate the situation where the lower layer is partially occluded by the upper layer. The rice in the composite image includes rotated rice and the original placed rice. The j-th target rice is... j The height in the composite image is greater than the i-th grain. iThe height of the rice grains in the composite image is determined by combining the height difference between adjacent rice grains and the ratio of the projection length of the target rice grain along its long axis to the length of the rice grain itself. This method marks the upper and lower layers of rice grains in each composite image, taking into account the occlusion caused by the actual location distribution and the characteristics of light propagation. Therefore, rice grains that are occluded are designated as the lower layer, rice grains that cause occlusion are designated as the upper layer, and rice grains without occlusion remain unchanged (i.e., no masking is performed). Masking is performed by first covering the lower layer with a mask containing all zero values, then randomly selecting a portion of the lower layer as the visible area, and finally removing the mask from the visible area. The direction of the long axis is the same as the grain length direction, and the grain length refers to the maximum projected length of the rice grain from its base to its tip.

[0036] Given that the lighting directions of M rice paddies are all different, Gaussian shadows are randomly added to the combined image of the merged and rotated rice paddies to simulate the lighting changes in a real rice pile, generating multiple images of rice paddies containing complex scenes such as stacking and occlusion. The Gaussian shadows are added as follows: the outline of the target object is copied to a pure black layer, offset in a specified direction (e.g., lower right), then a Gaussian blur is applied, and finally overlaid with the original image. The blurred shadows simulate the penumbra of natural light. The standard deviation of the Gaussian blur is 5-15, which controls the spread of the shadow; the larger the value, the softer the shadow.

[0037] This embodiment provides a rice recognition method based on the YOLOv11 model and two-stage data augmentation, which includes image transformation of N1 rice images to obtain an initial image set. Image transformation expands the sample size and enhances the adaptability of the YOLOv11 model to rotation, perspective, scaling, and noise. The initial image set is used to train the YOLOv11 model in the first stage, obtaining a baseline model. The baseline model is then used to identify N2 rice images, filtering out difficult samples; these are samples where the baseline model failed to detect rice. For these difficult samples, a region segmentation algorithm is used to extract the rice regions, and each rice region is superimposed onto the background image to obtain a combined image set. The rice regions are rotated, stopping when the intersection-union ratio (IU / U) of the rice region of a difficult sample with its neighboring rice in the background image is within a certain range, thus achieving a controllable dense stacking effect. Rice regions with different lighting directions are superimposed, and Gaussian shadows and mask erasure are added to simulate occlusion and lighting changes. The system combines a synthetic image set with the initial image set and performs enhancement processing, including random rotation, random perspective transformation, random scaling, Gaussian blur, adding white point noise, adding black point noise, and various brightness adjustments. The enhanced image set is then used to retrain the baseline model, adjusting model parameters and improving its ability to recognize difficult samples. The rice grain image to be detected is then input into the final detection model for recognition, yielding the rice grain identification result. This invention employs a two-stage data augmentation strategy, enabling the model to learn richer grain morphology, stacking patterns, and illumination variation features. The trained final detection model significantly improves the detection accuracy for small targets, occluded grains, and adhered grains.

[0038] Example 2 This embodiment provides a rice identification method based on the YOLOv11 model and two-stage data augmentation. This embodiment describes the differences between it and Embodiment 1.

[0039] The process of performing image transformation on N1 rice images to obtain an initial image set includes: Each rice image is subjected to various transformations, including random rotation, random perspective transformation, random scaling, Gaussian blur, addition of white point noise, addition of black point noise, and brightness adjustment, to obtain an initial image set. White point noise involves randomly adding white points with a value of 255 to the image, and black point noise involves randomly adding black points with a value of 0. The original rice image is shown below. Figure 2 As shown, the result of the image transformation is as follows: Figures 3-9 As shown.

[0040] The step of enhancing the synthesized image set and the initial image set to obtain an enhanced image set includes: S61: Combine the synthesized image set and the initial image set to obtain the combined image set; S62: Perform random rotation, random perspective transformation, random scaling, Gaussian blur, adding white point noise, adding black point noise, and brightness adjustment on the combined image set to obtain an enhanced image set.

[0041] For example, in the initial sample of this invention, N1 of the N1 rice images is 6. Image transformation is performed on the 6 rice images. The image transformation of each rice image uses a different mapping set, so that the total number of images in the initial image set is expanded to 1056.

[0042] Define the transformation set T = {t1, t2, ..., t} n}, where t1 represents the first kind of transformation, t2 represents the second kind of transformation, and t n This represents the nth type of transformation. The transformation of the rice image in step S1 and the transformation of the combined image in steps S61-S62 both employ a transformation set. Each rice image and each combined image uses one type of transformation from the transformation set. There is a one-to-one correspondence between the rice images and the transformation types in the transformation set, and also a one-to-one correspondence between the combined images and the transformation types in the transformation set. For example, the first type of transformation t1 includes four operations: random rotation, random scaling, Gaussian blur, and adding white point noise; the second type of transformation t2 includes two operations: random perspective transformation and adding black point noise. The first rice image undergoes the third type of transformation, and the second rice image undergoes the first type of transformation. The first combined image undergoes the nth type of transformation, and the second combined image undergoes the second type of transformation.

[0043] The first stage of training of the YOLOv11 model is performed using the initial image set, including: Train a YOLOv11 model using the following two-stage loss function: (1) (2) (3) Where Loss represents the two-stage loss function, IoU represents the intersection-over-union ratio, and b p Represents the prediction box, b g Represents the true bounding box. represents the square of the Euclidean distance between the predicted bounding box and the ground truth bounding box; c represents the diagonal distance of the smallest closure region that simultaneously contains both the predicted bounding box and the ground truth bounding box. Represents the balance parameters. Indicates the aspect ratio consistency parameter; y i p represents the value of the i-th type of label. iThis represents the probability of the YOLOv11 model predicting the i-th class, where log represents the logarithmic function with base to the natural constant; arctan represents the arctangent function; and w... g h represents the width of the actual bounding box. g Indicates the height of the actual bounding box; w p h represents the width of the prediction box. p This indicates the height of the prediction box.

[0044] The two-stage loss function of this invention is applicable to both the first and second training phases. The two-stage loss function consists of two parts. The first part measures the overlap area between the predicted and ground truth boxes, as well as the distance between the center points of the two boxes and their aspect ratio. The second part is a cross-entropy loss function for multi-class classification, where the position corresponding to the target class is 1, and other positions are 0. That is, the position of the rice paddy region in the image is 1, and the position of the non-rice paddy region is 0. The first term of the two-stage loss function measures the scale of the detection box, making the predicted box closer in size to the ground truth box, thus improving the accuracy of the predicted box. Since incorrect labels only affect the logarithm of the predicted probability of the corresponding class, the second part of the two-stage loss function is robust to noisy data.

[0045] In the first stage of training, the initial image set is used as the training set, and the YOLOv11 model is trained based on the two-stage loss function until the number of training iterations is greater than or equal to the training iteration threshold, thus obtaining the baseline model.

[0046] In the second stage of training, the enhanced image set is used as the training set, and the baseline model is trained a second time based on the two-stage loss function until the recognition error rate of the baseline model is less than or equal to the recognition error rate threshold, thus obtaining the final detection model.

[0047] After the first stage of training, the baseline model was used to identify 161 rice images, i.e., N²=161. After adjusting the occlusion and lighting conditions, seven synthetic images containing complex scenes such as stacking and occlusion were generated. These seven synthetic images were then merged with the six rice images before the image transformation in step S1 to obtain a combined image set. The transform set T was then applied again to enhance the combined image set, generating 871 enhanced images. All enhanced images were used to train the baseline model a second time to obtain the final detection model.

[0048] Example 3 This embodiment provides a rice identification method based on the YOLOv11 model and two-stage data augmentation. This embodiment describes the differences between this embodiment and Embodiment 1 and Embodiment 2, based on Embodiment 1.

[0049] After obtaining the rice identification result, the process also includes: Count all detection boxes in the rice identification results; Calculate the distance function value between adjacent first and second detection boxes; where the confidence level of the first detection box is con1, the confidence level of the second detection box is con2, and con1 < con2; If the distance function value is less than the distance threshold, then the first detection box is removed.

[0050] The set of detection boxes for rice recognition results is B={b1,b2,...,b...} m}, the i-th detection box b i =(x i ,y i ,w i ,h i ,con i ), the j-th detection box b j =(x j ,y j ,w j ,h j ,con j ). x i Let y represent the x-coordinate of the i-th detection box. i w represents the ordinate of the i-th detection box. i h represents the width of the i-th detection box. i Represents the height of the i-th detection box, distance function Set a threshold. , It is 1.2 times the average width of the grain, for any ,like Then determine b i With b j To prevent duplicate detection, detection boxes with higher confidence levels are retained. The above detection box center distance detection method effectively suppresses duplicate recognition in dense scenes, further optimizing the final output of the model.

[0051] After obtaining the rice identification result, the process also includes: S91: Extract the particle size, aspect ratio, and integrity of each detected rice grain; S92: Rice with an aspect ratio less than a first aspect ratio threshold or greater than a second aspect ratio threshold is classified as first-category unqualified rice; the first aspect ratio threshold is less than the second aspect ratio threshold. S93: Rice with an integrity of less than 0.85 is classified as the second category of substandard rice; S94: Subtract twice the standard deviation of rice grain size from the average rice grain size in the training set to obtain the lower limit of grain size; add twice the standard deviation of rice grain size to the average rice grain size in the training set to obtain the upper limit of grain size. S95: Rice with a particle size smaller than the lower limit or larger than the upper limit is classified as the third category of unqualified rice.

[0052] Rice with an aspect ratio less than 1.5 or greater than 3.5 is classified as Category I substandard rice. 0.85 is used as the threshold for distinguishing Category II substandard rice, and rice with a particle size deviating from the training set mean ± 2 standard deviations is classified as Category III substandard rice. Category I substandard rice represents rice with abnormal aspect ratios, Category II substandard rice represents damaged rice, and Category III substandard rice represents rice with abnormal particle size.

[0053] Preferably, in order to enhance the YOLOv11 model's ability to identify incomplete rice grains in stacked occlusion scenarios, after filtering out difficult samples in step S3, artificially synthesized incomplete rice grain instances are added. The incomplete rice grain instances are generated by random cropping, edge erosion, and / or local mask erasure, so that the YOLOv11 model can learn the quality defect features of rice grains end-to-end.

[0054] like Figure 10 As shown, the number of rice grains identified in steps S1-S8 of the method of this invention is 177. Figure 11 As shown, after center distance detection of adjacent detection boxes, 4 duplicate detection boxes were suppressed, and the number of rice grains identified was 173, effectively preventing duplicate identification of rice grains.

[0055] This embodiment also provides a rice identification system based on the YOLOv11 model and two-stage data augmentation, including: The image transformation module is used to transform N1 images of rice to obtain an initial image set. The first-stage training module is used to perform the first-stage training of the YOLOv11 model using the initial image set to obtain the baseline model. The difficult sample screening module is used to identify N2 rice images using the benchmark model and screen out difficult samples; the difficult samples are those that the benchmark model did not detect as rice. The rice region overlay module is used to extract the rice regions of the difficult samples using a region segmentation algorithm, and overlay each rice region onto the background image to obtain a combined image set. An image adjustment module is used to adjust the occlusion and lighting conditions of the combined image set to obtain a synthetic image set; The image enhancement module is used to enhance the synthesized image set and the initial image set to obtain an enhanced image set; The second-stage training module is used to perform secondary training on the baseline model using the enhanced image set to obtain the final detection model; the rice recognition module is used to input the rice image to be detected into the final detection model for recognition to obtain the rice recognition result.

[0056] This embodiment also provides a computer device, which may be a server. The computer device includes a processor, memory, a network interface, and a database connected via a system bus. The processor in this computer design provides computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The network interface of the computer device is used for communication with external terminals via a network connection.

[0057] This embodiment also provides a computer-readable storage medium storing a computer program thereon. When the computer program is executed by a processor, it implements the rice identification method based on the YOLOv11 model and two-stage data augmentation described in any one of Embodiments 1-3. It is understood that the computer-readable storage medium in this embodiment can be a volatile readable storage medium or a non-volatile readable storage medium.

[0058] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, apparatus, article, or method that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, apparatus, article, or method. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, apparatus, article, or method that includes that element.

[0059] The above description is only a preferred embodiment of this application and does not limit the patent scope of this application. Any equivalent structural or procedural changes made based on the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.

Claims

1. A rice identification method based on the YOLOv11 model and two-stage data augmentation, characterized in that, include: Perform image transformation on N1 images of rice to obtain an initial image set; The YOLOv11 model was trained in the first stage using the initial image set to obtain the baseline model; The benchmark model is used to identify N2 rice images and filter out difficult samples; the difficult samples are those that the benchmark model does not detect rice in. Extract the rice grain regions from the difficult samples, and overlay each rice grain region onto the background image to obtain a combined image set; Adjust the occlusion and illumination conditions of the combined image set to obtain a synthetic image set; The synthesized image set and the initial image set are enhanced to obtain an enhanced image set; The base model is trained a second time using the enhanced image set to obtain the final detection model; The image of the rice grain to be detected is input into the final detection model for recognition, and the rice grain recognition result is obtained.

2. The rice identification method based on the YOLOv11 model and two-stage data augmentation according to claim 1, characterized in that, The step of overlaying each of the rice paddies onto the background image to obtain a combined image set includes: Select a background image containing multiple rice grains; M rice paddy regions are pre-overlaid on the background image, and the intersection-union ratio (IUU) of the rice paddy regions and the rice paddies already placed in the background image is detected; wherein, the illumination directions of the M rice paddy regions are different, and M≥1; If the cross-over ratio is less than the first overlap threshold or greater than the second overlap threshold, the rice region is rotated until the cross-over ratio is greater than or equal to the first overlap threshold and less than or equal to the second overlap threshold, resulting in a rotated rice region; the second overlap threshold is greater than the first overlap threshold. The rotated rice paddy region is merged into the background image using a Poisson fusion method to obtain a combined image set.

3. The rice identification method based on the YOLOv11 model and two-stage data augmentation according to claim 2, characterized in that, The process of adjusting the occlusion and illumination conditions of the combined image set to obtain the synthetic image set includes: The upper and lower layers of rice in each composite image in the composite image set are distinguished based on the height difference between adjacent rice grains and the length of the projection line. The visible area of ​​the lower layer of rice was randomly selected and masked to simulate a scenario where the lower layer of rice was completely or partially obscured by the upper layer of rice. Gaussian shadows are added to each composite image in the composite image set to simulate lighting variations in a real haystack.

4. The rice identification method based on the YOLOv11 model and two-stage data augmentation according to claim 1, characterized in that, The step of enhancing the synthesized image set and the initial image set to obtain an enhanced image set includes: The synthesized image set and the initial image set are combined to obtain the combined image set; The combined image set is subjected to any of the following transformations: random rotation, random perspective transformation, random scaling, Gaussian blur, addition of white point noise, and addition of black point noise, to obtain an enhanced image set.

5. The rice identification method based on the YOLOv11 model and two-stage data augmentation according to claim 1, characterized in that, The first stage of training the YOLOv11 model using the initial image set includes: Train a YOLOv11 model using the following two-stage loss function: ; ; ; Where Loss represents the two-stage loss function, IoU represents the intersection-over-union ratio, and b p Represents the prediction box, b g Represents the true bounding box. represents the square of the Euclidean distance between the predicted bounding box and the ground truth bounding box; c represents the diagonal distance of the smallest closure region that simultaneously contains both the predicted bounding box and the ground truth bounding box. Represents the balance parameters. Indicates the aspect ratio consistency parameter; y i p represents the value of the i-th tag, total represents the total number of tag categories, and p i This represents the probability of the YOLOv11 model predicting the i-th class, where log represents the logarithmic function with base to the natural constant; arctan represents the arctangent function; and w... g h represents the width of the actual bounding box. g Indicates the height of the actual bounding box; w p h represents the width of the prediction box. p This indicates the height of the prediction box.

6. The rice identification method based on the YOLOv11 model and two-stage data augmentation according to claim 5, characterized in that, The step of using the enhanced image set to perform secondary training on the baseline model to obtain the final detection model includes: The enhanced image set is used as the training set, and the baseline model is trained a second time based on the two-stage loss function until the recognition error rate of the baseline model is less than or equal to the recognition error rate threshold, thus obtaining the final detection model.

7. The rice identification method based on the YOLOv11 model and two-stage data augmentation according to claim 1, characterized in that, After obtaining the rice identification result, the process also includes: Count all detection boxes in the rice identification results; Calculate the distance function value between adjacent first and second detection boxes; where the confidence level of the first detection box is con1, the confidence level of the second detection box is con2, and con1 < con2; If the distance function value is less than the distance threshold, then the first detection box is removed.

8. The rice identification method based on the YOLOv11 model and two-stage data augmentation according to claim 1, characterized in that, The process of performing image transformation on N1 rice images to obtain an initial image set includes: For each rice image, perform any number of transformations, including random rotation, random perspective transformation, random scaling, Gaussian blur, adding white noise, and adding black noise, to obtain the initial image set.

9. The rice identification method based on the YOLOv11 model and two-stage data augmentation according to claim 6, characterized in that, After obtaining the rice identification result, the process also includes: Extract the grain size, aspect ratio, and integrity of each detected rice grain; Rice with an aspect ratio less than a first aspect ratio threshold or greater than a second aspect ratio threshold is classified as first-category unqualified rice; the first aspect ratio threshold is less than the second aspect ratio threshold. Rice with an integrity score of less than 0.85 is classified as the second category of substandard rice. Subtracting twice the standard deviation of rice grain size from the average rice grain size in the training set yields the lower limit of grain size; adding twice the standard deviation of rice grain size to the average rice grain size in the training set yields the upper limit of grain size. Rice with a particle size smaller than the lower limit or larger than the upper limit is classified as the third category of substandard rice.

10. A rice identification system based on the YOLOv11 model and two-stage data augmentation, characterized in that, include: The image transformation module is used to transform N1 images of rice to obtain an initial image set. The first-stage training module is used to perform the first-stage training of the YOLOv11 model using the initial image set to obtain the baseline model. The difficult sample screening module is used to identify N2 rice images using the benchmark model and screen out difficult samples; the difficult samples are those that the benchmark model did not detect as rice. The rice region overlay module is used to extract the rice regions of the difficult samples using a region segmentation algorithm, and overlay each rice region onto the background image to obtain a combined image set. An image adjustment module is used to adjust the occlusion and lighting conditions of the combined image set to obtain a synthetic image set; The image enhancement module is used to enhance the synthesized image set and the initial image set to obtain an enhanced image set; The second-stage training module is used to perform secondary training on the baseline model using the enhanced image set to obtain the final detection model. The rice grain recognition module is used to input the image of the rice grain to be detected into the final detection model for recognition, and obtain the rice grain recognition result.