Method for customizing germination standard of rice seeds
By taking rice seed images with a mobile phone and constructing a deep learning model, combined with the SAM image segmentation model, the seed germination rate is calculated, which solves the problem of lack of flexibility in rice seed germination detection in the existing technology, realizes customized germination standards, and improves the accuracy of detection. sex and efficiency.
Patent Information
- Application Number
- CN202410707862.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-03
- Publication Date
- 2024-09-06
AI Technical Summary
The existing rice seed germination detection technology lacks flexibility and cannot customize germination standards, resulting in a lack of flexibility and practicality in seed germination judgment.
Use a mobile phone to capture rice seed images, create a data set through the LabelImg annotation tool, and construct a deep learning model, including an input layer, feature extraction network, feature pyramid network, classification subnetwork, and box regression subnetwork. Combined with the SAM image segmentation model, the seed germination is calculated. Rate to custom germination standards.
It has improved the accuracy and efficiency of rice seed germination assessment, provided a more scientific basis for seed screening, is convenient and fast, and is suitable for large-scale planting industry.
Smart Images

Figure CN118608958A
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of agricultural production, and in particular to a method for customizing rice seed germination standards. Background Art
[0002] With the rapid development of agricultural science and technology, the cultivation of high-quality and high-yield rice seeds has become one of the important ways to increase grain production. In this process, the germination rate of rice seeds directly affects the planting efficiency and final yield. Therefore, it is particularly important to quickly and accurately evaluate the germination ability of rice seeds. Traditional seed germination tests mainly rely on manual observation and counting. This method is not only time-consuming and labor-intensive, but also has poor accuracy and objectivity, and it is difficult to meet the needs of large-scale planting.
[0003] At present, with the advancement of computer vision technology, especially the widespread application of deep learning technology in the field of image processing, many scholars have proposed the use of image recognition technology to automatically detect rice seed germination. By collecting seed images and using image processing and deep learning algorithms to automatically identify and evaluate the germination status of rice seeds, the detection speed and accuracy can be significantly improved, and it has broad application prospects. However, the existing rice seed germination detection technology still has some limitations. At present, when determining whether a seed has germinated, a fixed germination standard is used. For example, the germination standard is set at 1mm. When the seed bud grows longer than 1mm, it is judged to be germinated. However, in many cases, researchers often need to customize the germination standard by themselves. For example, according to the seeds with different bud lengths in the seed image, users can set different germination standards. At present, there is a lack of an intuitive and scientific method to customize the rice seed germination standard. Summary of the invention
[0004] In view of the above-mentioned defects of the prior art, the technical problem to be solved by the present invention is that the rice seed germination standard cannot be defined by itself. When judging whether the seeds have germinated, the user can only compare the seeds with the fixed rice seed germination standard, which makes the judgment of whether the rice seeds have germinated lack flexibility and practicality. Therefore, the present invention provides a method for customizing the rice seed germination standard, which has the advantages of being simple, easy to use, low cost, fast, and high precision. A method for customizing the rice seed germination standard of the present invention can not only improve the accuracy and efficiency of seed germination evaluation, but also provide growers with a more scientific basis for screening seeds, which has important research significance and application value.
[0005] To achieve the above object, the present invention provides a method for customizing rice seed germination standards, comprising the following steps:
[0006] S1: Use a mobile phone or other camera device to obtain rice seed images;
[0007] S2: Use the LabelImg annotation tool to label each rice seed in the rice seed image to create a rice seed image dataset, and divide the dataset into a training set and a test set;
[0008] S3: Construct a deep learning model for rice seed detection, which includes an input layer, a feature extraction network, a feature pyramid network, a classification sub-network, and a box regression sub-network;
[0009] S4: input the training samples into the rice seed detection deep learning model for training;
[0010] S5: input the test sample into the trained rice seed detection deep learning model to obtain the rice seed position of the test sample; evaluate its performance by analyzing the model indicator value, thereby obtaining a usable deep learning model;
[0011] S6: Input the rice seed image to be detected into the available rice seed detection deep learning model, and segment each rice seed using the SAM image segmentation model;
[0012] S7: for each segmented rice seed, pixels in the seed that satisfy the smaller color difference between red and blue, and between green and blue are regarded as embryos, and the ratio of the area of the embryo to the area of the rice husk is used as the germination rate of the rice seed;
[0013] S8: Determine whether the rice seeds have germinated.
[0014] Furthermore, a camera device such as a mobile phone is used to obtain images of rice seeds, specifically including:
[0015] S11: soaking rice seeds according to the requirements of germination experiment;
[0016] S12: Place the soaked rice seeds in a transparent culture dish with green non-reflective paper placed at the bottom of the dish. The rice seeds are allowed to touch each other but not overlap.
[0017] S13: Using a photographing device such as a mobile phone or a camera, take a photograph of the rice seeds from directly above the culture dish to obtain an image of the rice seeds.
[0018] Furthermore, the LabelImg annotation tool is used to annotate each rice seed in the rice seed image, thereby creating a rice seed image dataset, and the dataset is divided into a training set and a test set, specifically including:
[0019] S21: Use the LabelImg annotation tool to annotate the outer contour of a single rice seed and the germinated part in the rice seed image with a rectangular frame. Here, germinated or ungerminated seeds are classified into the same category;
[0020] S22: A rice seed image dataset is formed by all rice seed images and their corresponding annotations;
[0021] S23: Divide all rice seed images into training samples and test samples in a ratio of 7:3, all training samples constitute a training set, and all test samples constitute a test set.
[0022] Furthermore, a rice seed detection deep learning model is constructed, which includes an input layer, a feature extraction network, a feature pyramid network, a classification subnetwork, and a box regression subnetwork, and specifically includes the following steps:
[0023] S31: construct an input layer to input rice seed images, preprocess the images, scale them to a fixed size, and perform random splicing, random cropping, random arrangement, and Mosaic data enhancement on the images;
[0024] S32: construct a residual block, each residual block contains a calculation branch and a direct connection branch; the calculation branch means that the input data undergoes multiple convolution, batch normalization and ReLU activation operations to obtain the output x1; the direct connection branch means that when the input data passes through the branch, no calculation is performed or only one convolution layer is passed to obtain the output x2; the output of the residual block is x1+x2;
[0025] S33: construct a feature extraction network. After the data is input, it first passes through a convolution layer, a batch normalization layer, a ReLU activation operation and a maximum pooling layer, and then passes through the first residual block combination, the second residual block combination, the third residual block combination and the fourth residual block combination, and then passes through the average pooling layer and the fully connected layer, and finally uses Softmax to achieve regression; when the data passes through the second, third, and fourth residual block combinations, the feature maps C3, C4, and C5 are output respectively;
[0026] S34: Construct a feature pyramid network, and use C3, C4, and C5 as the input of the feature pyramid network. After C5, C4, and C3 pass through the convolution layer, they get CV5, CV4, and CV3 respectively; CV5 is upsampled to get U5, CV4+U5 is upsampled to get U4, and CV3+U4 is U3; U5, U4, and U3 are passed through a convolution layer respectively to get multi-scale feature fusion graphs P5, P4, and P3; P5 is passed through a convolution layer to get P6, and P6 is passed through a ReLU activation operation and a convolution layer to get P7;
[0027] S35: Construct a classification sub-network, and use P7, P6, P5, P4, and P3 as the input of the classification sub-network, respectively passing through three convolutional layers and ReLU activation operations and then passing through one convolutional layer;
[0028] S36: Box regression sub-network, P7, P6, P5, P4, and P3 are used as the input of the box regression sub-network, and they pass through three convolutional layers and ReLU activation operations respectively, and then pass through one convolutional layer.
[0029] Furthermore, the training samples are input into a rice seed detection deep learning model, and model training is performed, specifically including:
[0030] The training samples are input into the rice seed detection deep learning model, and the SGD optimizer with momentum of 0.9 and weight decay of 0.0001 is used. The batch size is 16, the number of iterations is 90,000, the initial learning rate is 0.01, when the number of iterations reaches 60,000, the learning rate is 0.001, and when the number of iterations reaches 80,000, the learning rate is 0.0001. The loss function uses the Focal Loss loss function and the Smooth L1 loss function; here, the Smooth L1 loss function is used for regression tasks to calculate the difference between the predicted bounding box and the true bounding box;
[0031] The Focal Loss loss function is expressed as:
[0032] FL(p t )=-α t (1-p t ) γ log(p t )
[0033] Among them, p t is the predicted value of the model, α t is the balancing factor and γ is the regulating factor.
[0034] Furthermore, the test sample is input into the trained rice seed detection deep learning model to obtain the rice seed position of the test sample; the performance of the model is evaluated by analyzing the model index value, thereby obtaining a usable deep learning model, which specifically includes the following steps:
[0035] S41: input the test sample into the trained rice seed detection deep learning model, and the model outputs multiple prediction rectangular boxes corresponding to the positions of different rice seeds in the image;
[0036] S42: The position of the predicted rectangular box of a single rice seed is recorded as [(x1, y1), (x2, y2)], where (x1, y1) and (x2, y2) correspond to the coordinates of the upper left corner and lower right corner of the predicted rectangular box respectively; the position of the real rectangular box of a single rice seed is recorded as [(x3, y3), (x4, y4)], where (x3, y3) and (x4, y4) correspond to the coordinates of the upper left corner and lower right corner of the real rectangular box respectively, and the area of the real rectangular box is recorded as S0; calculate the intersection area S1 between the predicted rectangular box and the real rectangular box, and take the ratio of S1 to S0 as the single rice seed detection accuracy W, and the average detection accuracy of rice seeds in the test sample It is equal to the average of the detection accuracy of all single rice seeds in the sample;
[0037] S43: When 80% of the test samples satisfy This shows that the deep learning model for rice seed detection can be used in practice.
[0038] Furthermore, the rice seed image to be detected is input into an available rice seed detection deep learning model, and each rice seed is segmented using the SAM image segmentation model, specifically including the following steps:
[0039] S51: Inputting the rice seed image to be detected into an available rice seed detection deep learning model, the model outputs rectangular boxes of different sizes and positions, each of which contains a seed. If the seed germinates, the rectangular box also contains an embryo;
[0040] S52: For each rectangular box containing a single seed, input it into the SAM (Segment anything model) image segmentation model to segment out the single rice seed. If the seed germinates, the embryo is also segmented out.
[0041] Further, for each segmented rice seed, pixels in the seed that satisfy the smaller color difference between red and blue, and between green and blue are regarded as embryos, and the ratio of the area of the embryo to the area of the rice husk is used as the germination rate of the rice seed, which specifically includes the following steps:
[0042] S61: for each segmented rice seed, calculating the absolute value d1 of the difference between the red and blue colors of each pixel inside the seed, and the absolute value d2 of the difference between the green and blue colors, and if both d1 and d2 are less than a threshold, the pixel is regarded as a germ;
[0043] S62: the number of pixels contained in the segmented rice seeds is taken as the area s of the rice seeds, and the number of pixels classified as embryos is taken as the area S1 of the embryos, then the area of the rice husk is equal to S-S1;
[0044] S63: The ratio of the area of the embryo to the area of the rice husk, S1 / (S-S1), is taken as the germination rate of rice seeds.
[0045] Further, determining whether the rice seeds have germinated specifically comprises the following steps:
[0046] S71: selecting any rice seed in the rice seed image, and using the germination rate of the rice seed as a germination standard;
[0047] S72: traverse each seed in the rice seed image, and compare the germination rate of the seed with the germination standard. If the germination rate is greater than the germination standard, it is determined to be germinated, otherwise it is determined to be ungerminated.
[0048] Technical Effects
[0049] The present invention provides a method for customizing rice seed germination standards, and its technical effects include:
[0050] 1. In the process of acquiring rice seed images, there is no need to shoot each rice seed separately. All rice seeds in the culture dish can be shot at one time, thereby speeding up the shooting speed.
[0051] 2. You can use your mobile phone to take pictures without the need for special camera equipment, making the shooting process easier.
[0052] 3. The present invention trains the rice seed detection deep learning model, SAM image segmentation model and rice seed germination rate calculation. The user only needs to input the rice seed image to be tested into the model and select the rice seed germination standard to obtain the germination status of each seed. The entire measurement process does not require manual intervention, is easy to use, fast and accurate. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] Figure 1 It is a flow chart of a method for customizing rice seed germination standards according to a preferred embodiment of the present invention;
[0054] Figure 2 It is a rice seed image of a method for customizing rice seed germination standards according to a preferred embodiment of the present invention;
[0055] Figure 3 It is a result of labeling each rice seed in a rice seed image using LabelImg according to a preferred embodiment of the present invention;
[0056] Figure 4 is a schematic diagram of a residual block structure of a preferred embodiment of the present invention;
[0057] Figure 5is a schematic diagram of a feature extraction network of a preferred embodiment of the present invention;
[0058] Figure 6 It is a schematic diagram of a feature pyramid network of a preferred embodiment of the present invention;
[0059] Figure 7 is a schematic diagram of a classification subnetwork of a preferred embodiment of the present invention;
[0060] Figure 8 Schematic diagram of a frame regression subnetwork of a preferred embodiment of the present invention;
[0061] Fig. 9 It is a network structure diagram of a preferred embodiment of the present invention;
[0062] Fig.10 It is a neural network model training schematic diagram of a preferred embodiment of the present invention;
[0063] Fig.11 It is a segmentation result using the SAM image segmentation model in a preferred embodiment of the present invention. DETAILED DESCRIPTION
[0064] In order to make the technical problems, technical solutions and beneficial effects to be solved by the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0065] In the following description, specific details such as specific internal procedures and techniques are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present invention. However, it should be clear to those skilled in the art that the present invention may be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present invention.
[0066] like Figure 1 As shown, the embodiment of the present invention provides a method for customizing rice seed germination standards, comprising the following steps:
[0067] S1: Use a mobile phone or other camera device to obtain rice seed images;
[0068] S2: Use the LabelImg annotation tool to label each rice seed in the rice seed image to create a rice seed image dataset, and divide the dataset into a training set and a test set;
[0069] S3: Construct a deep learning model for rice seed detection, which includes an input layer, a feature extraction network, a feature pyramid network, a classification sub-network, and a box regression sub-network;
[0070] S4: input the training samples into the rice seed detection deep learning model for training;
[0071] S5: input the test sample into the trained rice seed detection deep learning model to obtain the rice seed position of the test sample; evaluate its performance by analyzing the model indicator value, thereby obtaining a usable deep learning model;
[0072] S6: Input the rice seed image to be detected into an available rice seed detection deep learning model, the model outputs a rectangular box containing a single seed, and uses the SAM image segmentation model to segment each rice seed;
[0073] S7: for each segmented rice seed, pixels in the seed that satisfy the smaller color difference between red and blue, and between green and blue are regarded as embryos, and the ratio of the area of the embryo to the area of the rice husk is used as the germination rate of the rice seed;
[0074] S8: Selecting a germination rate of any rice seed from the rice seed image as a germination standard, and then, for each seed in the rice seed image, if its germination rate is greater than the germination standard, it is determined to be germinated, otherwise it is determined to be ungerminated.
[0075] The following is an example to illustrate the specific steps of a method for customizing rice seed germination standards of the present invention:
[0076] Step 1: Use a mobile phone or other camera device to obtain rice seed images, including:
[0077] (1) Soak the rice seeds according to the requirements of the rice seed germination experiment; first, select about 30-50 full rice seeds and put them into a transparent culture dish; second, prepare a clean container, such as a glass beaker or a measuring cylinder; then, use the container to fill and measure 30 ml of distilled water; then, pour the measured distilled water into the culture dish containing the seeds to ensure complete soaking, and gently shake it to ensure uniform soaking; finally, determine the soaking time according to the experimental requirements, which is usually 24 to 72 hours;
[0078] (2) Place green non-reflective paper at the bottom of the culture dish containing soaked rice seeds, allowing the rice seeds to touch each other but not overlap;
[0079] (3) Use a photographing device such as a mobile phone or a camera to take a picture of the rice seeds from directly above the culture dish to obtain an image of the rice seeds. Figure 2 This is an image of rice seeds taken with a mobile phone.
[0080] Step 2: Use the LabelImg annotation tool to label each rice seed in the rice seed image, thereby creating a rice seed image dataset, and divide the dataset into a training set and a test set, specifically including the following steps:
[0081] (1) For each rice seed image, use the LabelImg annotation tool to annotate the outer contour of a single rice seed and its sprouted part in the image with a rectangular frame. Here, germinated or ungerminated seeds are classified into the same category; the coordinates of the two vertices of the upper left corner and the lower right corner of the rectangular frame are used for annotation; it should be pointed out that the size of the rectangular frame is required to just cover the single rice seed and its sprouted part, that is, the rectangular frame is the minimum circumscribed rectangle of the outer contour of the single rice seed and its sprouted part;
[0082] (2) The rice seed image dataset consists of all rice seed images and their corresponding annotations;
[0083] (3) All rice seed images are divided into training samples and test samples in a ratio of 7:3. All training samples constitute the training set, and all test samples constitute the test set.
[0084] Figure 3 To use LabelImg Figure 2 The result of labeling a single rice seed in the rice seed image shown in Figure 1. Figure 3 It can be seen that each seed together with the sprouting part is surrounded by a rectangular frame.
[0085] Step 3: Construct a deep learning model for rice seed detection. The model includes an input layer, a feature extraction network, a feature pyramid network, a classification subnetwork, and a box regression subnetwork. Specifically, the following steps are included:
[0086] First, construct an input layer to input rice seed images, preprocess the images, and scale them to a fixed size of 640×640×3. If the input image is larger or smaller than 640×640×3, scale the image to 640×640. For example, if an image of size 400×400×3 is input, the image is enlarged to 640×640×3 using bilinear interpolation. At the same time, perform random splicing, random cropping, random arrangement, and Mosaic data enhancement on the images. The random splicing operation is to randomly select two different images, select different parts of the two images for splicing, and splice them into a 640×640×3 image. Random cropping is to partially crop an image and fill the cropped part with gray pixel values. Random arrangement is to disrupt the original order of all sub-images and randomly sort them. Mosaic data enhancement is to randomly select four complete sub-images and splice the four sub-images into a 640×640×3 image.
[0087] Secondly, construct residual blocks. Each residual block contains a computation branch and a direct connection branch. The computation branch refers to the input data undergoing multiple convolutions, batch normalization, and ReLU activation operations to obtain the output x1. The direct connection branch refers to the input data passing through the branch without any computation or only passing through one convolution layer to obtain the output x2. The output of the residual block is x1+x2. Figure 4 Schematic diagram of residual block structure;
[0088] Next, construct a feature extraction network. After the data is input, it first passes through a convolution layer, a batch normalization layer, a ReLU activation operation, and a maximum pooling layer, and then passes through the first residual block combination (including 3 residual block combinations), the second residual block combination (including 4 residual block combinations), the third residual block combination (including 6 residual block combinations), and the fourth residual block combination (including 3 residual block combinations), and then passes through the average pooling layer and the fully connected layer, and finally uses Softmax to achieve regression; when the data passes through the second, third, and fourth residual block combinations, the feature maps C3, C4, and C5 are output respectively; Figure 5 This is a schematic diagram of the feature extraction network; the detailed information of the feature extraction network is as follows:
[0089]
[0090]
[0091] Secondly, construct a feature pyramid network. First, take C3, C4, and C5 as the input of the feature pyramid network. After C5, C4, and C3 pass through the convolution layer, they get CV5, CV4, and CV3 respectively. After CV5 is upsampled, U5 is obtained. After CV4+U5 is upsampled, U4 is obtained. After CV3+U4, U3 is obtained. After U5, U4, and U3 pass through a convolution layer respectively, multi-scale feature fusion graphs P5, P4, and P3 are obtained. After P5 passes through a convolution layer, P6 is obtained. After P6 passes through the ReLU activation operation and a convolution layer, P7 is obtained. Figure 6 This is a schematic diagram of the feature pyramid network; the detailed information of the feature pyramid network is as follows:
[0092]
[0093]
[0094] Then, a classification sub-network is constructed, and P7, P6, P5, P4, and P3 are used as the input of the classification sub-network, and they are respectively passed through three convolutional layers and ReLU activation operations and then through one convolutional layer; Figure 7 This is a schematic diagram of the classification subnetwork; the detailed information of the classification subnetwork is as follows:
[0095]
[0096]
[0097] Finally, the box regression sub-network is constructed, and P7, P6, P5, P4, and P3 are used as the input of the box regression sub-network, passing through three convolutional layers and ReLU activation operations respectively, and then passing through one convolutional layer. Figure 8 This is a schematic diagram of the box regression subnetwork; the detailed information of the box regression subnetwork is as follows:
[0098]
[0099] Fig. 9 A network structure diagram including input layer, feature extraction network, feature pyramid network, classification subnetwork, and box regression subnetwork is given.
[0100] Step 4: input the training samples into the deep learning model for rice seed detection, and perform model training, specifically including: input the training samples into the deep learning model for rice seed detection, using an SGD optimizer with a momentum of 0.9 and a weight decay of 0.0001, a batch size of 16, an iteration number of 90,000, an initial learning rate of 0.01, when the iteration number reaches 60,000, the learning rate is 0.001, when the iteration number reaches 80,000, the learning rate is 0.0001, and the loss function uses a Focal Loss loss function and a Smooth L1 loss function; here, the Smooth L1 loss function is used for regression tasks to calculate the difference between the predicted bounding box and the true bounding box;
[0101] The Focal Loss loss function is expressed as:
[0102] FL(p t )=-α t (1-p t ) γ log(p t )
[0103] Among them, p t is the predicted value of the model, α t is the balancing factor, and γ is the regulating factor;
[0104] The Smooth L1 loss function is used to calculate the loss between the predicted value and the true value. The Smooth L1 loss function is expressed as: 0.5*(x 2 )if|x|<1,|x|-0.5otherwise, where x is the difference between the predicted value and the true value.
[0105] Fig.10 This is a schematic diagram of neural network model training.
[0106] Step 5: Input the test sample into the trained rice seed detection deep learning model to obtain the rice seed position of the test sample; evaluate its performance by analyzing the model index value, so as to obtain a usable deep learning model, which specifically includes the following steps:
[0107] A1: Input the test sample into the trained rice seed detection deep learning model, and the model outputs multiple predicted rectangular boxes corresponding to the positions of different rice seeds in the image;
[0108] A2: The position of the predicted rectangular box of a single rice seed is recorded as [(x1, y1), (x2, y2)], where (x1, y1) and (x2, y2) correspond to the coordinates of the upper left corner and lower right corner of the predicted rectangular box respectively; the position of the real rectangular box of a single rice seed is recorded as [(x3, y3), (x4, y4)], where (x3, y3) and (x4, y4) correspond to the coordinates of the upper left corner and lower right corner of the real rectangular box respectively, and the area of the real rectangular box is recorded as S0; calculate the intersection area S1 between the predicted rectangular box and the real rectangular box, and take the ratio of S1 to S0 as the single rice seed detection accuracy W, the average detection accuracy of rice seeds in the test sample It is equal to the average of the detection accuracy of all single rice seeds in the sample;
[0109] A3: When 80% of the test samples satisfy This shows that the deep learning model for rice seed detection can be used in practice.
[0110] Step 6: Input the rice seed image to be detected into the available rice seed detection deep learning model. The model outputs a rectangular frame containing a single seed, and uses the SAM image segmentation model to segment each rice seed. Specifically, the following steps are included:
[0111] A1: Input the rice seed image to be detected into the available rice seed detection deep learning model. The model outputs rectangular boxes of different sizes and positions. Each rectangular box contains a seed. If the seed germinates, the rectangular box also contains the embryo.
[0112] A2: For each rectangular box containing a single seed, it is input into the SAM (Segment anything model) image segmentation model to segment out the single rice seed. If the seed germinates, the embryo is also segmented out.
[0113] The present invention uses a model called SAM (Segment anything model), which is derived from the paper "Segment anything" by Kirillov et al., published at the 2023 IEEE / CVF International Conference on Computer Vision. The specific implementation details of the model can be viewed and referenced through the following code library URL: https: / / segment-anything.com / . The segmentation result of the SAM model is a two-dimensional Boolean array, the size of which is the same as the original image. Each element in the two-dimensional array corresponds to a corresponding pixel in the original image, where the value of the element is equal to True or False, True represents the foreground, that is, the corresponding pixel in the original image belongs to the seed, and False represents the background, that is, the corresponding pixel in the original image belongs to the background, not the seed. Fig.11 It is the segmentation result using the SAM image segmentation model.
[0114] Step 7: for each segmented rice seed, pixels in the seed that satisfy the smaller color difference between red and blue, and between green and blue are regarded as embryos, and the ratio of the area of the embryo to the area of the rice husk is used as the germination rate of the rice seed, which specifically includes the following steps:
[0115] A1: For each segmented rice seed, calculate the absolute value d1 of the difference between the red and blue colors of each pixel inside the seed, and the absolute value d2 of the difference between the green and blue colors. If both d1 and d2 are less than a threshold, the pixel is regarded as a germ. Here, the threshold is set to 30.
[0116] A2: The number of pixels in the rice seed segmented by SAM is taken as the area S of the rice seed, and the number of pixels classified as the embryo is taken as the area S1 of the embryo. Then the area of the rice seed shell is equal to S-S1.
[0117] A3: The ratio of the area of the embryo to the area of the rice husk, S1 / (S-S1), is taken as the germination rate of rice seeds.
[0118] Step 8: Select the germination rate of any rice seed from the rice seed image as the germination standard. Then, for each seed in the rice seed image, if its germination rate is greater than the germination standard, it is determined to be germinated, otherwise it is determined to be ungerminated. Specifically, the following steps are included:
[0119] A1: Select any rice seed in the rice seed image, and use the germination rate of the rice seed as the germination standard; the specific method is: (1) according to step 6, input the rice seed detection image into the available rice seed detection deep learning model, the model outputs a rectangular frame containing a single seed, and uses the SAM image segmentation model to segment each rice seed; (2) according to step 7, for each rice seed segmented from the rice seed detection image, the pixels inside the seed that meet the color difference values between red and blue, and between green and blue are small are regarded as embryos, and the ratio of the area of the embryo to the area of the rice seed shell is used as the germination rate of the rice seed; (3) click on any rice seed in the rice seed image with a mouse, and use the germination rate of the rice seed corresponding to the mouse click position as the germination standard;
[0120] A2: Traverse each seed in the rice seed image and compare the germination rate of the seed with the germination standard. If the germination rate is greater than the germination standard, it is judged to be germinated, otherwise it is judged to be ungerminated.
[0121] The present invention provides a method for customizing the germination standard of rice seeds. Researchers only need to use mobile phones and other camera equipment to take pictures of rice. The rice seeds only need to be spread on the container and kept at a certain interval. There are no special requirements for external lighting during shooting, and it only needs to be shot under natural light. The rice seed image is input into an available rice seed detection deep learning model, and after SAM segmentation and germination rate calculation, the germination rate of each rice seed in the rice seed image can be obtained. Then, the germination standard is selected to determine whether each rice seed in the rice seed image has germinated. The use of the present invention to customize the germination standard of rice seeds makes it more flexible for researchers to judge whether the rice seeds have germinated. The present invention has the advantages of convenience, speed, low cost and easy implementation, thereby providing great convenience for researchers.
[0122] The preferred specific embodiments of the present invention are described in detail above. It should be understood that a person skilled in the art can make many modifications and changes based on the concept of the present invention without creative work. Therefore, any technical solution that can be obtained by a person skilled in the art through logical analysis, reasoning or limited experiments based on the concept of the present invention on the basis of the prior art should be within the scope of protection determined by the claims.
Claims
1. A method for customizing rice seed germination standards, It is characterized in that The following steps are involved: S1: Use a mobile phone or other camera device to obtain rice seed images; S2: Use the LabelImg annotation tool to label each rice seed in the rice seed image to create a rice seed image dataset, and divide the dataset into a training set and a test set; S3: constructing a deep learning model for rice seed detection, the model comprising an input layer, a feature extraction network, a feature pyramid network, a classification sub-network, and a box regression sub-network; S4: input the training samples into the rice seed detection deep learning model for training; S5: input the test sample into the trained rice seed detection deep learning model to obtain the rice seed position of the test sample; Evaluate the performance of the model by analyzing its index values, thus obtaining a usable deep learning model; S6: Input the rice seed image to be detected into the available rice seed detection deep learning model, and segment each rice seed using the SAM image segmentation model; S7: for each segmented rice seed, pixels in the seed that satisfy the smaller color difference between red and blue, and between green and blue are regarded as embryos, and the ratio of the area of the embryo to the area of the rice husk is used as the germination rate of the rice seed; S8: Determine whether the rice seeds have germinated.
2. A method for customizing rice seed germination standards as claimed in claim 1, It is characterized in that S1: Use a mobile phone or other camera device to obtain rice seed images, which specifically includes the following steps: S11: soaking rice seeds according to the requirements of germination experiment; S12: Place the soaked rice seeds in a transparent culture dish with green non-reflective paper placed at the bottom of the dish. The rice seeds are allowed to touch each other but not overlap. S13: Using a photographing device such as a mobile phone or a camera, take a photograph of the rice seeds from directly above the culture dish to obtain an image of the rice seeds.
3. A method for customizing rice seed germination standards as claimed in claim 2, It is characterized in that S2: Use the LabelImg annotation tool to label each rice seed in the rice seed image to create a rice seed image dataset, and divide the dataset into a training set and a test set, which specifically includes the following steps: S21: Use the LabelImg annotation tool to annotate the outer contour of a single rice seed and the germinated part in the rice seed image with a rectangular frame. Here, germinated or ungerminated seeds are classified into the same category; S22: A rice seed image dataset is formed by all rice seed images and their corresponding annotations; S23: Divide all rice seed images into training samples and test samples in a ratio of 7:3, all training samples constitute a training set, and all test samples constitute a test set.
4. A method for customizing rice seed germination standards as claimed in claim 3, It is characterized in that S3: Construct a deep learning model for rice seed detection, which includes an input layer, a feature extraction network, a feature pyramid network, a classification subnetwork, and a box regression subnetwork, and specifically includes the following steps: S31: construct an input layer to input rice seed images, preprocess the images, scale them to a fixed size, and perform random splicing, random cropping, random arrangement, and Mosaic data enhancement on the images; S32: construct residual blocks, each residual block includes a calculation branch and a direct connection branch; The computational branch refers to the input data undergoing multiple convolutions, batch normalization, and ReLU activation operations to obtain the output x1; the direct branch refers to the input data passing through this branch without any calculation or only passing through one convolution layer to obtain the output x2; the output of the residual block is x1+x2; S33: Construct a feature extraction network. After the data is input, it first passes through a convolution layer, a batch normalization layer, a ReLU activation operation, and a maximum pooling layer, and then passes through the first residual block combination, the second residual block combination, the third residual block combination, and the fourth residual block combination, and then passes through the average pooling layer and the fully connected layer, and finally uses Softmax to achieve regression; when the data passes through the second, third, and fourth residual block combinations, the feature map C is output respectively. 3 , C 4 , C 5 ; S34: Construct a feature pyramid network and transform C 3 , C 4 , C 5 As the input of the feature pyramid network, C 5 , C 4 , C 3 After passing through the convolution layer, we get CV 5 、CV 4 、CV 3 CV 5 After upsampling, we get U 5 , CV 4 +U 5 After upsampling, we get U 4 , CV 3 +U 4 After getting U 3 ;Change U 5 , U 4 , U 3 After passing through a convolutional layer, we get a multi-scale feature fusion map P 5 , P 4 , P 3 ; P 5 After passing through a convolutional layer, we get P 6 , P 6 After continuing the ReLU activation operation and one convolutional layer, we get P 7 ; S35: Construct a classification subnetwork and transform P 7 , P 6 , P 5 , P 4 , P 3 As the input of the classification sub-network, it passes through three convolutional layers and ReLU activation operations and then passes through one convolutional layer; S36: Box regression sub-network, P 7 , P 6 , P 5 , P 4 , P 3 As the input of the box regression sub-network, it passes through three convolutional layers and ReLU activation operations and then passes through one convolutional layer.
5. A method for customizing rice seed germination standards as claimed in claim 4, It is characterized in that S4: Input the training samples into the rice seed detection deep learning model for training, which specifically includes the following steps: The training samples are input into the rice seed detection deep learning model, and the SGD optimizer with momentum of 0.9 and weight decay of 0.0001 is used. The batch size is 16, the number of iterations is 90,000, the initial learning rate is 0.01, when the number of iterations reaches 60,000, the learning rate is 0.001, and when the number of iterations reaches 80,000, the learning rate is 0.0001. The loss function uses the Focal Loss loss function and the Smooth L1 loss function; here, the Smooth L1 loss function is used for regression tasks to calculate the difference between the predicted bounding box and the true bounding box; The Focal Loss loss function is expressed as: FL(p t )=-a t (1-p t ) γ log(p t ) Among them, p t is the predicted value of the model, α t is the balancing factor and γ is the regulating factor.
6. A method for customizing rice seed germination standards as claimed in claim 5, It is characterized in that S5: Input the test sample into the trained rice seed detection deep learning model to obtain the rice seed position of the test sample; evaluate its performance by analyzing the model indicator value, so as to obtain a usable deep learning model, which specifically includes the following steps: S51: input the test sample into the trained rice seed detection deep learning model, and the model outputs multiple prediction rectangular boxes corresponding to the positions of different rice seeds in the image; S52: The location of the predicted rectangular frame of a single rice seed is recorded as [(x 1 ,y 1 ), (x 2 ,y 2 )], here, (x 1 ,y 1 ) and (x 2 ,y 2 ) correspond to the coordinates of the upper left corner and lower right corner of the predicted rectangular box respectively; the position of the actual rectangular box of a single rice seed is recorded as [(x 3 ,y 3 ), (x 4 ,y 4 )], here, (x 3 ,y 3 ) and (x 4 ,y 4 ) correspond to the coordinates of the upper left corner and lower right corner of the real rectangular box, and the area of the real rectangular box is recorded as S 0 ; Calculate the intersection area S between the predicted rectangular box and the real rectangular box 1 , S 1 With S 0 The ratio of is taken as the single rice seed detection accuracy W, and the average detection accuracy of rice seeds in the test sample is It is equal to the average of the detection accuracy of all single rice seeds in the sample; S53: When 80% of the test samples satisfy This shows that the deep learning model for rice seed detection can be used in practice.
7. A method for customizing rice seed germination standards as claimed in claim 6, It is characterized in that S6: Input the rice seed image to be detected into the available rice seed detection deep learning model, and use the SAM image segmentation model to segment each rice seed, which specifically includes the following steps: S61: Inputting the rice seed image to be detected into an available rice seed detection deep learning model, the model outputs rectangular boxes of different sizes and positions, each of which contains a seed. If the seed germinates, the rectangular box also contains an embryo; S62: For each rectangular box containing a single seed, input it into the SAM image segmentation model to segment out the single rice seed. If the seed germinates, the embryo is also segmented out.
8. A method for customizing rice seed germination standards as claimed in claim 7, It is characterized in that S7: For each segmented rice seed, pixels in the seed that satisfy the smaller color difference between red and blue, and between green and blue are regarded as embryos, and the ratio of the area of the embryo to the area of the rice husk is used as the germination rate of the rice seed, which specifically includes the following steps: S71: For each segmented rice seed, calculate the absolute value d of the difference between the red and blue values of each pixel inside the seed. 1 , and the absolute value of the difference between green and blue d 2 , if d 1 and d 2 If both are smaller than the threshold, the pixel is regarded as a germ; S72: The number of pixels included in the segmented rice seeds is taken as the area S of the rice seeds, and the number of pixels classified as embryos is taken as the area S of the embryos. 1 , then the area of the rice seed husk is equal to SS 1 ; S73: Ratio of the area of the germ to the area of the rice seed husk 1 / (SS 1 ) as the germination rate of rice seeds R i .
9. A method for customizing rice seed germination standards as claimed in claim 8, It is characterized in that S8: Determining whether the rice seeds have germinated, specifically comprising the following steps: S81: selecting any rice seed in the rice seed image, and using the germination rate of the rice seed as a germination standard; S82: traverse each seed in the rice seed image, and compare the germination rate of the seed with the germination standard. If the germination rate of the seed is greater than the germination standard, it is determined to be germinated, otherwise it is determined to be ungerminated.
Citation Information
Cited By
Seed germination detection method and device, electronic equipment and storage medium
CN122265286A
