A method for determining grain germination rate
By designing grain germination photography equipment and deep learning models, the grain germination images are automatically processed, which solves the time-consuming and labor-intensive problem of manual measurement in the existing technology and achieves fast and accurate grain germination rate measurement.
Patent Information
- Application Number
- CN202110671741.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-06-17
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2041-06-17
AI Technical Summary
The existing grain germination rate determination method requires manual preprocessing, consumes a lot of manpower and time, and has strict requirements for the placement of grains, which affects the measurement results.
A grain germination photography equipment including a camera and a light-proof box is designed. Combined with a deep learning model, image processing and annotation tools are used to obtain and preprocess grain germination images, and a neural network model is constructed for training to achieve automated grain germination. Rate determination.
Fast, accurate and low-cost determination of grain germination rate is achieved, labor costs are reduced, manual intervention is avoided, and determination efficiency and accuracy are improved.
Smart Images

Figure CN113610101B
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of agricultural production, and in particular to a method for determining a grain germination rate. Background Art
[0002] Rice is a major food crop in the world. As an ideal monocotyledonous model crop, the functional genomics study of its agronomic traits is one of the hot topics in plant biology research. Currently, there are thousands of rice genetic breeding scholars conducting research on rice genes and traits. Among them, grain germination represents the end of seed dormancy, the entry into continuous development and growth, and the conduction of gene transcription and expression, and the continuous exchange of substances and energy with the external environment. This process is the key to ensure the smooth reproduction and evolution of rice populations and has very important biological significance.
[0003] At present, the determination of grain germination rate is mainly done through manual statistics. Since the statistics of germination rate of tens of thousands of grains need to be completed in the same period of time, if the statistics are completed manually, the workload is large, the efficiency is low, and the measurement results are easily affected by subjective factors. With the increase in labor costs year by year, the cost of grain germination rate determination has also increased. In addition to manual statistics, many scholars have proposed the use of computer image processing technology to determine grain germination rate, including the use of neural networks, connected regions and morphological transformation methods. These methods have strict requirements on the placement of grains. For example, it is required to maintain a certain distance between grains and that the grains cannot stick together. At the same time, it is required to ensure that the grains are dry during shooting, and there should be no water droplets in the container where the grains are placed. These requirements bring inconvenience to practical use. Therefore, it is urgent to establish a grain germination rate determination system to conveniently and quickly complete the germination rate statistics of large-scale grain samples, thereby reducing labor costs and improving the accuracy of germination rate determination. 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 existing method for determining the germination rate of grains requires manual preprocessing, which consumes a lot of manpower and time, and also has specific requirements for the placement of grains, otherwise it will affect the determination results. Therefore, the present invention provides a method for determining the germination rate of grains, which has the advantages of being simple, easy to use, low cost, fast, and high precision.
[0005] To achieve the above object, the present invention provides a method for determining grain germination rate, comprising the following steps:
[0006] Step 1, designing a grain germination photographing device, wherein the photographing device comprises a camera and a light-proof box, and is used to obtain grain germination images;
[0007] Step 2, obtaining a grain germination image under a camera;
[0008] Step 3: For each grain germination image obtained, use the labelImg annotation tool to annotate the image to obtain a grain germination image dataset;
[0009] Step 4: for the grain germination image dataset, preprocess each grain germination image, including normalization processing and block processing, to obtain multiple sub-images of the same size, and divide all the sub-images into training samples and test samples in a ratio of 7:3;
[0010] Step 5: Construct a deep learning model, and construct the input layer, backbone network, head network and detection layer in sequence;
[0011] Step 6: For the deep learning model constructed in step 5, use the k-means clustering algorithm to calculate the anchor boxes and obtain 9 anchor boxes;
[0012] Step 7: for the preprocessed training samples, using the deep learning model constructed in step 5, gradually extracting the features and size information of the grain germination image through the convolution kernel in the model, and using the back propagation and stochastic gradient descent algorithms to supervisely minimize the loss function, and adjusting the connection weights of the model according to the learning rate and the gradient value, thereby completing the training of the neural network model;
[0013] Step 8: For the preprocessed test samples, input them into the trained neural network model to obtain the grain germination test results and model index values, and use the model index values to measure the quality of the model, thereby obtaining a usable deep learning model.
[0014] Furthermore, a grain germination photographing device is designed, which comprises a camera and a light-proof box for acquiring grain germination images; the light-proof box comprises an image acquisition port, a light source and a box body; the image acquisition port is located directly above the box body, and the camera can acquire images of objects in the box through the image acquisition port; the light source is a ring-shaped LED lamp, which is placed below the image acquisition port on the top of the box; the LED light shines toward the top of the box, and is reflected by surrounding materials such as the box top and box wall, forming a uniform diffuse reflection lighting environment at the bottom of the box, so that the captured grain image will not have obvious reflections; in addition, the LED lamp is powered by a USB interface, and three brightness adjustment modes are set; the front opening of the box body is used for the entry and exit of culture dishes when acquiring grain germination images.
[0015] Further, obtaining the grain germination image under the camera device specifically includes the following steps:
[0016] First, put the soaked grains into a transparent culture dish, spread the grains as flat as possible in the dish, and allow the grains to stick together and overlap;
[0017] Secondly, the culture dish is placed in the grain germination photographing device, a computer connected to a camera is used to take a photo, and the image number is input to obtain the grain germination image.
[0018] Furthermore, for each grain germination image obtained, the labelImg annotation tool is used to annotate the image to obtain a grain germination image dataset, which specifically includes the following steps:
[0019] For each grain germination image obtained, the labelImg annotation tool was used under the Windows system to annotate each grain and its germinated part with a rectangular frame, where the information of the annotated rectangular frame included the horizontal and vertical coordinates of the center point of the rectangular frame, as well as the width and height of the rectangular frame, to obtain the grain germination dataset, in which the grain labels were divided into three categories: obviously germinated grains, obviously ungerminated grains, and grains that were uncertain whether they had germinated.
[0020] Furthermore, for the grain germination image dataset, each grain germination image is preprocessed, including normalization and block processing, to obtain multiple sub-images of the same size, and all sub-images are divided into training samples and test samples in a ratio of 7:3, specifically including the following steps:
[0021] First, each grain germination image was normalized by dividing the R, G, and B values of each pixel in the image by 255;
[0022] Secondly, the image is divided into sub-images of size 640*640, with an overlap area of 160 pixels between each sub-image;
[0023] Then, normalizing each marked rectangular frame in the sub-image, including dividing the horizontal coordinate of the center point of the rectangular frame and the width of the rectangular frame by the width of the sub-image, and dividing the vertical coordinate of the center point of the rectangular frame and the height of the rectangular frame by the height of the sub-image;
[0024] Finally, all sub-images are divided into training samples and test samples in a ratio of 7:3.
[0025] Furthermore, a deep learning model is constructed, and the input layer, backbone network, head network and detection layer are constructed in sequence, which specifically includes the following steps:
[0026] First, construct an input layer to input the grain germination image to be processed, and perform random splicing, random cropping, random arrangement and Mosaic data enhancement on the image to obtain an image size of 640*640*3;
[0027] Secondly, construct a backbone network, slice the 640*640*3 image into a 320*320*12 feature map, and input the feature map into a convolution layer with 32 convolution kernels, and obtain a 320*320*32 feature map through convolution operation; then construct three convolution layers and a cross-stage local network; then construct a convolution layer and a spatial pyramid pooling; finally, construct a cross-stage local network;
[0028] Then, the head network structure is constructed, and a path aggregation network is formed through convolutional neural networks, upsampling and splicing operations. Finally, a three-layer network is obtained, and feature maps of sizes 80*80*128, 40*40*256, and 20*20*512 are output;
[0029] Finally, a detection layer structure is constructed to obtain the final convolution result. The detection layer structure includes three parallel convolution layers to obtain three layers of output feature maps. This feature map has three dimensions of width, height and depth, which are 80*80*21, 40*40*21, and 20*20*21, respectively. 80*80, 40*40, and 20*20 represent the width and height values of the feature map, and 21 represents the depth of the feature map. Specifically, 21 represents the number of anchor boxes per layer * 7, where the number of anchor boxes per layer is 3, and 7 represents the 7 prediction box values corresponding to each grid position in the feature map. These 7 prediction box values are: the horizontal coordinate value of the center point of the prediction box, the vertical coordinate value of the center point of the prediction box, the width of the prediction box, the height of the prediction box, and the category probabilities of three categories (including obviously germinated grains, obviously ungerminated grains, and uncertain whether germinated grains).
[0030] Furthermore, for the deep learning model constructed in step 5, the k-means clustering algorithm is used to calculate the anchor boxes to obtain 9 anchor boxes, which specifically includes the following steps:
[0031] First, the deep learning model is required to output three feature layers of different sizes, and each feature layer has three anchor boxes, for a total of 9 anchor boxes;
[0032] Secondly, the height and width values of all label boxes in the training samples are used as the input of the k-means clustering algorithm, and 9 cluster centers are obtained through the k-means clustering algorithm. These 9 cluster centers are 9 anchor boxes.
[0033] Furthermore, for the preprocessed training samples, the deep learning model constructed in step 5 is used to gradually extract the features and size information of the grain germination image through the convolution kernel in the model, and the back propagation and stochastic gradient descent algorithms are used to supervisely minimize the loss function, and the connection weights of the model are adjusted according to the learning rate and the gradient value, so as to complete the training of the neural network model, wherein the learning rate is adjusted using the cosine annealing algorithm, the prediction box information (including the horizontal and vertical coordinates of the center point of the prediction box, the width and height of the prediction box) uses the CIoU loss function, the classification loss uses the Varifocal loss function, and the CIoU loss function L CIoU Expressed as:
[0034]
[0035]
[0036]
[0037] L CIoU =1-IoU+CIoU (4)
[0038] Among them, ρ 2 (b,b gt ) represents the distance between the center point of the actual rectangular box and the predicted box, c represents the diagonal length of the smallest rectangular box surrounding the actual rectangular box and the predicted box, and w gt Indicates the actual width of the rectangular box, h gt Represents the height value of the actual rectangular box, w represents the width value of the predicted box, h represents the height value of the predicted box, and IoU represents the intersection area of the actual rectangular box and the predicted box divided by the union area of the actual box and the predicted box;
[0039] Varifocal loss function is expressed as:
[0040]
[0041] Among them, p is the predicted value of the category probability, and q is the true value of the category probability.
[0042] Furthermore, the preprocessed test samples are input into the trained neural network model to obtain the grain germination test results and model index values, and the model index values are used to measure the quality of the model, thereby obtaining a usable deep learning model; specifically, during the model test, the values output by the deep learning model need to be processed by a non-maximum suppression algorithm to detect and delete redundant prediction boxes of the same object, which specifically includes the following steps:
[0043] First, sort each prediction box according to its category probability prediction value;
[0044] Then, compare the IoU between each other p Value, where IoU p Represents the intersection area of two prediction boxes divided by the union area of two prediction boxes;
[0045] Finally, the prediction boxes that are smaller than the threshold are deleted to obtain the final prediction box.
[0046] Furthermore, the method further includes step 9, packaging the usable deep learning model once and designing it into a graphical interface system connected to a grain germination photography device so that people can use it repeatedly in the future, which specifically includes the following steps:
[0047] First, place the soaked grains in a transparent petri dish and prepare for the germination rate test;
[0048] Secondly, the transparent culture dish is placed in the photographing device, and the culture dish in the photographing device is photographed to obtain a grain germination image. At the same time, the image is named, and the corresponding seed number is input to save the grain germination image;
[0049] Then, the grain germination image obtained by taking a photo is preprocessed, including image scaling and image normalization; wherein, the image scaling process is: assuming that the length of the image is a and the width is b, first adjust the length of the image to 1024 and the width to b'=1024 / a*b, then calculate b"=round(b' / 32)*32, wherein round() means rounding up, and further obtain ε=round((b"-b') / 2), thus, on the basis of b', fill ε gray pixels on the left and right along the width direction, and the size of the image after pixel filling is 640*b"; image normalization is to divide the R, G and B values of each pixel in the image by 255 respectively;
[0050] Finally, the preprocessed image is sent to the trained deep learning model to obtain a prediction box containing three grain categories (including obviously germinated grains, obviously ungerminated grains, and grains of uncertainty whether they have germinated). The number of grains in each category is counted separately, and the number of grains in each category is added together to obtain the total number of grains. The number of grains in the category of obviously germinated grains is then divided by the total number of grains to obtain the grain germination rate.
[0051] Technical Effects
[0052] The invention discloses a method for determining grain germination rate. A grain germination photographing device is designed by utilizing a camera and a light-proof box. The whole device is low in price and easy to assemble.
[0053] In the process of acquiring grain germination images, there is no need to do too much pretreatment of the grains. The soaked grains only need to be placed in a transparent culture dish, and adhesion and overlap between the grains are allowed, which provides convenience for the capture of grain germination images.
[0054] When counting the grain germination rate, you only need to place the culture dish into the grain germination photography equipment to quickly and conveniently complete the statistics of the grain germination rate. The entire statistical process is completed through a deep learning model, thus avoiding human intervention and ensuring the accuracy of the germination rate statistical results.
[0055] The concept, specific structure and technical effects of the present invention will be further described below in conjunction with the accompanying drawings to fully understand the purpose, characteristics and effects of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] Figure 1 It is a schematic flow chart of a method for determining grain germination rate according to a preferred embodiment of the present invention;
[0057] Figure 2 This is a schematic diagram of an LED light adjustment switch in a photographing device according to a preferred embodiment of the present invention;
[0058] Figure 3 It is a schematic diagram of an image acquisition port in a photographing device according to a preferred embodiment of the present invention;
[0059] Figure 4 It is a schematic diagram of a camera in a photographing device according to a preferred embodiment of the present invention;
[0060] Figure 5 It is a schematic diagram of a light source in a photographing device according to a preferred embodiment of the present invention;
[0061] Figure 6 is a top view schematic diagram of a photographing device according to a preferred embodiment of the present invention;
[0062] Figure 7 is a front view schematic diagram of a photographing device according to a preferred embodiment of the present invention;
[0063] Figure 8 It is a schematic diagram of an original grain germination image of a grain germination rate determination method according to a preferred embodiment of the present invention;
[0064] Fig. 9 It is a schematic diagram of annotated image results of a method for determining grain germination rate according to a preferred embodiment of the present invention;
[0065] Fig.10 It is a schematic diagram of the results of an XML file of a method for determining a grain germination rate according to a preferred embodiment of the present invention;
[0066] Fig.11 It is a block diagram of a method for determining grain germination rate according to a preferred embodiment of the present invention;
[0067] Fig.12 It is a schematic diagram of image segmentation results of a method for determining grain germination rate according to a preferred embodiment of the present invention;
[0068] Fig.13 It is a schematic diagram of a TXT file after label normalization of a method for determining grain germination rate in a preferred embodiment of the present invention;
[0069] Fig.14 It is a schematic diagram of the structure of a deep learning model of a method for determining grain germination rate according to a preferred embodiment of the present invention;
[0070] Fig.15 It is a schematic diagram of a slice network structure of a method for determining grain germination rate in a preferred embodiment of the present invention;
[0071] Fig.16 It is a schematic diagram of a spatial pyramid pooling structure of a method for determining grain germination rate in a preferred embodiment of the present invention;
[0072] Fig.17 It is a schematic diagram of a neural network model training of a method for determining grain germination rate according to a preferred embodiment of the present invention;
[0073] Fig.18 It is a schematic diagram of a photographic graphical interface of a method for determining grain germination rate according to a preferred embodiment of the present invention;
[0074] Fig.19 It is a schematic diagram of a detection graphical interface of a method for determining grain germination rate according to a preferred embodiment of the present invention;
[0075] Fig. 20 It is a schematic diagram of Excel results after detection of a method for determining grain germination rate in a preferred embodiment of the present invention. DETAILED DESCRIPTION
[0076] 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.
[0077] 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.
[0078] like Figure 1 As shown, the embodiment of the present invention provides a method for determining grain germination rate, comprising the following steps:
[0079] Step 1, designing a grain germination photographing device, wherein the photographing device comprises a camera and a light-proof box, and is used to obtain grain germination images;
[0080] Step 2, obtaining a grain germination image under a camera;
[0081] Step 3: For each grain germination image obtained, use the labelImg annotation tool to annotate the image to obtain a grain germination image dataset;
[0082] Step 4: for the grain germination image dataset, preprocess each grain germination image, including normalization processing and block processing, to obtain multiple sub-images of the same size, and divide all the sub-images into training samples and test samples in a ratio of 7:3;
[0083] Step 5: Construct a deep learning model, and construct the input layer, backbone network, head network and detection layer in sequence;
[0084] Step 6: For the deep learning model constructed in step 5, use the k-means clustering algorithm to calculate the anchor boxes and obtain 9 anchor boxes;
[0085] Step 7: for the preprocessed training samples, using the deep learning model constructed in step 6, gradually extracting the features and size information of the grain germination image through the convolution kernel in the model, and using the back propagation and stochastic gradient descent algorithms to supervisely minimize the loss function, and adjusting the connection weights of the model according to the learning rate and the gradient value, thereby completing the training of the neural network model;
[0086] Step 8: Input the preprocessed test samples into the trained neural network model to obtain the grain germination test results and model index values, and measure the quality of the model through the model index values, so as to obtain a usable deep learning model;
[0087] Step 9: Encapsulate the deep learning model obtained in step 8 and design it into a graphical interface system connected to the grain germination photography device for easy use by people.
[0088] The specific steps of a method for determining grain germination rate of the present invention are described below by way of example.
[0089] Step 1. Design a grain germination photography device, which includes a camera and a light-proof box for acquiring grain germination images; the light-proof box consists of three parts: an image acquisition port, a light source, and a box body; the image acquisition port is located directly above the box body, and the camera can acquire images of objects in the box through the image acquisition port; the light source is a ring-shaped LED lamp, which is placed below the image acquisition port on the top of the box; the LED light shines toward the top of the box, and is reflected by surrounding materials such as the box top and box wall, forming a uniform diffuse reflection lighting environment at the bottom of the box, so that the captured grain image will not have obvious reflections; in addition, the LED lamp is powered by a USB port, and has three brightness adjustment modes; the front opening of the box body is used for the entry and exit of the culture dish when acquiring grain germination images. Grain germination photography device such as Figure 2-Figure 7 As shown, Figure 2 Adjust the switch for LED lights, Figure 3 For image acquisition port, Figure 4 The camera shown is installed at the image acquisition port. Figure 5 It is the light source used in photographic equipment. Figure 6 and Figure 7 They are respectively a top view and a front view of the photographing device.
[0090] Step 2: obtaining a grain germination image under a camera, specifically comprising the following steps:
[0091] First, put the soaked grains into a transparent culture dish, spread the grains as flat as possible in the dish, and allow the grains to stick together and overlap;
[0092] Secondly, the culture dish is placed in the grain germination photographing device, a computer connected to a camera is used to take a photo, and the image number is input to obtain the grain germination image.
[0093] Here, red, green, blue, black and other colored papers are placed in the photographing device, and then the culture dish is placed in the grain germination photographing device. The computer connected to the camera is used to take pictures. At the same time, the image resolution of the picture is set to 1920*1080, and the image number is input to obtain the grain germination image, such as Figure 8 shown.
[0094] Step 3: For each grain germination image obtained, use the labelImg annotation tool to annotate the image to obtain a grain germination image dataset, which specifically includes the following steps:
[0095] For each grain germination image obtained, the labelImg annotation tool is used in the Windows system to annotate each grain and its germinating part with a rectangular frame, and then the annotated information is saved in the form of an xml file. The original image file and the xml file are saved in the same folder. The final data set consists of the original image file and the xml file, where the annotated rectangular frame information includes the category, the horizontal and vertical coordinates of the center point of the rectangular frame, and the width and height of the rectangular frame, etc., to obtain the grain germination data set, where the grain labels are divided into three categories: obviously germinated grains, obviously ungerminated grains, and grains that are uncertain whether they have germinated. The schematic diagram of the annotated image result is shown in the figure below. Fig. 9 As shown, the XML file result diagram is as follows Fig.10 As shown. Fig.10 In the image, 1920 and 1080 represent the width and height of the image respectively, and 3 represents that the image contains three channels: red R, green G, and blue B. <name> no< / name> " indicates that the category of the grain label is obviously germinated grain. Here, yes indicates obviously germinated grain, un indicates whether it is uncertain whether it is germinated, and no indicates obviously ungerminated grain. xmin, ymin, xmax and ymax indicate the coordinates of the upper left corner (xmin, ymin) and the lower right corner (xmax, ymax) of the marked rectangular box. Fig.10 The coordinates of the upper left corner of the middle rectangular box are (1059,784) and the coordinates of the lower right corner are (1122,860). According to the four values of xmin, ymin, xmax and ymax, we can get the horizontal coordinate of the center point of the rectangular box is (1059+1122) / 2=1090.5, the vertical coordinate of the center point is (784+860) / 2=822, the width of the rectangular box is 1122-1059=63, and the height of the rectangular box is 860-784=76.
[0096] Step 4: for the grain germination image dataset, preprocess each grain germination image, including normalization processing and block processing, to obtain multiple sub-images of the same size, and divide all the sub-images into training samples and test samples in a ratio of 7:3, specifically including the following steps:
[0097] Since the image files and the XML files of the annotation information in the grain germination dataset obtained in step 3 are placed in the same folder, the image files and XML files are first separated according to the file type into image folders and XML folders, and then the image files in the image folder and the XML files in the XML folder are preprocessed respectively. The preprocessing includes the following steps:
[0098] First, each grain germination image was normalized by dividing the R, G, and B values of each pixel in the image by 255;
[0099] Secondly, the image is divided into sub-images of size 640*640, with an overlap area of 160 pixels between each sub-image; the specific steps of block division are as follows:
[0100] The image is divided into sub-images of size 640*640 in the horizontal and vertical directions, and the overlapping area between the sub-images is 160 pixels. Fig.11 As shown, for an image with a resolution of 1920*1080, when m is obtained 11 , m 12 and m 13 After the three sub-images, along the horizontal direction, these three sub-images occupy a total of 640*3-160*2=1600 pixels, so there are 1920-1600=320 pixels left in the horizontal direction of the image. In order to make the width of the sub-image equal to 640, m 13 and m 14 The overlap area is set to 320 pixels, so that m 14 The width of the sub-image is equal to 640; similarly, for the vertical direction, when m 11 After the sub-image, the image has 1080-640=440 pixels left in the vertical direction. To make the height of the sub-image equal to 640 pixels, m 11 and m 21 The overlap area is set to 200 pixels, so that m 21 The height of the sub-image is equal to 640; all the rightmost and bottommost sub-images are processed in the same way; Fig.12 According to the above method, Figure 8 The result of dividing the original germination image shown in the figure is that a total of 8 sub-images with a size of 640*640 are obtained.
[0101] Since the image is processed in blocks, the annotated rectangular frame also needs to be processed in blocks. The rectangular frame corresponding to the sub-image is screened according to the coordinates of the center point of the annotated rectangular frame. If the center point is within the range of the sub-image, the rectangular frame corresponding to the sub-image is selected; each annotated rectangular frame in the sub-image is normalized, including dividing the horizontal coordinate of the center point of the rectangular frame and the width of the rectangular frame by the width of the sub-image 640, and dividing the vertical coordinate of the center point of the rectangular frame and the height of the rectangular frame by the height of the sub-image 640; the file size of the rectangular frame annotated by the sub-image is the number of rectangular frames * 5, where 5 represents the information contained in each rectangular frame: the category name number, the horizontal and vertical coordinates of the center point of the rectangular frame after normalization, and the width and height of the rectangular frame after normalization. Here, the category name number specifies that 0 represents obviously germinated grains, 1 represents obviously ungerminated grains, and 2 represents whether it is uncertain whether the grains are germinated. At the same time, the annotated rectangular frame file corresponding to the sub-image is saved in TXT file format. The schematic diagram of the TXT file is as follows Fig.13 shown. Fig.13 In the first row, 1, 0.9515625000000002, 0.596875, 0.09374999999999964 and 0.11875000000000017 respectively indicate that the category of the rectangular box is uncertain whether the germinated grains, the horizontal coordinate of the center point of the rectangular box, the vertical coordinate of the center point of the rectangular box, the width of the rectangular box and the height of the rectangular box.
[0102] Finally, all sub-images and corresponding annotation files are divided into training samples and test samples in a ratio of 7:3.
[0103] Step 5: Construct a deep learning model. Construct the input layer, backbone network, head network and detection layer in sequence. The schematic diagram of the deep learning model structure is as follows: Fig.14 As shown, the specific steps include:
[0104] First, an input layer is constructed to input the grain germination image to be processed, with a size of 640*640*3. At the same time, the image is randomly spliced, randomly cropped, randomly arranged and Mosaic data enhanced to obtain an image size of 640*640*3; among them, the random splicing operation is to randomly select two different images, select part of the pixel values in 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 them into a 640*640*3 image.
[0105] Secondly, construct a backbone network, slice the 640*640*3 image into a 320*320*12 feature map, and input the feature map into a convolution layer including 32 convolution kernels, and obtain a 320*320*32 feature map through convolution operation; then construct three convolution layers and a cross-stage local area network; then construct a convolution layer and a spatial pyramid pooling; finally construct a cross-stage local area network; the detailed information of the backbone network convolution kernel is as follows:
[0106]
[0107]
[0108] Then, the head network structure is constructed, and the path aggregation network is composed of convolutional neural network, upsampling and splicing operations. Finally, a three-layer network is obtained, and feature maps of sizes 80*80*128, 40*40*256, and 20*20*512 are output; the order of upsampling and splicing operations to form the path aggregation network is shown in the following table:
[0109]
[0110]
[0111] Finally, the detection layer structure is constructed to obtain the final convolution result. The C18 output feature map 80*80*128 in the head network structure is connected to the convolution layer of 21 1*1 convolution kernels to obtain a feature map of 80*80*21. The C21 output feature map 40*40*256 in the head network structure is connected to the convolution layer of 21 1*1 convolution kernels to obtain a feature map of 40*40*21. The C24 output feature map in the head network structure is connected to the convolution layer of 21 1*1 convolution kernels to obtain a feature map of 40*40*21. Fig. 20 *20*512 connects 21 convolution layers of 1*1 convolution kernels to obtain a 20*20*21 feature map; finally, a three-layer output feature map can be obtained. This feature map has three dimensions of width, height and depth, which are: 80*80*21, 40*40*21, and 20*20*21 output sizes, respectively, where 80*80, 40*40, and 20*20 represent the width and height values of the feature map, and 21 represents the depth size of the feature map. Specifically, 21 represents the number of anchor boxes per layer*7, where the number of anchor boxes per layer is 3, and 7 represents the 7 prediction box values corresponding to each grid position in the feature map. These 7 prediction box values are: the horizontal coordinate value of the center point of the prediction box, the vertical coordinate value of the center point of the prediction box, the width of the prediction box, the height of the prediction box, and the category probabilities of three categories (including obviously germinated grains, obviously ungerminated grains, and uncertain whether to germinate grains);
[0112] Step 6: For the deep learning model constructed in step 5, use the k-means clustering algorithm to calculate the anchor boxes and obtain 9 anchor boxes, which specifically includes the following steps:
[0113] First, the deep learning model is required to output three feature layers of different sizes, and each feature layer has three anchor boxes, for a total of 9 anchor boxes;
[0114] Secondly, the height and width values of all label boxes in the training samples are used as the input of the k-means clustering algorithm, and 9 cluster centers are obtained through the k-means clustering algorithm. These 9 cluster centers are 9 anchor boxes.
[0115] Step 7: For the preprocessed training samples, the deep learning model constructed in step 6 is used to gradually extract the features and size information of the grain germination image through the convolution kernel in the model, and the loss function is supervisedly minimized by back propagation and stochastic gradient descent algorithms. The connection weights of the model are adjusted according to the learning rate and the gradient value. The model is trained 500 times in total to complete the training of the neural network model. The learning rate is adjusted using the cosine annealing algorithm, the prediction box information (including the horizontal and vertical coordinates of the center point of the prediction box, the width and height of the prediction box) uses the CIoU loss function, the classification loss uses the Varifocal loss function, and the CIoU loss function L CIoU Expressed as:
[0116]
[0117]
[0118]
[0119] L CIoU =1-IoU+CIoU (4)
[0120] Among them, ρ 2 (b,b gt ) represents the distance between the center point of the actual rectangular box and the predicted box, c represents the diagonal length of the smallest rectangular box surrounding the actual rectangular box and the predicted box, and w gt Indicates the actual width of the rectangular box, h gt Represents the height value of the actual rectangular box, w represents the width value of the predicted box, h represents the height value of the predicted box, and IoU represents the intersection area of the actual rectangular box and the predicted box divided by the union area of the actual box and the predicted box.
[0121] Varifocal loss function is expressed as:
[0122]
[0123] Among them, p is the predicted value of the category probability, and q is the true value of the category probability.
[0124] The cosine annealing algorithm is used to adjust the learning rate for each training, and the learning rate is adjusted for each batch according to the following formula:
[0125]
[0126] Among them, η min and η max Represents the minimum and maximum learning rates in the set learning rate range, T cur Indicates the number of trainings from the beginning of training to the current training, T i Indicates the total number of training times. Fig.17 This is a schematic diagram of neural network model training.
[0127] Step 8: For the preprocessed test samples, input them into the trained neural network model to obtain the grain germination test results and model index values, and measure the quality of the model through the model index values, so as to obtain a usable deep learning model; specifically, when testing the model, it is necessary to perform non-maximum suppression algorithm processing on the values output by the deep learning model to detect and delete redundant prediction boxes of the same object, which specifically includes the following steps:
[0128] First, sort each prediction box according to its category probability prediction value;
[0129] Then, compare the IoU between each other p Value, where IoU p Represents the intersection area of two prediction boxes divided by the union area of two prediction boxes;
[0130] Finally, delete the prediction boxes that are smaller than the threshold to get the final prediction box;
[0131] Step 9: Encapsulate the usable deep learning model once and design it into a graphical interface system connected to a grain germination photography device so that people can use it repeatedly in the future, which specifically includes the following steps:
[0132] First, place the soaked grains in a transparent petri dish and prepare for the germination rate test;
[0133] Secondly, put the transparent culture dish into the camera device and take a picture of the culture dish in the camera device to obtain the grain germination image. At the same time, name the image and enter the corresponding seed number to save the grain germination image. The PYQT5 language is used to design the graphical interface. The interface contains a number input box, a camera opening button, a camera taking button, and a camera closing button. The usage steps are: first open the camera, then enter the number, and then click the camera taking button. If the photo is finished, click the camera closing button; the photo taking graphical interface is as follows Fig.18 As shown;
[0134] Then, the grain germination image obtained by taking a photo is preprocessed, including image scaling and image normalization; wherein, the image scaling process is: assuming that the length of the image is a and the width is b, first adjust the length of the image to 1024 and the width to b'=1024 / a*b, then calculate b"=round(b' / 32)*32, wherein round() means rounding up, and further obtain ε=round((b"-b') / 2), thus, on the basis of b', fill ε gray pixels on the left and right along the width direction, and the size of the image after pixel filling is 640*b"; image normalization is to divide the R, G and B values of each pixel in the image by 255 respectively;
[0135] Finally, the preprocessed image is sent to the trained deep learning model to obtain a prediction box containing three grain categories (including obviously germinated grains, obviously ungerminated grains, and grains uncertain whether to germinate). The number of grains in each category is counted separately, and the number of grains in each category is added to get the total number of grains. Then the number of grains belonging to the category of obviously germinated grains is divided by the total number of grains to get the grain germination rate. The results are saved in Excel files for easy viewing and use later. The designed interface includes a path box, a detection button, and a log display box. The path box is for inputting the folder path of the grain image taken or a single picture. The log display box mainly records the path name where the Excel results are saved after image detection. If the input image path does not exist or is empty, it will also be prompted and recorded; the detection interface is as follows Fig.19 shown. Fig. 20 This is a schematic diagram of the results in the Excel file. At the same time, the system will save the test result image to facilitate researchers to verify the results.
[0136] The method for determining the grain germination rate of the present invention gets rid of the previous manual determination of the grain germination rate, thereby saving a lot of manpower. In the process of obtaining grain images, only a computer and a camera are needed to obtain a good effect, and the method has the advantages of being easy to use, fast, low cost and easy to implement. When shooting, the grains only need to be spread on a culture dish, and at the same time, a certain degree of adhesion between the grains is allowed, so that the grain germination rate can be statistically obtained, which provides great convenience for researchers.
[0137] 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 determining grain germination rate, characterized in that: The following steps are involved: Step 1, designing a photographing device for grain germination, the photographing device comprises a camera and a light-proof box, and is used to obtain grain germination images, specifically comprising: the light-proof box is composed of three parts: an image acquisition port, a light source, and a box body; the image acquisition port is located directly above the box body, and the camera can acquire images of objects in the box through the image acquisition port; the light source is a ring-shaped LED lamp, which is placed below the image acquisition port on the top of the box; the LED light irradiates toward the top of the box, and is reflected by the materials around the top and wall of the box, forming a uniform diffuse reflection lighting environment at the bottom of the box, so that the collected grain image will not have obvious reflections; in addition, the LED lamp is powered by a USB interface, and three brightness adjustment modes are set; the front opening of the box body is used for the entry and exit of the culture dish when acquiring the grain germination image; Step 2, obtaining a grain germination image under the photographing device; Step 3: for each of the grain germination images obtained, label the image using the labelImg labeling tool to obtain a grain germination image dataset; Step 4: for the grain germination image dataset, preprocess each grain germination image, including normalization processing and block processing, to obtain multiple sub-images of the same size, and divide all the sub-images into training samples and test samples in a ratio of 7:3; Step 5, construct a deep learning model, and sequentially construct an input layer, a backbone network, a head network, and a detection layer, specifically including: first, construct an input layer for inputting the grain germination image to be processed, and at the same time, randomly splice, randomly crop, randomly arrange, and perform Mosaic data enhancement on the image to obtain an image size of 640*640*3; Secondly, construct a backbone network, slice the 640*640*3 image into a 320*320*12 feature map, and input the feature map into a convolution layer with 32 convolution kernels, and obtain a 320*320*32 feature map through convolution operation; then construct three convolution layers and a cross-stage local network; then construct a convolution layer and a spatial pyramid pooling; finally, construct a cross-stage local network; Then, the head network structure is constructed, and a path aggregation network is formed through convolutional neural networks, upsampling and splicing operations. Finally, a three-layer network is obtained, and feature maps of sizes 80*80*128, 40*40*256, and 20*20*512 are output; Finally, a detection layer structure is constructed to obtain the final convolution result. The detection layer structure includes three parallel convolution layers to obtain three layers of output feature maps. The feature map has three dimensions of width, height and depth, which are: 80*80*21, 40*40*21, and 20*20*21 output sizes, respectively. 80*80, 40*40, and 20*20 represent the width and height values of the feature map, and 21 represents the depth size of the feature map. Specifically, 21 represents the number of anchor boxes per layer * 7, where the number of anchor boxes per layer is 3, and 7 represents the 7 prediction box values corresponding to each grid position in the feature map. These 7 prediction box values are: the horizontal coordinate value of the center point of the prediction box, the vertical coordinate value of the center point of the prediction box, the width of the prediction box, the height of the prediction box, and the category probabilities of the three categories. Step 6: According to the deep learning model, use the k-means clustering algorithm to calculate the anchor boxes and obtain 9 anchor boxes; Step 7: for the training samples, using the deep learning model, gradually extracting the features and size information of the grain germination image through the convolution kernel in the model, and using the back propagation and stochastic gradient descent algorithms to supervisely minimize the loss function, and adjusting the connection weights of the model according to the learning rate and the gradient value, thereby completing the training of the neural network model; Step 8: For the test sample, input the test sample into the trained neural network model to obtain the grain germination test result and the model index value, and measure the quality of the model by the model index value, so as to obtain a usable deep learning model.
2. A method for determining grain germination rate according to claim 1, characterized in that: Acquiring a grain germination image under a camera device specifically includes the following steps: Firstly, the soaked grains are placed in a transparent culture dish and spread out in the dish, while allowing the grains to adhere and overlap; Secondly, the culture dish is placed in the grain germination photographing device, a camera is used to take a photo, and then the image number is input to obtain the grain germination image.
3. A method for determining grain germination rate as claimed in claim 2, characterized in that: For each grain germination image obtained, the labelImg annotation tool is used to annotate the image to obtain the grain germination image dataset, which specifically includes the following steps: For each grain germination image obtained, the labelImg annotation tool was used under the Windows system to annotate each grain and its germinated part with a rectangular frame, where the information of the annotated rectangular frame included the horizontal and vertical coordinates of the center point of the rectangular frame, as well as the width and height information of the rectangular frame, to obtain the grain germination dataset, in which the grain labels were divided into three categories: obviously germinated grains, obviously ungerminated grains, and grains that were uncertain whether they had germinated.
4. A method for determining grain germination rate as claimed in claim 3, characterized in that: For the grain germination image dataset, each grain germination image is preprocessed, including normalization and block processing, to obtain multiple sub-images of the same size, and all sub-images are divided into training samples and test samples in a ratio of 7:3, specifically including the following steps: First, each grain germination image was normalized by dividing the R, G, and B values of each pixel in the image by 255; Secondly, the image is divided into sub-images of size 640*640, with an overlap area of 160 pixels between each sub-image; Then, normalizing each marked rectangular frame in the sub-image, including dividing the horizontal coordinate of the center point of the rectangular frame and the width of the rectangular frame by the width of the sub-image, and dividing the vertical coordinate of the center point of the rectangular frame and the height of the rectangular frame by the height of the sub-image; Finally, all sub-images are divided into training samples and test samples in a ratio of 7:
3.
5. A method for determining grain germination rate according to claim 4, characterized in that: For the deep learning model, the k-means clustering algorithm is used to calculate the anchor boxes, and 9 anchor boxes are obtained. The following steps are involved: First, the deep learning model is required to output three feature layers of different sizes, and each feature layer has three anchor boxes, for a total of 9 anchor boxes; Secondly, the height and width values of all label boxes in the training samples are used as the input of the k-means clustering algorithm, and 9 cluster centers are obtained through the k-means clustering algorithm. These 9 cluster centers are 9 anchor boxes.
6. A method for determining grain germination rate according to claim 5, characterized in that: For the training sample, the deep learning model is used to gradually extract the features and size information of the grain germination image through the convolution kernel in the model, and the loss function is supervisedly minimized by using the back propagation and stochastic gradient descent algorithms, and the connection weights of the model are adjusted according to the learning rate and the gradient value, so as to complete the training of the neural network model, wherein the learning rate is adjusted using the cosine annealing algorithm, the prediction box information uses the CIoU loss function, the classification loss uses the Varifocal loss function, and the CIoU loss function L CIoU Expressed as: L CIo U=lIoU+CIoU(4) Among them, ρ 2 (b, bgt) represents the distance between the center point of the actual rectangular box and the predicted box, c represents the diagonal length of the smallest rectangular box surrounding the actual rectangular box and the predicted box, wg t Indicates the actual width of the rectangular box, hg t Represents the height value of the actual rectangular box, w represents the width value of the predicted box, h represents the height value of the predicted box, and IoU represents the intersection area of the actual rectangular box and the predicted box divided by the union area of the actual box and the predicted box; Varifocal loss function is expressed as: Among them, p is the predicted value of the category probability, and q is the true value of the category probability.
7. A method for determining grain germination rate according to claim 6, characterized in that: For the test sample, it is input into the trained neural network model to obtain the grain germination test result and the model index value, and the model index value is used to measure the quality of the model, so as to obtain a usable deep learning model; specifically, when testing the model, it is necessary to perform non-maximum suppression algorithm processing on the value output by the deep learning model to detect and delete redundant prediction boxes of the same object, which specifically includes the following steps: First, sort each prediction box according to its category probability prediction value; Then, compare the IoU between each other p Value, where IoU p Represents the intersection area of two prediction boxes divided by the union area of two prediction boxes; Finally, the prediction boxes that are smaller than the threshold are deleted to obtain the final prediction box.
8. A method for determining grain germination rate according to claim 7, characterized in that: The method further includes step 9, packaging the usable deep learning model once and designing it into a graphical interface system connected to a grain germination photography device so that people can use it repeatedly in the future, which specifically includes the following steps: First, place the soaked grains in a transparent petri dish and prepare for the germination rate test; Secondly, the transparent culture dish is placed in the photographing device, and the culture dish in the photographing device is photographed to obtain a grain germination image. At the same time, the image is named, and the corresponding seed number is input to save the grain germination image; Then, the grain germination image obtained by taking a photo is preprocessed, including image scaling and image normalization; wherein, the image scaling process is: assuming that the length of the image is a and the width is b, first adjust the length of the image to 1024 and the width to b'=1024 / a*b, then calculate b"=round(b' / 32)*32, wherein round() means rounding up, and further obtain ε=round((b"-b') / 2), thus, on the basis of b', fill ε gray pixels on the left and right along the width direction, and the size of the image after pixel filling is 640*b"; image normalization is to divide the R, G and B values of each pixel in the image by 255 respectively; Finally, the preprocessed images are sent to the trained deep learning model to obtain prediction boxes containing three grain categories, including obviously germinated grains, obviously ungerminated grains, and grains that are uncertain whether to germinate. The number of grains in each category is counted separately, and the number of grains in each category is added together to get the total number of grains. The number of grains in the category of obviously germinated grains is then divided by the total number of grains to get the grain germination rate.
Citation Information
Patent Citations
Cascaded granular crop quality analysis method and system based on deep learning
CN111709326A
Domestic plant layer -stepping hydroponics planting device of intelligence
CN208300590U
