Rice ear grain counting and rice yield estimating method and device based on rotating target detection and medium
By combining the rice ear grain counting method based on rotation target detection and machine learning model, the problems of complex grain detection and inaccurate yield prediction in the prior art are solved, and fast and accurate grain detection and rice yield prediction are achieved.
Patent Information
- Application Number
- CN202411947249.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-27
- Publication Date
- 2025-05-30
AI Technical Summary
In the prior art, grain detection technology is relatively small and the counting method is complex, which can easily cause grain damage or loss, and it is difficult to accurately predict rice yield.
The rice ear grain counting method based on rotation target detection was adopted, and the YOLOv8n_OBB model was lightweighted and improved through the YOLOv8n_OBB model was constructed, and the YOLO-Grain_OBB model was trained in combination with the rice ear data set, and the grain phenotype characteristics were extracted, and the yield was estimated through the machine learning model.
Fast and high-precision grain identification and counting are achieved, and rice yields are accurately predicted through grain phenotype characteristics, overcoming the shortcomings of complex algorithms and large errors in the prior art.
Smart Images

Figure CN120071329A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of rice grain detection and yield prediction in rice images, and specifically relates to a method, device and medium for rice ear grain counting and rice yield estimation based on rotating object detection. Background Art
[0002] Rice is one of the main staple foods for many people around the world, so the yield and quality of rice have always been highly concerned. The factors affecting rice yield are complex and diverse, such as a series of complex genetic regulations and environmental changes. The number of panicles, the number of grains per panicle and the grain weight are three important factors constituting rice yield. Research shows that the number of grains per panicle directly affects rice yield. In addition, the number of grains per panicle is also an important indicator for breeding rice varieties. Therefore, the rapid and accurate detection of rice grains is of great significance for crop yield prediction, and is also of great significance for crop management, food security and policy making.
[0003] Traditional rice counting methods mainly rely on threshing counting. Rice ears are either manually threshed and counted or threshed by a threshing machine. Then a cleaning system is used to separate the rice grains from the straw and grain impurities. Finally, after the rice grains are separated and cleaned, the rice grains are counted by an optoelectronic device, or the rice grains are flattened on an imaging platform and counted by an algorithm based on image processing.
[0004] With the rise of smart agriculture, more and more digital image processing technologies are used for the recognition and counting of rice ears and grains. However, basically most of them are for the recognition of rice ears, and there are relatively few grain detection technologies. Moreover, these grain counting methods are generally used during the harvest period, and after threshing, technologies such as spectral analysis or digital image processing are used for analysis. Not only are the algorithms complex, but also grain damage or loss may occur during threshing, or during harvesting, the harvesting is not clean, resulting in grains still adhering to the rice ears, leading to large errors. And currently, there are not many methods for estimating yield through grain traits. Therefore, it is necessary to develop a method for grain detection and counting that is fast and accurate, and a method for yield analysis through the phenotypic characteristics of grains. Summary of the Invention
[0005] The first object of the present invention is to overcome the disadvantages and deficiencies existing in the prior art, and provide a method for rice ear grain counting and rice yield estimation based on rotating object detection, which can quickly and accurately identify and count grains, and accurately predict rice yield through grain phenotypic characteristics.
[0006] The second object of the present invention is to provide a computing device.
[0007] The third object of the present invention is to provide a storage medium.
[0008] The object of the present invention is achieved by the following technical solutions: A method for counting rice grains on rice panicles and estimating rice yield based on rotational object detection, comprising the steps:
[0009] S1. Obtain a rice panicle dataset: Construct a database of rice panicle images and corresponding yields, and perform preprocessing;
[0010] S2. Lightweight improve the YOLOv8n_OBB model to construct the YOLO-Grain_OBB model;
[0011] S3. Use the rice panicle dataset to train, validate and test the YOLO-Grain_OBB model to construct a rice panicle grain detection model;
[0012] S4. Identify and count the grains on the test set through the rice panicle grain detection model, and output the rotational object detection boxes of the grains; According to the information of the rotational object detection boxes of the grains, extract and screen the preferred grain phenotypic features with yield characterization ability;
[0013] S5. Select different machine learning models, fit various combinations of preferred grain phenotypic features and yield data, construct different yield prediction models, and verify the model performance to obtain the optimal yield prediction model.
[0014] Preferably, step S1 specifically includes the steps:
[0015] S11. Rice is planted in plots, and different planting patterns are adopted in different planting plots. At the rice harvesting stage, according to the standard agronomic requirements, the yield of each planting plot is statistically counted and the yield data is recorded;
[0016] S12. At different rice growth stages, collect rice panicle images of each planting plot. Among them, the collection is carried out in a uniformly random distribution manner. When collecting, place the rice panicles on a backboard with a standard grid, and the collection camera is perpendicular to the backboard.
[0017] Preferably, in step S1, the preprocessing process includes:
[0018] The first step: Use the open-source image annotation tool RoLabelImg to draw the minimum bounding rectangle around each grain and generate an xml file containing the marker box information;
[0019] The second step: Perform data augmentation on the rice panicle dataset;
[0020] The third step: Divide the rice panicle dataset into a training set, a validation set, and a test set according to a ratio of 8:1:1.
[0021] Preferably, step S2 specifically includes the steps:
[0022] S21. Replace the SPPF module of YOLOv8n_OBB with the SimSPPF module to improve the computing speed of the network;
[0023] S22. Introduce the VoVGSCSP module based on GSConv in the Neck network part of YOLOv8n_OBB to reduce the computational load of the model;
[0024] S23. Improve the C2f module of YOLOv8n_OBB by introducing the distribution shift convolution DShConv to use quantization and distribution shift to simulate the behavior of the convolutional layer;
[0025] S24. Introduce the depthwise separable convolution DSConv to reduce the model volume.
[0026] Preferably, step S3 specifically includes the steps:
[0027] S31. Train the YOLO-Grain_OBB model with the training set and the validation set;
[0028] S32. Input the test set into the trained YOLO-Grain_OBB model, and evaluate the model through the precision, recall rate, total number of parameters, and mean average precision of the model.
[0029] Preferably, step S4 specifically includes the steps:
[0030] Step S41. Obtain the scaling factor between the image pixels and the distance in each rotated object detection frame to unify and correct the phenotypic characteristics of the rice panicles;
[0031] Step S42. According to the four-point coordinates of the rotated object detection frame, solve the predicted rotation angle, and calculate the width w and height h of the rotated object detection frame through the Euclidean distance, and obtain the diagonal r of the rotated object detection frame;
[0032] Step S43. Obtain the pixels occupied by the diagonal r of the rotated object detection frame, and calculate the corrected length r', width corrected length w', and height corrected length h' of the diagonal of the rotated object detection frame according to the pixels and the corresponding scaling factor;
[0033] Step S44. Approximate the rice panicle grains as an ellipsoid with equal major axis and minor axis, and fit the preferred grain phenotypic characteristics, where the grain phenotypic characteristics include the perimeter L of the grain cross-section, the area A of the grain cross-section, the surface area S of the grain, the volume V of the grain, the major axis length of the grain, the minor axis length of the grain, and the number of rice panicle grains.
[0034] Preferably, step S41 specifically includes the steps:
[0035] S411. Obtain the length, width, and diagonal length of the standard grid of the rice panicle image background;
[0036] S412. Detect the pixels occupied by the length and width of the standard grid, and calculate the pixels occupied by the diagonal;
[0037] S413. Divide the diagonal length of the standard grid by the pixels occupied by the diagonal to obtain the scaling factor of the picture pixels to the distance.
[0038] Preferably, step S5 specifically includes:
[0039] S51. Select different machine learning models, including least squares fitting, random forest, multi-layer perceptron algorithm, and long short-term memory network. Fit different preferred grain phenotypic feature combinations with actual yield data to obtain different yield prediction models;
[0040] S52. Use the cross-validation method to verify the model performance and obtain the optimal yield prediction model.
[0041] A computing device includes a processor and a memory for storing programs executable by the processor. When the processor executes the programs stored in the memory, it implements the above-mentioned rice panicle grain counting and rice yield estimation method based on rotated object detection.
[0042] A storage medium stores a program, which when executed by a processor, implements the above-mentioned rice panicle grain counting and rice yield estimation method based on rotated object detection.
[0043] The present invention has the following advantages and effects compared with the prior art:
[0044] (1) The present invention provides a rice panicle grain counting and rice yield estimation method based on rotated object detection. First, after lightweight improvement of the YOLOv8n_OBB model to obtain the YOLO-Grain_OBB model, then use the constructed rice panicle dataset to train the model to construct a rice panicle grain detection model. This model can quickly identify and count rice panicle grains, and further extract the phenotypic characteristics of the grains according to the output results; finally, construct machine learning models of different phenotypic feature combinations and grain yields, and screen out the optimal yield prediction model. This yield prediction model can realize yield analysis through the phenotypic characteristics of grains, and has high speed and accuracy. The present invention overcomes the deficiencies of complex algorithms and large errors in the prior art when using techniques such as spectral analysis or digital image processing for grain recognition and technology.
[0045] (2) The present invention makes a lightweight improvement to the YOLOV8n model for the recognition and counting of grains under dense small targets, including the following lightweight modules: SimSPPF, VoVGSCSP, C2f_DShC2D, and DSConv, which reduce the number of parameters of the model, can effectively improve the ability to extract features of small targets, and at the same time have a small amount of computation and a fast model training speed.
[0046] (3) The present invention detects the traits (phenotypic characteristics) of rice panicle grains through the improved rotating object detection model YOLO-Grain_OBB, and then combines different combinations of grain phenotypic characteristics with a machine learning model to verify and screen to obtain the optimal rice yield prediction model, greatly improving the efficiency and accuracy of yield estimation. Description of the Drawings
[0047] Figure 1 is a schematic flow chart of the rice panicle grain counting and rice yield estimation method based on rotating object detection according to the present invention;
[0048] Figure 2 is a schematic diagram of the rice panicle grain detection model predicting and outputting a rotating object detection frame according to a rice panicle image of the present invention, where (a) is the rice panicle image and (b) is the rotating object detection frame;
[0049] Figure 3 is a schematic diagram of the shape of approximating the rice panicle grains as an ellipsoid with equal major and minor axes in Example 1 of the present invention. Detailed Embodiments
[0050] The present invention will be further described in detail below in conjunction with the embodiments and the drawings, but the embodiments of the present invention are not limited thereto.
[0051] Example 1
[0052] As Figure 1 shown is a schematic flow chart of the rice panicle grain counting and rice yield estimation method based on rotating object detection, including the steps:
[0053] S1. Obtain a rice panicle data set: construct a database of rice panicle images and corresponding yields, and perform preprocessing;
[0054] S2. Make a lightweight improvement to the YOLOv8n_OBB model to construct a YOLO-Grain_OBB model;
[0055] S3. Use the rice panicle data set to train, validate, and test the YOLO-Grain_OBB model to construct a rice panicle grain detection model;
[0056] S4. Use the rice panicle grain detection model to identify and count the grains in the test set, and output the rotated object detection boxes of the grains; according to the information of the rotated object detection boxes of the grains, extract and screen the preferred grain phenotypic characteristics with yield characterization ability.
[0057] S5. Select different machine learning models, fit various combinations of preferred grain phenotypic characteristics and yield data to construct different yield prediction models, and verify the model performance to obtain the optimal yield prediction model.
[0058] Specifically, after the present invention performs lightweight improvement on the YOLOv8n_OBB model to obtain the YOLO-Grain_OBB model, it is then trained using the constructed rice panicle dataset to construct a rice panicle grain detection model. This model can quickly identify and count the rice panicle grains, and further extract the phenotypic characteristics of the grains according to the output results; finally, construct machine learning models for different combinations of phenotypic characteristics and grain yields, and screen out the optimal yield prediction model. This yield prediction model can achieve yield analysis through the phenotypic characteristics of the grains, and has high speed and accuracy. The present invention overcomes the deficiencies of the prior art in which the algorithms are complex and the errors are large when using technologies such as spectral analysis or digital image processing for grain recognition and technology.
[0059] Step S1 specifically includes the following steps:
[0060] S11. The rice is planted in plots, and different planting plots adopt different planting patterns. At the rice harvest stage, according to the standard agronomic requirements, the yield of each planting plot is statistically analyzed, and the yield data is recorded.
[0061] S12. At different rice growth stages, collect rice panicle images of each planting plot. Among them, the collection is carried out in a uniformly random distribution manner. When collecting, place the rice panicle on a backboard with a standard grid, and the collection camera is perpendicular to the backboard.
[0062] Specifically, to improve the generality of the sample data, different planting patterns include using different rice varieties, different planting densities, and different fertilization levels; to increase the diversity of rice panicle samples, collect rice panicle images in the natural field environment and under different conditions. Different conditions include collecting images at different time periods and sunlight conditions. Different time periods are such as 8:30 - 12:00, 13:30 - 16:00, and 17:00 - 18:00; it also includes collecting under different weather conditions, such as sunny and cloudy days; it also includes that the shooting distance range between the rice panicle and the collection camera is 10 cm to 50 cm.
[0063] In this embodiment, when collecting rice panicle pictures, such as Figure 2As shown in (a) therein, the rice panicles are placed on a backboard with scales of standard grids (i.e., standard meshes). Field testers can use a smartphone or a camera to collect images of the rice panicles. The number of images collected for each planting plot is 30 - 50, and finally, the number of images collected for each planting plot is recorded. According to the collected rice panicle images, a database of rice panicle images and corresponding yields for different planting plots is constructed. Among them, according to different growth stages, the rice panicle images collected from the same plot are placed in the same folder, and the corresponding rice yield data of the planting plot is recorded for subsequent modeling and prediction of rice yields.
[0064] In step S1, the process of the preprocessing includes:
[0065] The first step: Use the open-source image annotation tool RoLabelImg to draw the minimum bounding rectangle around each grain and generate an xml file containing the information of the marked boxes;
[0066] The second step: Perform data augmentation on the rice panicle dataset;
[0067] The third step: Divide the rice panicle dataset into a training set, a validation set, and a test set according to the ratio of 8:1:1.
[0068] Specifically, as Figure 2 shown in (a) therein, after using the tool to complete the marking of the minimum bounding rectangle, an xml file containing the information of each marked box is automatically generated using the corresponding file name image. The marked box information includes category, coordinate, and angle information. In this embodiment, the specifically recorded information includes the number of each label, the coordinates (x, y) of the center point of the label box, the width and height (w, h) of the label box, and the rotation angle angle.
[0069] To enhance the generalization ability and robustness of the rice panicle grain detection model, data augmentation is performed on the original rice panicle dataset. The methods of the data augmentation include: translation, horizontal or vertical flipping, clockwise or counterclockwise rotation by 90°, brightness enhancement, Gaussian noise, and grayscale conversion.
[0070] Step S2 specifically includes the steps:
[0071] S21. Replace the SPPF module of YOLOv8n_OBB with the SimSPPF module to improve the computing speed of the network;
[0072] S22. Introduce the VoVGSCSP module based on GSConv in the Neck network part of YOLOv8n_OBB to reduce the computational amount of the model;
[0073] S23. Improve the C2f module of YOLOv8n_OBB by introducing the Distributed Shift Convolution (DShConv) to use quantization and distributed shift to simulate the behavior of the convolutional layer;
[0074] S24. Introduce the Depthwise Separable Convolution (DSConv) to reduce the model size.
[0075] Specifically, based on the YOLOv8n_OBB model, this invention constructs an improved YOLO-Grain_OBB model to achieve the recognition and counting of grains under dense small targets. The lightweight improvement of the YOLOV8n model includes the following lightweight modules: SimSPPF, VoVGSCSP, C2f_DShC2D, and DSConv, which reduce the number of model parameters, effectively improve the ability to extract small target features, have a small computational cost, and a fast model training speed.
[0076] Regarding the SimSPPF module:
[0077] SimSPPF is an upgraded version of SPPF that uses the Conv-BN-ReLU (CBR) structure, where the convolutional layer is followed by batch normalization and ReLU activation. The ReLU activation accelerates the convergence of the model through simple calculations. YOLOv8 adopts the SpatialPyramid Pooling with Factorization (SPPF) module, which captures context information at multiple scales by pooling features with different window sizes. The SPPF module uses the Conv-BN-SiLU (CBS) structure, which is a convolutional layer followed by batch normalization and the Sigmoid Linear Unit (SiLU) function. SiLU has the characteristic of a smooth curve but also increases the computational complexity. The operation speed of a single CBR is about 18% faster than that of CBS. Therefore, SimSPPF achieves a better trade-off between accuracy and efficiency.
[0078] Regarding the VoVGSCSP module:
[0079] GSConv is a lightweight convolution that penetrates the information generated by standard convolution into the information generated by depth convolution through a uniform mixing operation. Its computational complexity is about half that of standard convolution, but its learning ability is comparable to the latter. Based on GSConv, the GSbottleneck module and the VoVGSCSP module are constructed. The design of the VoVGSCSP module reduces the computational cost of the model while ensuring the model accuracy.
[0080] Regarding the DShC2D module:
[0081] DShConv can easily replace the standard neural network architecture, achieving lower memory usage and higher computational speed. Based on DShConv, Bottleneck_DShC2D is constructed. Further, C2f_DShC2D is constructed, which effectively improves the ability to extract small target features while reducing the number of model parameters and computational volume. The distributed shift convolution DShConv aims to simulate the behavior of the convolutional layer using quantization and distributed offsets. DShConv divides the traditional convolutional kernel into two parts: the variable quantization kernel (VQK) and the distribution shift (DS). The tensor of VQK only retains variable-length integer values, with the same size as the original convolutional tensor. The purpose of the distribution shift is to move the distribution of VQK through the kernel distribution shifter (KDS) and the channel distribution shifter (CDS) to try to mimic the distribution of the original convolutional kernel so that the output matches the values of the original weight tensor.
[0082] Regarding the DSConv module:
[0083] DSConv is a lightweight convolution that can effectively reduce the number of model parameters and computational volume. In the case of having the same input as the standard convolution, the number of parameters is about 1 / N + 1 / D of the conventional convolution 2 k , where N represents the number of output channels, and D 2 k represents the size of the convolutional kernel. If the number of output channels is set to 5, the number of parameters of the depthwise separable convolution is about 0.31% of the standard convolution, and the computational volume can be greatly reduced. It divides the standard convolution into two steps: depthwise convolution and pointwise convolution. The depthwise convolution independently performs convolution operations on each channel of the input. The pointwise convolution refers to performing convolution operations using a 1×1 kernel to linearly combine the intermediate feature maps obtained from the depthwise convolution between channels, and finally obtaining the output feature map.
[0084] Through the above lightweight processing, the present invention can greatly improve the lightweight and recognition performance of the YOLOv8n_OBB model.
[0085] Step S3 specifically includes the steps:
[0086] S31. Train the YOLO-Grain_OBB model using the training set and the validation set;
[0087] S32. Input the test set into the trained YOLO-Grain_OBB model, and evaluate the model through the precision, recall, total number of parameters, and mean average precision of the model.
[0088] Specifically, in this embodiment, to better train and evaluate the model, the hyperparameters for model training are set as follows: the learning rate is 0.01, the batch_size is 16, the epoch is 100, cos_lr is True, the weight_decay is 0.0007, and the seed is 10.
[0089] To test the performance of the improved model YOLO-Grain_OBB, the selected metrics for the model include
[0090] Precision (P), Recall (R), the total number of parameters (Params), Giga Floating Point operations Per second (GFLOPs), and the mean average precision (mAP) are used to evaluate the model. The calculation formulas for each metric are as follows:
[0091]
[0092] Among them, mAP@0.5 represents the mean average precision calculated when the IoU threshold is 0.5;
[0093] mAP@0.5:0.95 refers to evaluating the performance of object detection using the mean average precision at multiple IoU thresholds with an interval of 0.05 between 0.5 and 0.95. TP (True Positive) indicates that the detected object is a real sample, FP (False Positive) indicates that the detected object is not a real sample but other data, FN (False Negative) indicates that there are real samples that are not detected, and n represents the number of categories.
[0094]
[0095] In the formula: C i represents the number of input channels, C o represents the number of output channels, K 2 represents the size of the convolutional kernel. H o ×W o represents the size of the output feature map of the current operation.
[0096] Step S4 specifically includes the following steps:
[0097] Step S41: Obtain the scaling factor between the picture pixels and the distance in the corresponding rotated object detection box to unify and correct the phenotypic characteristics of the rice panicles.
[0098] Step S42: According to the four-point coordinates of the rotated target detection box, solve the predicted rotation angle, calculate the width w and height h of the rotated target detection box through the Euclidean distance, and obtain the diagonal r of the rotated target detection box.
[0099] Step S43: Obtain the pixels occupied by the diagonal r of the rotated target detection box, and calculate the corrected length r' of the diagonal, the corrected length w' of the width, and the corrected length h' of the height of the rotated target detection box according to the pixels and the corresponding scaling factor.
[0100] Step S44: Approximate the rice panicle grains as an ellipsoid with equal major axis and minor axis, and fit the preferred grain phenotypic characteristics, where the grain phenotypic characteristics include the perimeter L of the grain cross-section, the area A of the grain cross-section, the surface area S of the grain, the volume V of the grain, the major axis length of the grain, the minor axis length of the grain, and the number of rice panicle grains.
[0101] Step S41 specifically includes the following steps:
[0102] S411: Obtain the length, width, and diagonal length of the standard grid of the rice panicle image background.
[0103] S412: Detect the pixels occupied by the length and width of the standard grid, and calculate the pixels occupied by the diagonal.
[0104] S413: Divide the diagonal length of the standard grid by the pixels occupied by the diagonal to obtain the scaling factor of the picture pixels to the distance.
[0105] Specifically, in this embodiment, the distance between the acquisition camera and the rice panicle is variable, so the resolution of the captured rice panicle grain images is different, and it is necessary to unify and correct the shape characteristics of the rice panicles at different shooting distances. At different shooting distances, the pixels occupied by the width and height of the standard grid (standard grid) are different, and the diagonal of the standard grid can take into account both the horizontal deviation and the vertical deviation, so the diagonal is selected as the standard scale for correction.
[0106] The first step, the process of obtaining the scaling factor of the picture pixels to the distance is as follows:
[0107] Using the YOLO-Grain_OBB rotation detection model, identify and count the grains in the test set. First, detect the standard grid, calculate the pixels occupied by the width and height of the standard grid, then calculate the pixels occupied by the diagonal of the standard grid, and then divide the actual length of the diagonal of the standard grid by its corresponding pixels to solve the scaling factor of the picture pixels to the distance. In this embodiment, the width and height of the adopted standard grid are both 1 cm, and the diagonal length is √2 cm.
[0108] The second step, the process of obtaining the corrected length according to the scaling factor is as follows:
[0109] According to the format of the rotated object detection box saved by YOLOv8n_OBB (i.e., the coordinates of the four corner points of the detection box), the rotation angle is calculated based on the four-point coordinates, the Pythagorean theorem, and the inverse trigonometric function. Then, the width w and height h of the detection box are calculated through the two-dimensional Euclidean distance, and further the length r of the hypotenuse, i.e., the diagonal, is obtained. The calculation formula for the Euclidean distance d between any two points A(x 1 , y 1 ) and B(x 2 , y 2 ) in the two-dimensional space is as follows: As shown in (b) of Figure 2 .
[0110] The third step, the process of obtaining the corrected length is as follows:
[0111] Multiply the number of pixels Q of the ratio of the diagonal r of the rotated object detection box by the corresponding scaling factor p to obtain the corrected length r' of the diagonal, i.e., Q * p = r'. Then, according to the predicted rotation angle and the properties of trigonometric functions, the corrected length w' of the width and the corrected length h' of the height of the rotated object detection box can be predicted, which respectively correspond to the true lengths of the width and height of the predicted grain, and the width w' and height h' of each grain are saved.
[0112] The fourth step, further extract different grain phenotypic characteristics with yield characterization ability:
[0113] As shown in Figure 3 , approximate the rice panicle as an ellipsoid with the major axis a and the minor axis c being equal, and fit the perimeter L of the grain cross-section, the area A of the grain cross-section, as well as the surface area S and volume V of the grain. The calculation formulas are as follows:
[0114]
[0115] A = πab,
[0116]
[0117] where a, b, and c are the minor axis, major axis, and middle axis of the ellipsoid, respectively.
[0118] And mine the preferred rice grain phenotypic characteristics or phenotypic parameters related to yield, including the perimeter L of the grain cross-section, the area A of the grain cross-section, as well as the surface area S and volume V of the grain mentioned above, and also including the length of the middle axis of the grain, the length of the short axis of the grain, and the number of grains in the rice panicle, and other phenotypic characteristics or trait characteristics with similarity. Through these preferred phenotypic characteristics, four factors related to rice yield are simulated, including the number of panicles per unit area, the number of grains per panicle, the seed setting rate, and the 1000-grain weight.
[0119] Step S5 specifically includes:
[0120] S51. Select different machine learning models, which include least squares fitting, random forest, multi-layer perceptron algorithm, and long short-term memory network. Fit different combinations of preferred grain phenotypic characteristics with actual yield data to obtain different yield prediction models.
[0121] S52. Use the cross-validation method to verify the model performance and obtain the optimal yield prediction model.
[0122] Specifically, the present invention selects traditional machine learning models, combines different preferred grain phenotypic characteristics as the input of each model, and outputs the yield prediction value. In this embodiment, to better train and evaluate the model, the original rice panicle dataset is divided into 10 subsets of equal size, and then according to the results of cross-validation, the best-performing model parameters or model structures are selected.
[0123] Adopt the coefficient of determination R 2 , root mean square error RMSE, relative root mean square error RRMSE, and mean absolute error MAE as the evaluation indicators of the rice yield estimation algorithm to evaluate the performance of the yield measurement model, as follows:
[0124]
[0125] In the formula: y i represents the actual value, represents the predicted value, represents the average value of the actual values, and n represents the number of samples; where R 2 is closer to 1, RMSE, RRMSE, and MAE are closer to 0, the better the model fitting degree, the better the prediction effect, and then select the yield prediction model with the best simulation fitting degree as the optimal yield prediction model.
[0126] Example 2
[0127] A computing device includes a processor and a memory for storing the programs executable by the processor. When the processor executes the programs stored in the memory, it implements the method for counting rice panicle grains and estimating rice yield based on rotational object detection described in Example 1, as follows:
[0128] S1. Obtain the rice panicle dataset: Construct a database of rice panicle images and corresponding yields, and perform preprocessing.
[0129] S2. Lightweight improve the YOLOv8n_OBB model to construct the YOLO-Grain_OBB model.
[0130] S3. Use the rice ear dataset to train, validate, and test the YOLO-Grain_OBB model, and construct a rice ear grain detection model;
[0131] S4. Use the rice ear grain detection model to identify and count grains in the test set, and output the rotated object detection boxes of the grains; according to the information of the rotated object detection boxes of the grains, extract and screen the preferred grain phenotypic features with yield characterization ability;
[0132] S5. Select different machine learning models, fit various combinations of preferred grain phenotypic features and yield data, construct different yield prediction models, and verify the model performance to obtain the optimal yield prediction model.
[0133] In the above process, the specific processing process is as described in Embodiment 1 and will not be elaborated here.
[0134] In this embodiment, the computing device can be a desktop computer, a laptop computer, a PDA handheld terminal, a tablet computer, a mobile phone, or other terminal devices.
[0135] Embodiment 3
[0136] A storage medium stores a program, which when executed by a processor, implements the method for rice ear grain counting and rice yield estimation based on rotated object detection described in Embodiment 1, as follows:
[0137] S1. Obtain a rice ear dataset: construct a database of rice ear images and corresponding yields, and perform preprocessing;
[0138] S2. Lightweight improve the YOLOv8n_OBB model to construct the YOLO-Grain_OBB model;
[0139] S3. Use the rice ear dataset to train, validate, and test the YOLO-Grain_OBB model, and construct a rice ear grain detection model;
[0140] S4. Use the rice ear grain detection model to identify and count grains in the test set, and output the rotated object detection boxes of the grains; according to the information of the rotated object detection boxes of the grains, extract and screen the preferred grain phenotypic features with yield characterization ability;
[0141] S5. Select different machine learning models, fit various combinations of preferred grain phenotypic features and yield data, construct different yield prediction models, and verify the model performance to obtain the optimal yield prediction model.
[0142] In the above process, the specific processing process is as described in Embodiment 1 and will not be elaborated here.
[0143] In this embodiment, the storage medium may be a magnetic disk, an optical disk, a computer memory, a read-only memory, a random access memory, a USB flash drive, a mobile hard disk, or other media.
[0144] The above embodiments are preferred embodiments of the present invention and do not limit the present invention. Any other changes or other equivalent replacement methods made without departing from the technical solution of the present invention are included in the protection scope of the present invention.
Claims
1. A method for counting rice ears and grains and estimating rice yield based on rotating target detection, characterized in that: Includes steps: S1. Obtain rice ear dataset: construct a database of rice ear images and corresponding yields, and perform preprocessing; S2. Improve the YOLOv8n_OBB model with lightweight features and build the YOLO-Grain_OBB model. S3. Use the rice ear dataset to train, verify and test the YOLO-Grain_OBB model to build a rice ear grain detection model; S4. Recognize and count the grains of the test set through the rice ear grain detection model, and output the rotating target detection frame of the grains; extract and screen the preferred grain phenotypic characteristics with yield characterization capability according to the rotating target detection frame information of the grains; S5. Select different machine learning models, fit various preferred combinations of grain phenotypic characteristics with yield data, construct different yield estimation models, and verify the model performance to obtain the optimal yield prediction model.
2. The method for counting rice ears and grains and estimating rice yield based on rotating target detection according to claim 1, characterized in that: Step S1 specifically includes the following steps: S11. Rice is planted in plots, with different planting patterns being used in different plots. During the rice harvest stage, yield statistics are collected for each plot according to standard agronomic requirements, and yield data are recorded; S12. In different rice growth stages, rice ear images are collected for each planting plot, wherein the images are collected in a uniform random distribution manner. During the collection, the rice ears are placed on a backboard with a standard grid, and the collection camera is perpendicular to the backboard.
3. The method for counting rice ears and grains and estimating rice yield based on rotating target detection according to claim 1, characterized in that: In step S1, the pre-processing process includes: Step 1: Use the open source image annotation tool RoLabelImg to draw the minimum bounding rectangle around each grain and generate an XML file containing the label box information; Step 2: Perform data enhancement on the rice ear dataset; Step 3: Divide the rice ear dataset into training set, validation set, and test set in a ratio of 8:1:
1.
4. The method for counting rice ears and grains and estimating rice yield based on rotating target detection according to claim 1, characterized in that: Step S2 specifically includes the following steps: S21. Replace the SPPF module of YOLOv8n_OBB with the SimSPPF module to improve the calculation speed of the network; S22. In the neck network part of YOLOv8n_OBB, the VoVGSCSP module based on GSConv is introduced to reduce the computational complexity of the model. S23. Improve the C2f module of YOLOv8n_OBB by introducing distributed shift convolution DShConv to simulate the behavior of convolutional layers using quantization and distributed shift. S24. Introduce depthwise separable convolution DSConv to reduce the model size.
5. The method for counting rice ears and grains and estimating rice yield based on rotating target detection according to claim 3, characterized in that: Step S3 specifically includes the following steps: S31. Train the YOLO-Grain_OBB model using the training set and the validation set. S32. Input the test set into the trained YOLO-Grain_OBB model and evaluate the model by its precision, recall, total number of parameters, and mean average precision.
6. The method for counting rice ears and grains and estimating rice yield based on rotating target detection according to claim 1, characterized in that: Step S4 specifically includes the following steps: Step S41, obtaining the scaling factors of the image pixels and distances in each rotating target detection frame to unify and correct the phenotypic characteristics of the rice ears; Step S42: according to the four-point coordinates of the rotating target detection frame, solve the predicted rotation angle, and calculate the width w and height h of the rotating target detection frame by Euclidean distance to obtain the diagonal r of the rotating target detection frame; Step S43, obtaining the pixels occupied by the diagonal r of the rotated target detection frame, and calculating the corrected length r', the corrected length w' of the width, and the corrected length h' of the height of the diagonal of the rotated target detection frame according to the pixels and the corresponding scaling factors; Step S44, approximate the rice ear grain as an ellipsoid with equal median axis and minor axis, and fit the preferred grain phenotypic characteristics, wherein the grain phenotypic characteristics include the grain cross-sectional perimeter L, the grain cross-sectional area A, the grain surface area S, the grain volume V, the grain median axis length, the grain minor axis length and the number of grains in the rice ear.
7. The method for counting rice ears and grains and estimating rice yield based on rotating target detection according to claim 6, characterized in that: Step S41 specifically includes the following steps: S411, obtaining the length, width and diagonal length of the standard grid of the rice ear image background; S412, detecting the pixels occupied by the length and width of the standard grid, and calculating the pixels occupied by the diagonal line; S413. Calculate the scaling factor of the image pixel and distance by dividing the diagonal length of the standard grid by the pixels occupied by the diagonal.
8. The method for counting rice ears and grains and estimating rice yield based on rotating target detection according to claim 1, characterized in that: Step S5 specifically includes: S51, selecting different machine learning models, including least squares fitting, random forest, multi-layer perceptron algorithm and long short-term memory network, fitting different preferred combinations of grain phenotypic characteristics with actual yield data, and obtaining different yield estimation models; S52. Use the cross-validation method to verify the model performance and obtain the optimal yield estimation model.
9. A computing device comprising a processor and a memory for storing a program executable by the processor, characterized in that: When the processor executes the program stored in the memory, the method for counting rice ears and grains and estimating rice yield based on rotating target detection as described in any one of claims 1 to 8 is implemented.
10. A storage medium storing a program, characterized in that: When the program is executed by a processor, the method for counting rice ears and grains and estimating rice yield based on rotating target detection as described in any one of claims 1 to 8 is implemented.
Citation Information
Cited By
Intelligent examination and approval method and system for government affair materials and electronic equipment
CN120410467A