Flag leaf included angle measurement method and device, electronic equipment, storage medium and program product
Through technology based on 2D images and CNN, the flag leaf angle of grass plants is automatically measured, which solves the time-consuming and labor-intensive problem of manual measurement and achieves efficient flag leaf angle measurement.
Patent Information
- Application Number
- CN202410666485.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-27
- Publication Date
- 2024-09-10
AI Technical Summary
Manual measurement of flag leaf angles is time-consuming and labor-intensive, and it is difficult to achieve efficient automated measurement with existing technology.
A method based on 2D images and convolutional neural networks (CNN) is used to obtain images of target grass plants, predict the positions of flag leaves, stems and connection points, and calculate the angle between the flag leaves and stems.
The automatic measurement of the flag leaf angle is realized, the measurement efficiency is improved, and the problem of manual measurement being time-consuming and labor-intensive is solved.
Smart Images

Figure CN118623799A
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of image processing technology, and in particular to a flag leaf angle measurement method, device, electronic device, storage medium and program product. Background Art
[0002] With the continuous growth of the world's population and the continuous change of climate, improving the productivity of plants, especially the productivity of grasses, has become an important task in plant breeding.
[0003] It should be noted that the flag leaf is the uppermost leaf closest to the panicle in Gramineae plants, has the strongest photosynthetic capacity, and plays an important role in determining plant yields. Therefore, crop lines with upright flag leaves are more popular. On this basis, whether the flag leaf is upright can be determined by measuring the flag leaf angle.
[0004] However, the current method is mainly based on manual measurement of the flag leaf angle, which is time-consuming and labor-intensive and needs to be improved. Summary of the invention
[0005] The embodiments of the present invention provide a flag leaf angle measurement method, device, electronic device, storage medium and program product to realize automatic measurement of the flag leaf angle.
[0006] According to one aspect of the present invention, a flag leaf angle measurement method is provided, which may include:
[0007] Acquire a target image collected for a target Gramineae plant, wherein the target image may at least include a target flag leaf and a target stem in the target Gramineae plant;
[0008] The target image is input into a pre-trained key point prediction model, and according to the output result of the key point prediction model, a first prediction position of a flag leaf point on a target flag leaf in the target image, a second prediction position of a stem point on a target stem in the target image, and a third prediction position of a connection point between the target flag leaf and the target stem in the target image can be obtained;
[0009] According to the first predicted position, the second predicted position and the third predicted position, a target angle between the target flag leaf and the target stem is measured.
[0010] According to another aspect of the present invention, a flag leaf angle measuring device is provided, which may include:
[0011] A target image acquisition module is used to acquire a target image collected for a target Gramineae plant, wherein the target image at least includes a target flag leaf and a target stem in the target Gramineae plant;
[0012] A predicted position obtaining module is used to input the target image into a pre-trained key point prediction model, and obtain a first predicted position of a flag leaf point on a target flag leaf in the target image, a second predicted position of a stalk point on a target stalk in the target image, and a third predicted position of a connection point between the target flag leaf and the target stalk in the target image according to an output result of the key point prediction model;
[0013] The target angle measurement module is used to measure the target angle between the target flag leaf and the target stem according to the first predicted position, the second predicted position and the third predicted position.
[0014] According to another aspect of the present invention, there is provided an electronic device, which may include:
[0015] at least one processor; and
[0016] a memory communicatively connected to at least one processor; wherein,
[0017] The memory stores a computer program that can be executed by at least one processor. The computer program is executed by at least one processor so that the flag blade angle measurement method provided by any embodiment of the present invention is implemented when the at least one processor executes the computer program.
[0018] According to another aspect of the present invention, a computer-readable storage medium is provided, on which computer instructions are stored, and the computer instructions are used to enable a processor to implement the flag blade angle measurement method provided by any embodiment of the present invention when executed.
[0019] According to another aspect of the present invention, a computer program product is provided, on which a computer program is stored. When the computer program is executed by a processor, the flag blade angle measurement method provided by any embodiment of the present invention is implemented.
[0020] The technical solution in the embodiment of the present invention obtains the target image collected for the target grass plant, especially the target flag leaf and the target stem in the target grass plant, so as to measure the target angle between the target flag leaf and the target stem based on the target image; the target image is input into the key point prediction model that has been trained in advance, so as to use the key point prediction model to predict each key point in the target image (i.e., the flag leaf point on the target flag leaf, the stem point on the target stem, and the connection point between the target flag leaf and the target stem), and then according to the output result of the key point prediction model, the first predicted position of the flag leaf point in the target image, the second predicted position of the stem point in the target image, and the third predicted position of the connection point in the target image can be obtained, and these positions are the key to measuring the flag leaf angle; then, the target angle is measured according to the obtained positions. The above technical solution predicts each key point in the target image by using the key point prediction model, and then automatically measures the flag leaf angle according to the positions of these key points, thereby solving the time-consuming and labor-intensive problem caused by manually measuring the flag leaf angle.
[0021] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0023] Figure 1 is a flow chart of a flag leaf angle measurement method provided according to an embodiment of the present invention;
[0024] Figure 2a is a schematic diagram of a target image in a flag leaf angle measurement method provided according to an embodiment of the present invention;
[0025] Figure 2b According to a method for measuring a flag leaf angle provided by an embodiment of the present invention, Figure 2a Schematic diagram of the corresponding three key points: flag leaf point (L), stem point (S) and connection point (C);
[0026] Figure 3 is a flow chart of another flag leaf angle measurement method provided according to an embodiment of the present invention;
[0027] Figure 4is a flow chart of another flag leaf angle measurement method provided according to an embodiment of the present invention;
[0028] Figure 5 is a flow chart of an optional example of another flag leaf angle measurement method provided in an embodiment of the present invention;
[0029] Figure 6 is a structural block diagram of a flag leaf angle measurement device provided according to an embodiment of the present invention;
[0030] Figure 7 It is a structural schematic diagram of an electronic device for implementing the flag leaf angle measurement method of an embodiment of the present invention. DETAILED DESCRIPTION
[0031] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0032] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. The situations of "target", "original", etc. are similar and will not be repeated here. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0033] Before introducing the embodiment of the present invention, the manual measurement of the flag leaf angle and related contents described in the background technology are first exemplarily described to better understand the flag leaf angle measurement process described in the embodiment of the present invention.
[0034] For example, when measuring the flag leaf angle manually, representative plants need to be selected from a large number of plants growing in the field, and then the flag leaf angles (i.e., the angle between the flag leaf and the stem) of these plants are measured using a goniometer. Obviously, this measurement scheme is time-consuming and labor-intensive.
[0035] On this basis, with the development of high-throughput plant phenotyping platforms and sensing technologies, it provides opportunities to improve the measurement efficiency of flag leaf angle, including three-dimensional (3D) and two-dimensional (2D) measurement schemes.
[0036] For 3D measurement solutions, in wild or field environments, plant 3D images can be reconstructed based on a variety of technologies to extract phenotypes, such as Laser Triangulation (LT) technology, Structure From Motion (SFM) technology, Structured Light (SL) technology, Time of flight (TOF) technology, Terrestrial Laser Scanning (TLS) technology, and Light Field (LF) technology.
[0037] Compared with 2D images, 3D images certainly provide more information, but it is not convenient to obtain 3D images (i.e., 3D point cloud data). In addition, TLS technology can quickly and accurately measure the leaf angles of the entire forest canopy, with a large coverage area, fully automatic data collection and processing, and less human interference. However, the tools to implement TLS technology are relatively expensive, and processing TLS data is very time-consuming and requires specialized knowledge. SFM technology, by comparison, does not require specialized equipment and is inexpensive, but it requires a lot of time and resources to process data, and is sensitive to image quality and quantity. In a field environment, plants are easily blown by the wind, causing motion blur, affecting measurement accuracy.
[0038] Compared with 3D measurement schemes, the acquisition and processing of 2D images used in 2D measurement schemes are easier and more convenient. Smartphones have excellent graphics and image processing capabilities, are versatile and easy to carry, and there are more and more examples of obtaining plant organ phenotypic parameters based on smartphones.
[0039] On this basis, Convolutional Neural Network (CNN) has strong performance in image processing tasks in field-based plant phenotyping studies. Compared with traditional computer vision solutions, CNN can better cope with image-by-image changes caused by occlusion, lighting and viewpoint differences.
[0040] Therefore, the embodiment of the present invention combines 2D images with CNN to achieve automatic measurement of the flag leaf angle. Next, this will be explained in detail.
[0041] Figure 1It is a flow chart of a flag leaf angle measurement method provided by an embodiment of the present invention. This embodiment is applicable to the automatic measurement of the flag leaf angle of grass plants, and is particularly applicable to the automatic measurement of the flag leaf angle of wheat. The method can be executed by the flag leaf angle measurement device provided by an embodiment of the present invention, and the device can be implemented by software and / or hardware. The device can be integrated on an electronic device, and the electronic device can be a server, and in particular can be various user terminals, such as a mobile phone or a tablet computer.
[0042] See also Figure 1 The method of the embodiment of the present invention specifically includes the following steps:
[0043] S110, acquiring a target image collected for a target Gramineae plant, wherein the target image at least includes a target flag leaf and a target stem of the target Gramineae plant.
[0044] Among them, the target grass plant can be understood as the grass plant whose flag leaf angle is to be measured. The grass plant can be, for example, wheat, corn, bluegrass, rice, sorghum, oats or sugarcane, which is related to the actual situation and is not specifically limited here.
[0045] A target image collected for a target grass plant is obtained, especially a target image collected for a target flag leaf and a target stem in the target grass plant, wherein the target flag leaf can be understood as a flag leaf in the target grass plant, and the target stem can be understood as a stem in the target grass plant. In combination with the application scenarios that may be involved in the embodiments of the present invention, the target image can be a 2D image.
[0046] Exemplarily, a mobile phone is placed on a portable image acquisition device, and based on this, images are taken using the mobile phone. The portable image acquisition device includes a mobile phone clip, a bracket, and a background board. In order to facilitate the distinction between the background board and the target Poaceae plant, the background board can be black. Figure 2a The target image of the target Poaceae plant collected based on this is taken from the front view, which can show the target flag leaf and the target stem.
[0047] S120. Input the target image into a pre-trained key point prediction model, and based on the output results of the key point prediction model, obtain the first predicted position of the flag leaf point on the target flag leaf in the target image, the second predicted position of the stem point on the target stem in the target image, and the third predicted position of the connection point between the target flag leaf and the target stem in the target image.
[0048] Among them, before measuring the flag leaf angle, a key point prediction model for predicting key points can be pre-trained, and the key point prediction model is a CNN model. In practical applications, optionally, the key point prediction model can be trained for various grass plants; it can also be trained for a certain grass plant (such as wheat, corn, bluegrass, rice, sorghum, oats or sugarcane, etc.), that is, corresponding CNN models can be trained for different types of grass plants, so as to ensure accurate prediction of key points; of course, it can also be trained based on other methods, which are not specifically limited here. Optionally, when the key point prediction model is a lightweight CNN model, the flag leaf angle measurement scheme implemented by the key point prediction model can be deployed on the user terminal for application.
[0049] A key point prediction model is obtained, in particular, a key point prediction model trained for target grass plants such as grass plants can be obtained. Then, the target image is input into the key point prediction model, so as to predict the key points in the target image using the key point prediction model, thereby obtaining a first prediction position, a second prediction position, and a third prediction position according to the output result of the key point prediction model.
[0050] Among them, the first predicted position represents the position of the key point of the predicted flag leaf point (L) on the target flag leaf in the target image, the second predicted position represents the position of the key point of the predicted stalk point (S) on the target stalk in the target image, and the third predicted position represents the position of the key point of the predicted connection point (C) between the target flag leaf and the target stalk in the target image. It should be noted that L is a pixel point among the pixel points on the target flag leaf. As for which pixel point the model will select as L, this is related to the flag leaf point marked on the sample flag leaf during the model training process. The same is true for S, which will not be repeated here.
[0051] Exemplary, combined Figure 2a , using the key point prediction model to predict the key points and their positions on the target image, such as Figure 2b shown.
[0052] S130, measuring a target angle between a target flag leaf and a target stem according to the first predicted position, the second predicted position, and the third predicted position.
[0053] Among them, according to the three predicted positions obtained by using the above steps, the flag leaf angle (that is, the target angle between the target flag leaf and the target stem) is measured to achieve automatic measurement of the flag leaf angle.
[0054] For example, the target angle can be measured by the following formula:
[0055]
[0056] in, represents a vector based on the third predicted position and the first predicted position, represents a vector formed by the third predicted position and the second predicted position, and θ represents the target angle.
[0057] The technical solution in the embodiment of the present invention obtains the target image collected for the target grass plant, especially the target flag leaf and the target stem in the target grass plant, so as to measure the target angle between the target flag leaf and the target stem based on the target image; the target image is input into the key point prediction model that has been trained in advance, so as to use the key point prediction model to predict each key point in the target image (i.e., the flag leaf point on the target flag leaf, the stem point on the target stem, and the connection point between the target flag leaf and the target stem), and then according to the output result of the key point prediction model, the first predicted position of the flag leaf point in the target image, the second predicted position of the stem point in the target image, and the third predicted position of the connection point in the target image can be obtained, and these positions are the key to measuring the flag leaf angle; then, the target angle is measured according to the obtained positions. The above technical solution predicts each key point in the target image by using the key point prediction model, and then automatically measures the flag leaf angle according to the positions of these key points, thereby solving the time-consuming and labor-intensive problem caused by manually measuring the flag leaf angle.
[0058] Figure 3 It is a flow chart of another flag leaf angle measurement method provided in an embodiment of the present invention. This embodiment is optimized based on the above-mentioned technical solutions. In this embodiment, optionally, the key point prediction model includes at least one coding layer group, and the coding layer group includes at least two coding layers connected in sequence; after the target image is input into the pre-trained key point prediction model, the above-mentioned flag leaf angle measurement method may also include: for each coding layer in the key point prediction model, using the coding layer, encoding the target object input into the coding layer, wherein the target object is related to the target image; for each coding layer group in at least one coding layer group, splicing the coding features respectively output by each coding layer in the coding layer group to obtain splicing features; according to the splicing features respectively corresponding to at least one coding layer group, obtaining the output result. Among them, the explanations of the terms that are the same or corresponding to the above-mentioned embodiments are not repeated here.
[0059] See also Figure 3 The method of this embodiment may specifically include the following steps:
[0060] S210, acquiring a target image collected for a target Gramineae plant, wherein the target image at least includes a target flag leaf and a target stem in the target Gramineae plant.
[0061] S220, obtaining a pre-trained key point prediction model, wherein the key point prediction model includes at least one coding layer group, and the coding layer group includes at least two coding layers connected in sequence.
[0062] The key point prediction model includes at least one, two or more coding layer groups, and when the number of coding layer groups is two or more, each coding layer group is connected in sequence. On this basis, further, a coding layer group includes two or more coding layers connected in sequence, and when the number of coding layer groups is two or more, each coding layer in the key point prediction model is connected in sequence.
[0063] S230: Input the target image into the key point prediction model to execute S240-S260 using the key point prediction model.
[0064] S240 . For each coding layer in all coding layers, use the coding layer to encode a target object input into the coding layer, wherein the target object is related to the target image.
[0065] Among them, based on this step, each coding layer in all coding layers is used for processing respectively. Here, any coding layer in all coding layers is taken as an example, and the coding layer is used to encode the target object input into the coding layer. The target object is related to the target image, for example, it can be the target image, it can be the coding feature X obtained after encoding the target image, it can be the coding feature Y obtained after encoding the coding feature X, it can also be the coding feature Z obtained after encoding the coding feature Y, etc. This is related to the actual situation and is not specifically limited here.
[0066] Exemplarily, it is assumed that the network depth of the key point prediction model is 4, that is, it includes 4 sequentially connected coding layers (here, coding layer 1, coding layer 2, coding layer 3 and coding layer 4 are taken as examples). On this basis, the target image is input into the key point prediction model, so that the target image is processed by coding layer 1 to obtain coding feature 1, that is, the target object corresponding to coding layer 1 is the target image; then, coding feature 1 is processed by coding layer 2 to obtain coding feature 2, that is, the target object corresponding to coding layer 2 is coding feature 1; then, coding feature 2 is processed by coding layer 3 to obtain coding feature 3, that is, the target object corresponding to coding layer 3 is coding feature 2; finally, coding feature 3 is processed by coding layer 4 to obtain coding feature 4, that is, the target object corresponding to coding layer 4 is coding feature 3.
[0067] S250. For each coding layer group in at least one coding layer group, concatenate coding features respectively output by each coding layer in the coding layer group to obtain concatenated features.
[0068] In this step, a single coding layer group in all coding layer groups is used as a unit for processing. Here, any coding layer group in all coding layer groups is taken as an example, and the coding features respectively output by each coding layer in the coding layer group are spliced to obtain a spliced feature. The splicing process here is the decoding process.
[0069] Continuing with the above example, assuming that the key point prediction model includes coding layer group A and coding layer group B, where coding layer group A includes coding layer 1 and coding layer 2, and coding layer group B includes coding layer 3 and coding layer 4, then the coding feature 1 output by coding layer 1 and the coding feature 2 output by coding layer 2 can be spliced to obtain spliced feature 1, and the coding feature 3 output by coding layer 3 and the coding feature 4 output by coding layer 4 can be spliced to obtain spliced feature 2.
[0070] The above feature splicing process can be understood as using a hierarchical integration architecture in the key point prediction model to achieve bidirectional mutual refinement between low-level features and high-level features through recursive feature integration.
[0071] S260. Obtain an output result according to the splicing features corresponding to at least one coding layer group, and output the output result.
[0072] According to the splicing features corresponding to each coding layer group, the output result of the key point prediction model is obtained and the output result is output. For example, each splicing feature can be spliced twice to obtain the output result; each splicing feature can be multiplied to obtain the output result; each splicing feature can also be compared to obtain the output result; etc., which are not specifically limited here.
[0073] S270. According to the output results output by the key point prediction model, a first predicted position of the flag leaf point on the target flag leaf in the target image, a second predicted position of the stem point on the target stem in the target image, and a third predicted position of the connection point between the target flag leaf and the target stem in the target image are obtained.
[0074] S280, measuring a target angle between a target flag leaf and a target stem according to the first predicted position, the second predicted position, and the third predicted position.
[0075] The technical solution of the embodiment of the present invention splices the coding features output by each coding layer in the same coding layer group, and then predicts key points based on the spliced features, thereby achieving two-way mutual refinement between low-level features and high-level features, thereby ensuring the accuracy of key point prediction.
[0076] In an optional technical solution, at least one coding layer group includes at least a first coding layer group and a second coding layer group that are connected;
[0077] According to the splicing features respectively corresponding to at least one coding layer group, an output result is obtained, including:
[0078] Using the splicing feature corresponding to the first coding layer group as the first splicing feature, and using the splicing feature corresponding to the second coding layer group as the second splicing feature;
[0079] Obtaining a first intermediate result according to the first splicing feature and the second splicing feature;
[0080] Splicing the first splicing feature and the second splicing feature to obtain a second intermediate result;
[0081] The first intermediate result and the second intermediate result are multiplied to obtain an output result.
[0082] Among them, here taking the first coding layer group and the second coding layer group that are connected in each coding layer group as an example, the coding features output by each coding layer in the first coding layer group are spliced to obtain a first splicing feature, and the coding features output by each coding layer in the second coding layer group are spliced to obtain a second splicing feature.
[0083] On this basis, further, according to the first stitching feature and the second stitching feature, a first intermediate result is obtained, for example, the first stitching feature and the second stitching feature may be multiplied to obtain the first intermediate result; the first stitching feature and the second stitching feature may also be compared to obtain the first intermediate result; and so on, which are not limited here. In combination with the application scenarios that may be involved in the embodiments of the present invention, assuming that the size of the target image is H*W, since a total of 3 key points are detected, the first intermediate result may be an array of H*W*3.
[0084] The first splicing feature and the second splicing feature are spliced to obtain a second intermediate result. Continuing with the above example, the second intermediate result can also be an array of H*W*3.
[0085] Then, the first intermediate result and the second intermediate result are multiplied to obtain an output result.
[0086] The above technical solution further improves the accuracy of key point prediction by adding a weighted spatial attention mechanism (i.e., spatial weighted attention mechanism) to the key point prediction model, i.e., by splicing two splicing features and multiplying the second intermediate result obtained based on this with the first intermediate result.
[0087] It should be noted that the above embodiments describe the application process of the key point prediction model, while the following embodiments describe the training process of the key point prediction model. In order to facilitate the distinction between the two processes, the concepts involved in the model application process are expressed as "target" or "prediction", such as target grass plant, target image, target flag leaf, target stem, first predicted position, second predicted position and third predicted position, etc., and the concepts involved in the model training process are expressed as "sample" or "annotation", such as sample grass plant, sample image, sample flag leaf, sample stem, first annotated position, second annotated position and third annotated position, etc. On this basis, in order to avoid repeated elaboration, the specific meanings of the concepts corresponding to the above embodiments appearing in the following embodiments will not be repeated.
[0088] Figure 4 It is a flow chart of another flag leaf angle measurement method provided in an embodiment of the present invention. This embodiment is optimized based on the above-mentioned technical solutions. In this embodiment, optionally, the key point prediction model is pre-trained by the following steps: obtaining a sample image collected for a sample grass plant, wherein the sample image at least includes a sample flag leaf and a sample stem in the sample grass plant; obtaining the flag leaf point on the sample flag leaf obtained by annotation at a first annotated position in the sample image, the stem point on the sample stem at a second annotated position in the sample image, and the connection point between the sample flag leaf and the sample stem at a third annotated position in the sample image; taking the sample image, the first annotated position, the second annotated position, and the third annotated position as a set of data sets to obtain multiple sets of data sets; based on at least part of the multiple sets of data sets, training the original prediction model to obtain a key point prediction model, wherein the original prediction model has the same model structure as the key point prediction model. Among them, the explanations of the terms that are the same as or corresponding to the above-mentioned embodiments are not repeated here.
[0089] See also Figure 4 The method of this embodiment may specifically include the following steps:
[0090] S310, acquiring a sample image collected for a sample Gramineae plant, wherein the sample image at least includes a sample flag leaf and a sample stem of the sample Gramineae plant.
[0091] S320, obtaining the flag leaf point on the sample flag leaf obtained through annotation at the first annotation position in the sample image, the stem point on the sample stem at the second annotation position in the sample image, and the connection point between the sample flag leaf and the sample stem at the third annotation position in the sample image.
[0092] Here, each key point in the sample image is marked, so as to obtain the marked positions of these key points in the sample image, that is, the marked positions.
[0093] In practical applications, optionally, when marking key points, the first distance and the second distance can be made as equal as possible, and in particular, can be equal, so as to facilitate model learning, thereby improving the model learning effect. The first distance represents the distance between the marked flag leaf point and the connection point, and the second distance represents the distance between the marked stem point and the connection point.
[0094] S330: taking the sample image, the first marked position, the second marked position and the third marked position as a set of data sets to obtain multiple sets of data sets.
[0095] The sample image and each annotation position are taken as a set of data sets. In practical applications, the file name of the sample image and each annotation position can be optionally taken as a set of data sets and stored in a .txt annotation file, and then the corresponding file name and annotation position are read from the annotation file, and the model training is performed based on this.
[0096] At this point, after collecting multiple sample images, corresponding samples can be constructed for different sample images, thereby obtaining multiple sets of data sets.
[0097] S340: Based on at least part of the multiple data sets, train the original prediction model to obtain a key point prediction model, wherein the original prediction model and the key point prediction model have the same model structure.
[0098] The original prediction model can be understood as a model to be trained as a key point prediction model, that is, the original prediction model has the same model structure as the key point prediction model. In combination with the application scenarios that may be involved in the embodiments of the present invention, the original prediction model can be a CNN model for realizing human posture estimation.
[0099] Based on at least part of the multiple data sets, the original prediction model is trained to obtain a key point prediction model. For example, all data sets can be used as training sets to train the original prediction model to obtain a key point prediction model; or part of the data sets in the entire data set can be used as training sets to train the original prediction model, and then another part of the data set can be used as a verification set to verify the model training effect, thereby obtaining the final key point prediction model; and so on, no specific limitation is made here.
[0100] In practical applications, before performing model training based on samples, the sample images in the samples may be optionally enhanced to increase the number of samples and thus improve the model training effect.
[0101] S350, acquiring a target image collected for the target Gramineae plant, wherein the target image at least includes a target flag leaf and a target stem in the target Gramineae plant.
[0102] S360, input the target image into the key point prediction model, and based on the output results of the key point prediction model, obtain the first predicted position of the flag leaf point on the target flag leaf in the target image, the second predicted position of the stem point on the target stem in the target image, and the third predicted position of the connection point between the target flag leaf and the target stem in the target image.
[0103] S370, measuring a target angle between a target flag leaf and a target stem according to the first predicted position, the second predicted position and the third predicted position.
[0104] The technical solution of the embodiment of the present invention realizes the effective training of the key point prediction model.
[0105] On this basis, an optional technical solution is to train the original prediction model based on at least part of the multiple data sets to obtain the key point prediction model, including:
[0106] Divide multiple sets of data into multiple training sets and multiple validation sets;
[0107] Based on multiple sets of training sets, the original prediction models under different hyperparameters are trained respectively to obtain candidate prediction models corresponding to different hyperparameters;
[0108] Based on multiple groups of verification sets, each candidate prediction model is verified respectively to determine the key point prediction model from the candidate prediction models.
[0109] The above technical solution sets different hyperparameters for the original prediction model to train the corresponding candidate prediction model, and then verifies each candidate prediction model separately, for example, by using mean square error (MSE) and other methods to verify, so as to screen out the best candidate prediction model as the key point prediction model for application, thereby ensuring the model training effect.
[0110] Another optional technical solution is to train the original prediction model based on at least part of the multiple data sets to obtain the key point prediction model, including:
[0111] For each data set in at least part of the multiple data sets, converting the first annotation position, the second annotation position, and the third annotation position in the data set into a heat map respectively;
[0112] Based on at least a portion of the transformed data set, the original prediction model is trained to obtain a key point prediction model.
[0113] The above technical solution, by converting the marked positions into heat maps and performing model training based on the heat maps, can effectively improve the model training effect compared to training directly based on the marked positions.
[0114] In order to better understand the above model training process and model application process as a whole, the following is an illustrative description of the model training process and model application process with specific examples. Figure 5 As shown, the specific implementation steps are as follows:
[0115] 1. Place a mobile phone on a portable image acquisition device, and use the mobile phone to shoot the flag leaf part of wheat at a normal angle to obtain a sample image. The portable image acquisition device includes a mobile phone clip, a bracket and a background plate.
[0116] 2. Based on the obtained sample images, a training set and a validation set are constructed, where the training set consists of 600 sample images and the validation set consists of 120 sample images. Here, the training set and the validation set are constructed by random selection, and it is ensured that the sample images in the training set do not overlap with the sample images in the validation set.
[0117] 3. For each sample image, mark it in the order of flag leaf point (L), connection point (C) and stem point (S), and record the positions (i.e. coordinates) of these three key points. Save the file names of the sample images in the training set and validation set and the coordinates of the three key points as .txt annotation files.
[0118] 4. Modify the lightweight CNN model for human posture estimation. Change the network depth to 4; use a layered integration architecture in the prediction head to achieve two-way mutual refinement between low-level features and high-level features through recursive feature integration. At the same time, before outputting the final prediction layer, add a spatial weight attention mechanism to improve the prediction effect, so as to construct the original prediction model.
[0119] 5. Take the training set obtained in step 3 as input, and convert the coordinates of each key point into a heat map in the data enhancement stage, and set different hyperparameters to train the original prediction model obtained in step 4.
[0120] 6. According to the MSE of each candidate prediction model on the validation set, the optimal candidate prediction model is selected as the final key point prediction model.
[0121] 7. Input the target image of wheat to be measured into the key point prediction model obtained in step 6, obtain the coordinates of L, C and S respectively, and calculate the flag leaf angle θ based on these coordinates in combination with the following formula:
[0122]
[0123] Figure 6This is a structural block diagram of a flag leaf angle measuring device provided in an embodiment of the present invention, and the device is used to execute the flag leaf angle measuring method provided in any of the above embodiments. The device and the flag leaf angle measuring method of the above embodiments belong to the same inventive concept, and the details not described in detail in the embodiment of the flag leaf angle measuring device can be referred to the embodiment of the flag leaf angle measuring method. Figure 6 The device may specifically include: a target image acquisition module 410, a predicted position acquisition module 420 and a target angle measurement module 430.
[0124] The target image acquisition module 410 is used to acquire a target image collected for a target Gramineae plant, wherein the target image at least includes a target flag leaf and a target stem in the target Gramineae plant;
[0125] The predicted position obtaining module 420 is used to input the target image into the pre-trained key point prediction model, and obtain the first predicted position of the flag leaf point on the target flag leaf in the target image, the second predicted position of the stem point on the target stem in the target image, and the third predicted position of the connection point between the target flag leaf and the target stem in the target image according to the output result of the key point prediction model;
[0126] The target angle measurement module 430 is used to measure the target angle between the target flag leaf and the target stem according to the first predicted position, the second predicted position and the third predicted position.
[0127] Optionally, the key point prediction model includes at least one coding layer group, and the coding layer group includes at least two coding layers connected in sequence; the flag leaf angle measurement device also includes:
[0128] An encoding module, for encoding a target object input into the encoding layer by using the encoding layer for each encoding layer in the key point prediction model after the target image is input into the pre-trained key point prediction model, wherein the target object is related to the target image;
[0129] A splicing feature obtaining module is used to splice the coding features respectively output by each coding layer in the coding layer group for each coding layer group in at least one coding layer group to obtain a splicing feature;
[0130] The output result obtaining module can be used to obtain the output result according to the splicing features respectively corresponding to at least one coding layer group.
[0131] On this basis, optionally, at least one coding layer group includes at least a first coding layer group and a second coding layer group connected; the output result obtaining module is specifically used for:
[0132] Using the splicing feature corresponding to the first coding layer group as the first splicing feature, and using the splicing feature corresponding to the second coding layer group as the second splicing feature;
[0133] Obtaining a first intermediate result according to the first splicing feature and the second splicing feature;
[0134] Splicing the first splicing feature and the second splicing feature to obtain a second intermediate result;
[0135] The first intermediate result and the second intermediate result are multiplied to obtain an output result.
[0136] Optionally, the key point prediction model is pre-trained using the following modules:
[0137] A sample image acquisition module, used to acquire a sample image collected for a sample Gramineae plant, wherein the sample image at least includes a sample flag leaf and a sample stem of the sample Gramineae plant;
[0138] A marking position acquisition module, used to acquire a first marking position of a flag leaf point on a sample flag leaf obtained by marking in a sample image, a second marking position of a stem point on a sample stem in a sample image, and a third marking position of a connection point between the sample flag leaf and the sample stem in a sample image;
[0139] A sample obtaining module, used for taking the sample image, the first annotation position, the second annotation position and the third annotation position as a set of data sets to obtain multiple sets of data sets;
[0140] The model training module is used to train the original prediction model based on at least part of the multiple data sets to obtain a key point prediction model, wherein the model structure of the original prediction model is the same as that of the key point prediction model.
[0141] On this basis, an optional model training module is specifically used to:
[0142] Divide multiple sets of data into multiple training sets and multiple validation sets;
[0143] Based on multiple sets of training sets, the original prediction models under different hyperparameters are trained respectively to obtain candidate prediction models corresponding to different hyperparameters;
[0144] Based on multiple groups of verification sets, each candidate prediction model is verified respectively to determine the key point prediction model from the candidate prediction models.
[0145] Another optional model training module is specifically used to:
[0146] For each data set in at least part of the multiple data sets, converting the first annotation position, the second annotation position, and the third annotation position in the data set into a heat map respectively;
[0147] Based on at least a portion of the transformed data set, the original prediction model is trained to obtain a key point prediction model.
[0148] The flag leaf angle measurement device provided in the embodiment of the present invention obtains a target image collected for a target Poaceae plant, especially a target flag leaf and a target stem in the target Poaceae plant, through a target image acquisition module, so as to measure the target angle between the target flag leaf and the target stem based on the target image; through a predicted position acquisition module, the target image is input into a pre-trained key point prediction model, so as to use the key point prediction model to predict each key point in the target image (i.e., the flag leaf point on the target flag leaf, the stem point on the target stem, and the connection point between the target flag leaf and the target stem), and then according to the output result of the key point prediction model, a first predicted position of the flag leaf point in the target image, a second predicted position of the stem point in the target image, and a third predicted position of the connection point in the target image can be obtained, and these positions are the key to measuring the flag leaf angle; then, through the target angle measurement module, the target angle is measured according to each obtained position. The above device predicts the key points in the target image by using the key point prediction model, and then automatically measures the flag leaf angle according to the positions of these key points, thereby solving the time-consuming and labor-intensive problem caused by manual measurement of the flag leaf angle.
[0149] The flag leaf angle measurement device provided in the embodiment of the present invention can execute the flag leaf angle measurement method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0150] It is worth noting that in the above-mentioned embodiment of the flag blade angle measurement device, the various units and modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention.
[0151] Figure 7A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0152] like Figure 7 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0153] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0154] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as the flag leaf angle measurement method.
[0155] In some embodiments, the flag leaf angle measurement method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the flag leaf angle measurement method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the flag leaf angle measurement method in any other appropriate manner (e.g., by means of firmware).
[0156] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0157] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine as a stand-alone software package and partially on a remote machine, or entirely on a remote machine or server.
[0158] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, device, or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0159] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0160] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0161] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0162] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0163] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for measuring the flag leaf angle, characterized in that: include: Acquire a target image collected for a target Gramineae plant, wherein the target image at least includes a target flag leaf and a target stem of the target Gramineae plant; The target image is input into a pre-trained key point prediction model, and based on the output results of the key point prediction model, a first predicted position of a flag leaf point on the target flag leaf in the target image, a second predicted position of a stem point on the target stem in the target image, and a third predicted position of a connection point between the target flag leaf and the target stem in the target image are obtained; A target angle between the target flag leaf and the target stem is measured based on the first predicted position, the second predicted position, and the third predicted position.
2. The method according to claim 1, characterized in that The key point prediction model includes at least one coding layer group, and the coding layer group includes at least two coding layers connected in sequence; After inputting the target image into the pre-trained key point prediction model, the method further includes: For each coding layer in the key point prediction model, using the coding layer, encoding a target object input into the coding layer, wherein the target object is related to the target image; For each coding layer group in the at least one coding layer group, concatenating coding features respectively output by each coding layer in the coding layer group to obtain a concatenated feature; The output result is obtained according to the splicing features respectively corresponding to the at least one coding layer group.
3. The method according to claim 2, characterized in that The at least one coding layer group comprises at least a first coding layer group and a second coding layer group connected; The obtaining the output result according to the splicing features respectively corresponding to the at least one coding layer group includes: Using the splicing feature corresponding to the first coding layer group as the first splicing feature, and using the splicing feature corresponding to the second coding layer group as the second splicing feature; Obtaining a first intermediate result according to the first splicing feature and the second splicing feature; Splicing the first splicing feature and the second splicing feature to obtain a second intermediate result; The first intermediate result and the second intermediate result are multiplied to obtain the output result.
4. The method according to claim 1, characterized in that: The key point prediction model is pre-trained by the following steps: Acquire a sample image collected for a sample Gramineae plant, wherein the sample image at least includes a sample flag leaf and a sample stem of the sample Gramineae plant; Obtaining a first annotated position of a flag leaf point on the sample flag leaf in the sample image, a second annotated position of a stem point on the sample stem in the sample image, and a third annotated position of a connection point between the sample flag leaf and the sample stem in the sample image obtained by annotating; Taking the sample image, the first marked position, the second marked position and the third marked position as a set of data sets to obtain multiple sets of data sets; Based on at least part of the multiple data sets, an original prediction model is trained to obtain the key point prediction model, wherein the original prediction model and the key point prediction model have the same model structure.
5. The method according to claim 4, characterized in that The step of training the original prediction model based on at least part of the plurality of data sets to obtain the key point prediction model comprises: Dividing the multiple sets of data sets into multiple sets of training sets and multiple sets of validation sets; Based on the multiple training sets, the original prediction models under different hyperparameters are trained respectively to obtain candidate prediction models corresponding to the different hyperparameters; Based on the multiple groups of verification sets, each of the candidate prediction models is verified respectively to determine the key point prediction model from the candidate prediction models.
6. The method according to claim 4, characterized in that The step of training the original prediction model based on at least part of the plurality of data sets to obtain the key point prediction model comprises: For each data set in at least part of the multiple data sets, converting the first annotation position, the second annotation position, and the third annotation position in the data set into a heat map respectively; Based on the at least part of the transformed data set, the original prediction model is trained to obtain the key point prediction model.
7. A device for measuring the angle of a flag leaf, characterized in that: include: A target image acquisition module, used to acquire a target image collected for a target Gramineae plant, wherein the target image at least includes a target flag leaf and a target stem in the target Gramineae plant; A predicted position obtaining module is used to input the target image into a pre-trained key point prediction model, and obtain a first predicted position of a flag leaf point on the target flag leaf in the target image, a second predicted position of a stem point on the target stem in the target image, and a third predicted position of a connection point between the target flag leaf and the target stem in the target image according to an output result of the key point prediction model; A target angle measurement module is used to measure a target angle between the target flag leaf and the target stem according to the first predicted position, the second predicted position and the third predicted position.
8. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor executes the flag blade angle measurement method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the flag blade angle measurement method as described in any one of claims 1 to 6 when executed.
10. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the flag blade angle measurement method according to any one of claims 1 to 6 is implemented.
