Corn tassel identification method and device, computer equipment and storage medium
By improving the YOLOv8 network architecture, combining the attention mechanism of partial convolution and CTAM modules, and optimizing hyperparameters, the problem of inaccurate recognition of corn ears in complex environments is solved, and high-precision and robust recognition effects are achieved.
Patent Information
- Application Number
- CN202411723818.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-28
- Publication Date
- 2025-03-18
AI Technical Summary
The prior art has inaccurate identification of corn ears in complex environments, making it difficult to meet the needs of large-scale agricultural production.
By improving the YOLOv8 network architecture, replacing the conventional convolution of the Backbone module into partial convolution, and adding the CTAM module to the Neck module, integrating the channel attention and timing attention mechanism, and combining the sparrow search algorithm for hyperparameter optimization, we obtain the Tassels-YOLO model.
It significantly improves the accuracy and robustness of corn ear recognition, is suitable for complex field environments, and improves the applicability and detection performance of the model.
Smart Images

Figure CN119649363A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the field of image recognition, and in particular relates to a corn tassel recognition method, device, computer equipment and storage medium. Background Art
[0002] With the continuous growth of the global population and the increasing demand for agricultural production, modern agriculture faces huge challenges in increasing food production and ensuring food security. As an important food crop in China and the world, the output of corn is directly related to the sustainable development of agriculture and national food security. The annual precipitation in arid and semi-arid climate regions is relatively small, mostly concentrated in summer, and the evaporation is much higher than the precipitation, which has serious water shortage problems. Despite the dry climate, the region has abundant light resources, with an annual sunshine duration of about 3,000 hours, which is very suitable for the cultivation of drought-resistant crops such as corn, wheat, cotton, etc.
[0003] Accurately monitoring and identifying the status of corn tassels helps determine the pollination period of corn, reasonably arrange irrigation time and water volume, avoid unnecessary waste of water resources, optimize irrigation efficiency, and ensure high corn yields under limited water resources.
[0004] Although the traditional early corn tassel identification method is feasible to a certain extent, it has many limitations, especially in large-scale agricultural production, where efficiency and accuracy are difficult to guarantee. For example, farmers or agricultural technicians visually observe the growth of corn plants, especially the appearance of tassels, and then manually record the corn pollination period. This method relies on experience. Although it is simple and intuitive and suitable for small-scale agriculture, manual observation is inefficient, time-consuming and labor-intensive, highly subjective, and easily affected by factors such as weather and environment. Therefore, it is not scalable for large-scale farmland.
[0005] Based on the above problems, RGB imaging can be used for tassel identification in the existing technology. The reflectance spectrum data of corn plants in different bands can be obtained by the RGB camera carried by the drone, which can reflect the growth status, health status and changes in the tassel of the plant. By analyzing these data through the existing algorithm model, corn ears can be effectively identified, but its accuracy is relatively limited, especially in complex field environments. Summary of the invention
[0006] In order to solve the problem of inaccurate corn tassel recognition in a complex environment, the present invention provides a corn tassel recognition method, device, computer equipment and storage medium.
[0007] In order to achieve the above object, the present invention provides the following technical solutions:
[0008] First, a method for identifying corn tassels is provided, the method comprising:
[0009] The conventional convolution of the Backbone module in the YOLOv8 network architecture is replaced with partial convolution, and the CTAM module is added to the Neck module. The channel attention and temporal attention mechanisms are integrated through the CTAM module to improve the YOLOv8 network architecture and obtain the Tassels-YOLO model. The hyperparameters of the Tassels-YOLO model are optimized through the sparrow search algorithm to obtain the target model.
[0010] Acquire training samples with corn tassels, and train the target model using the training samples to obtain a corn tassel recognition model;
[0011] The target image to be identified is input into the corn tassel recognition model, the target image is identified by the Backbone module, and the irregular areas in the target image are feature retained by partial convolution to obtain a preliminary feature map of the corn tassel; the preliminary feature map is feature extracted by the Neck module to obtain enhanced features, and the channel features of the preliminary feature map are extracted by the channel attention mechanism, and the temporal features of the preliminary feature map are extracted by the temporal attention mechanism. Based on the enhanced features, channel features and temporal features, the fused features of the corn tassel are obtained, and finally the fused features are identified by the Head module to obtain the recognition result of the corn tassel.
[0012] Optionally, replacing the conventional convolution of the Backbone module in the YOLOv8 network architecture with partial convolution includes:
[0013] The expression for establishing partial convolution based on the Backbone module in the YOLOv8 network architecture is:
[0014]
[0015] Among them, y i Represents the value of the i-th pixel in the output feature map. k is the value of the kth pixel in the convolution window corresponding to the input mask, 1 represents a valid pixel, and 0 represents an invalid pixel or an occluded part; M k is the weight of the convolution kernel corresponding to the position, x k is the value of the Kth pixel in the input feature map, ∈ is a small constant used to avoid the denominator being 0;
[0016] When there are valid pixels in the convolution window, the output of the partial convolution is normalized by weighted summation based on the valid pixels; when all pixels in the convolution window are invalid, the output is 0;
[0017] Among them, the mask update formula is:
[0018]
[0019] Among them, M′ i It is a partial convolution operation followed by a new mask; if the valid pixel value ∑ k M k >0, the updated mask value is 1, indicating that the current output image is valid;
[0020] If all pixels within the convolution window are invalid k M k =0, the updated mask value is 0, indicating that the output pixel is invalid.
[0021] Optionally, adding a CTAM module to the Neck module and fusing the channel attention and temporal attention mechanisms through the CTAM module includes:
[0022] Constructing channel attention mechanism:
[0023] A c =σ(W2·ReLU(W1·AvgPool(X)+W1·MaxPool(X)))
[0024] Where X is the input feature map with dimensions C×H×W, where C is the number of channels, H and W are the height and width respectively; AvgPool(X) and MaxPool(X) are global average pooling and global maximum pooling respectively, generating a feature vector with dimensions C×1×1; W1 and W2 are the weight matrices of the fully connected layer, σ(·) represents the Sigmoid activation function, and the output channel attention weight A c , i.e., channel characteristics;
[0025] Constructing a temporal attention mechanism:
[0026] A t =σ(W3·ReLU(W4·TemporalAvgPool(X)))
[0027] Among them, TemporalAvgPool(X) represents the average pooling operation in the time dimension, which is used to extract global information in time; ReLU(·) is the activation function, W3 and W4 are the weight matrices of the fully connected layer, similar to channel attention, which extracts temporal features by reducing and increasing dimensions; finally, the temporal attention weight At is output, which is the temporal feature;
[0028] Construct feature fusion formula based on CTAM:
[0029] By combining the channel attention weight and the temporal attention weight, the final feature weight A is expressed as:
[0030] A=A c ·At
[0031] The channel attention weight A c and temporal attention weight A t The comprehensive attention weight A is obtained by fusion through the method of element-by-element multiplication at each level.
[0032] Optionally, the performing hyperparameter optimization on the Tassels-YOLO model by using the sparrow search algorithm includes:
[0033] Initialize the sparrow population based on the Tassels-YOLO model, and regard each sparrow as a potential solution, represented by a set of hyperparameters x of the Tassels-YOLO model. i , where θ represents the hyperparameter of the model and i is the individual number;
[0034] x i ={θ1, θ2, ..., θ n}
[0035] The fitness function is used to evaluate the quality of each individual sparrow;
[0036] In the hyperparameter optimization of the Tassels-YOLO model, the loss function and mAP of the Tassels-YOLO model are selected as the optimization targets, and their formulas are:
[0037] f(x i ) = mAP(x i )
[0038] f(x i )=Loss(x i )
[0039] Update the position to iterate the heuristic algorithm;
[0040] The sparrow population is divided into finders and joiners, responsible for global and local searches, respectively;
[0041] Update individual positions. The update iteration formula for the discoverer is:
[0042]
[0043] Among them, N is the population size, r1 is a random number, and f best is the fitness function of the current optimal individual;
[0044] For participants, the specific formula is:
[0045] x i (t+1)=x i (t)+α·(x i (t)-xj (t))·r2
[0046] Among them, x j (t) is the neighboring individual, α is the adjustment parameter, and r2 is another random number;
[0047] When the fitness function convergence condition is met or the maximum number of iterations is reached, the optimization is stopped to obtain the optimal hyperparameters of the Tassels-YOLO model.
[0048] Optionally, obtaining a training sample with corn tassels includes:
[0049] The images of corn tassels at different heights are acquired by using drones, and the image quality is enhanced to obtain optimized images of corn tassels;
[0050] Use digital image segmentation technology to separate the foreground and background images of corn tassels, and highlight the color, shape and texture characteristics of corn tassels;
[0051] The corn tassels are labeled according to their color, shape and texture features to obtain training samples with corn tassels.
[0052] Optionally, the training sample with corn tassels includes an original image with corn tassels and a corresponding corn tassel annotation; training the target model by using the training sample to obtain a corn tassel recognition model includes:
[0053] Inputting the original image with corn tassels into the target model to obtain an output recognition result;
[0054] The target model is trained with the goal of minimizing the deviation between the recognition results and the corresponding corn tassel annotations;
[0055] Monitor the model’s loss function, precision, recall, and mAP metrics during training;
[0056] When the indicators meet the preset requirements, the training is determined to be completed and a corn tassel recognition model is obtained.
[0057] Optionally, the method further comprises:
[0058] Determining the growth state of the corn tassel based on the identification result of the corn tassel, and then determining the optimal pollination period of the corn according to the growth state;
[0059] In addition, the insect pest problem of corn is determined based on the growth status, and an alarm message is issued when it is determined that the insect pest problem exists.
[0060] Secondly, a corn tassel identification device is provided, the device comprising:
[0061] A construction module is used to construct a YOLOv8 network architecture, replace the conventional convolution of the Backbone module in the YOLOv8 network architecture with partial convolution, and add a CTAM module to the Neck module. The channel attention and temporal attention mechanisms are integrated through the CTAM module to improve the YOLOv8 network architecture and obtain a Tassels-YOLO model. Finally, the Tassels-YOLO model is hyperparameter optimized through a sparrow search algorithm to obtain a target model.
[0062] A training module, used for obtaining training samples with corn tassels, training a target model with the training samples, and obtaining a corn tassel recognition model;
[0063] The recognition module is used to input the target image to be recognized into the corn tassel recognition model, recognize the target image through the Backbone module, and retain the features of irregular areas in the target image through partial convolution to obtain a preliminary feature map of the corn tassel; extract features of the preliminary feature map through the Neck module to obtain enhanced features, and extract channel features of the preliminary feature map through the channel attention mechanism, and extract temporal features of the preliminary feature map through the temporal attention mechanism. Based on the enhanced features, channel features and temporal features, the fused features of the corn tassel are obtained, and finally the fused features are recognized through the Head module to obtain the recognition result of the corn tassel.
[0064] In addition, a computer-readable storage medium is provided, wherein the storage medium stores a computer program, and when the computer program is executed by a processor, the above-mentioned corn tassel identification method is implemented.
[0065] Finally, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned corn tassel identification method when executing the program.
[0066] The corn tassel identification method provided by the present invention has the following beneficial effects:
[0067] First, by replacing the conventional convolution of the Backbone module in the YOLOv8 network architecture with partial convolution, it can dynamically adapt to irregular input areas, ensure that the feature information is accurately retained when processing occluded or incomplete images, and significantly improve the detection accuracy when processing targets with complex shapes or partial occlusions such as corn tassels; secondly, a CTAM module is added to the Neck module, and the channel attention and temporal attention mechanisms are fused through the CTAM module, so that for the initially identified feature maps, the dependencies between different channels of the feature maps can be enhanced, and more distinguishing features in the image can be captured, especially for targets such as corn tassels that may have multi-scale and changing forms in the image, which can effectively improve the recognition ability of the model; finally, the Tassels-YOLO model is hyperparameter optimized through the sparrow search algorithm, which can significantly improve the model performance, save time and resources for model training, enhance the applicability and robustness of the model, and promote the application effect of the model in the present invention on corn tassel recognition. BRIEF DESCRIPTION OF THE DRAWINGS
[0068] In order to more clearly illustrate the embodiment of the present invention and its design scheme, the following briefly introduces the drawings required for this embodiment. 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.
[0069] Figure 1 The present invention is a schematic flow chart of a method for identifying a corn tassel according to an exemplary embodiment of the present invention.
[0070] Figure 2 A flowchart of target model construction deployment provided by the present invention according to an exemplary embodiment.
[0071] Figure 3 The present invention is a flowchart of sample image preprocessing according to an exemplary embodiment.
[0072] Figure 4 A flow chart of sample image classification and annotation provided by the present invention according to an exemplary embodiment.
[0073] Figure 5 This is a diagram showing the effect of corn tassel recognition provided according to an exemplary embodiment of the present invention.
[0074] Figure 6 The present invention is a block diagram of a corn tassel identification device according to an exemplary embodiment of the present invention. DETAILED DESCRIPTION
[0075] In order to enable those skilled in the art to better understand the technical solution of the present invention and implement it, the present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. The following embodiments are only used to more clearly illustrate the technical solution of the present invention, and cannot be used to limit the scope of protection of the present invention.
[0076] The present invention utilizes digital image technology and deep learning technology to perform a technical route for corn tassel recognition, including:
[0077] Data collection and preprocessing: Use drones to obtain images of corn tassels at different heights and perform image quality enhancement, such as preprocessing operations such as translation, rotation, filtering, and brightness change at any time to improve image quality and adaptability, and provide high-quality data for subsequent feature extraction and recognition.
[0078] Feature extraction and annotation, using digital image segmentation technology, separate the corn tassel foreground and background images, highlighting its color, shape, texture and other features. Then focus on the position of the corn tassel and generate a labeled data set for training. This step ensures that the corn tassel in the image can be accurately identified and annotated, providing training data for the deep learning model.
[0079] The "Tassels-YOLO" model is proposed for the target detection task of corn tassels. The robustness, detection accuracy and operational stability of the model are improved by introducing local convolution, CTAM modules and sparrow search algorithm. This step focuses on the optimization and improvement of the model to adapt it to complex field environments.
[0080] To guide actual production, corn tassel identification can accurately determine the pollination period, thereby more effectively arranging field management operations such as fertilization and irrigation, and timely early warning of pests and diseases. In addition, through data-driven decision support, agricultural production efficiency can be improved, costs can be saved, agricultural mechanization can be promoted, and intelligent and efficient modern agricultural management can be realized.
[0081] The technical solutions provided by various embodiments of the present invention are described in detail below in conjunction with the accompanying drawings.
[0082] First, the present invention provides a method for identifying corn tassels, specifically, Figure 1 As shown, the following steps are included:
[0083] S101, based on the YOLOv8 network architecture, improve and obtain the target model.
[0084] Specifically, firstly, in the process of model building, we select YOLOv8, a deep learning model architecture suitable for the task of corn tassel detection. We build the YOLOv8 network architecture, replace the conventional convolution of the Backbone module in the YOLOv8 network architecture with partial convolution, and add the CTAM module to the Neck module. Through the CTAM module, we integrate the channel attention and temporal attention mechanisms to improve the YOLOv8 network architecture and obtain the improved model Tassels-YOLO. Finally, we use the sparrow search algorithm to optimize the hyperparameters of the Tassels-YOLO model to obtain the target model. The construction, improvement, training, and deployment process of the target model can be described as follows: Figure 2 shown.
[0085] In one embodiment, in order to enhance the feature extraction capability of the YOLOv8 network architecture, a partial convolution Pconv module is used to process irregular or occluded areas in the input data. This method can significantly improve the detection accuracy when processing objects with complex shapes or partial occlusions such as corn tassels.
[0086] The core idea of Pconv is to dynamically adapt to irregular input areas and use masks to control the effective convolution area to ensure that feature information is accurately preserved when processing occluded or incomplete images. This feature makes Pconv perform particularly well in tasks such as image restoration and semantic segmentation, especially when processing partially missing or high-noise images, Pconv can significantly enhance the robustness of the model and the accuracy of detection.
[0087] The expression for establishing partial convolution based on the Backbone module in the YOLOv8 network architecture is:
[0088]
[0089] Among them, y i Represents the value of the i-th pixel in the output feature map. k M is the value of the kth pixel in the convolution window corresponding to the input mask (1 indicates a valid pixel, 0 indicates an invalid pixel or an occluded part). k is the weight of the convolution kernel corresponding to the position, x k is the value of the Kth pixel in the input feature map, and ∈ is a small constant used to avoid the denominator being 0. When there are valid pixels in the convolution window, the output of the partial convolution is weighted and normalized according to the valid pixels; when all pixels in the convolution window are invalid, the output is 0.
[0090] Among them, the mask update formula is:
[0091]
[0092] Among them, M′i It is a partial convolution operation followed by a new mask. If the valid pixel value ∑ k M k >0, the updated mask value is 1, indicating that the current output image is valid. If all pixels in the convolution window are invalid, ∑ k M k =0, the updated mask value is 0, indicating that the output pixel is invalid.
[0093] In another embodiment, in order to improve the feature expression capability of the YOLOv8 network architecture, the present invention integrates the CTAM module in the Neck part. The module combines the channel attention and temporal attention mechanisms, can enhance the dependency between different channels, and capture more distinguishing features in the image, especially for corn tassels, which may exist in multiple scales and changeable forms in the image, and can effectively improve the recognition ability of the model.
[0094] The first step is to build a channel attention mechanism:
[0095] A c =σ(W2·ReLU(W1·AvgPool(X)+W1·MaxPool(X)))
[0096] Among them, X is the input feature map, with dimensions of C×H×W, where C is the number of channels, H and W are the height and width respectively. AvgPool(X) and MaxPool(X) are global average pooling and global maximum pooling, respectively, generating a feature vector of dimension C×1×1. W1 and W2 are the weight matrices of the fully connected layer, which are used to reduce the number of channels and reconstruct features. Usually W1 will reduce the number of channels to the original channel. Where r is the compression ratio, σ(·) represents the Sigmoid activation function, and the output channel attention weight A c , that is, channel features, the final channel attention A c Applied to the input feature map via element-wise multiplication.
[0097] The second step is to build a temporal attention mechanism:
[0098] A t =σ(W3·ReLU(W4·TemporalAvgPool(X)))
[0099] Among them, TemporalAvgPool(X) represents the average pooling operation in the time dimension, which is used to extract global information in time. ReLU(·) is the activation function, W3 and W4 are the weight matrices of the fully connected layer, which are similar to channel attention and extract temporal features by reducing and increasing dimensions. The final temporal attention weight At (i.e., temporal feature) is generated by the Sigmoid function and multiplied by the input feature.
[0100] The third step is to build a feature fusion formula based on CTAM:
[0101] By combining the channel attention weight and the temporal attention weight, the final feature weight A can be expressed as
[0102] A=A c ·A t
[0103] The channel attention weight A c and temporal attention weight A t The comprehensive attention weight A is obtained by fusion through the method of element-by-element multiplication, and then applied to the input feature map to strengthen the model's attention to important temporal and channel features.
[0104] In another embodiment, the present invention uses a sparrow search algorithm and applies it to the Tassels-YOLO model optimization of the improved YOLOv8 network architecture. The main purpose is to use the global search capability of the sparrow search algorithm to optimize certain hyperparameters (learning rate, weight initialization) in the Tassels-YOLO model, thereby improving the detection performance of the model. The sparrow search algorithm optimization process is as follows: based on the improved YOLOv8 network architecture, the sparrow population is initialized, and each sparrow is regarded as a potential solution, which is represented by a set of hyperparameters x of the improved YOLOv8 network architecture. i , where θ represents the hyperparameter of the model and i is the individual number.
[0105] x i ={θ1, θ2, ..., θ n}
[0106] Secondly, a fitness function is used to evaluate the quality of each individual. In the hyperparameter optimization of the Tassels-YOLO model, the loss function and mAP of the network architecture can be selected as the optimization target, and the formula can be expressed as follows.
[0107] f(x i ) = mAP(x i )
[0108] f(x i )=Loss(xi )
[0109] Then, the position is updated to iterate the heuristic algorithm. The sparrow population is divided into discoverers and joiners, which are responsible for global and local searches respectively. The update iteration formula for the discoverer is as follows:
[0110]
[0111] Among them, N is the population size, r1 is a random number, and f best is the fitness function of the current optimal individual.
[0112] For participants, the specific formula is as follows:
[0113] x i (t+1)=x i (t)+α·(x i (t)-x j (t))·r2
[0114] Among them, xj(t) is the neighboring individual, α is the adjustment parameter, and r2 is another random number.
[0115] Finally, when the fitness function convergence condition is met or the maximum number of iterations is reached, the optimization is stopped to obtain the optimal hyperparameters of the Tassels-YOLO model.
[0116] S102, training the target model to obtain a corn tassel recognition model.
[0117] In some embodiments, a training sample with corn tassels may be first obtained, and a target model may be trained using the training sample to obtain a corn tassel recognition model.
[0118] Specifically, after the model is built and optimized, the model training phase begins. The built model is used for the training data set, and the model weights are continuously updated through back propagation and gradient descent algorithms. Combined with the modular optimization performed in the early stage, the model will gradually improve its detection capabilities for targets such as corn tassels. During the training process, the model's loss function, accuracy, recall rate, mAP (mean Average Precision) and other indicators are monitored to ensure that the model's performance is continuously optimized.
[0119] For example, the original image with corn tassels can be input into the target model to obtain an output recognition result; the target model is trained with the goal of minimizing the deviation between the recognition result and the corresponding corn tassel annotation; the loss function, precision, recall rate and mAP index of the model are monitored during the training process; when the index meets the preset requirements, the training is determined to be completed and a corn tassel recognition model is obtained.
[0120] In some possible implementations, the accuracy of the samples has a significant impact on the training effect of the model. Therefore, in order to improve the final recognition accuracy of the model, samples with higher accuracy are required.
[0121] For example, images of corn tassels at different heights can be acquired by drones, and image quality can be enhanced to obtain optimized images of corn tassels. Digital image segmentation technology can be used to separate the foreground and background images of the corn tassels to highlight the color, shape, and texture features of the corn tassels. The corn tassels can be labeled according to their color, shape, and texture features to obtain training samples with corn tassels.
[0122] like Figure 3 As shown in the figure, by using drones to obtain early corn tassel images at different heights, image data from multiple angles and heights are collected. The collected images are pre-processed by image quality enhancement operations, including brightness adjustment and contrast adjustment, to improve the visual effect of the image and make the details clearer.
[0123] The brightness adjustment is achieved by adding a constant β to each pixel value of the image. The formula is as follows:
[0124] I′(x, y)=I(x, y)+β
[0125] In this formula, I(x, y) represents the pixel value at position (x, y) in the original image. I′(x, y) is the pixel value after brightness adjustment. β is a constant used to adjust brightness. Increasing β makes the image brighter, while decreasing β makes the image darker.
[0126] Contrast adjustment changes the contrast by scaling each pixel value in the image. The formula is as follows
[0127] I′(x, y)=α·I(x, y)+β
[0128] In this formula, α is the contrast adjustment coefficient, which is usually a positive number. α greater than 1 will increase the contrast, and α less than 1 will reduce the contrast. β is a constant for brightness adjustment, which is used to adjust the overall brightness like the brightness adjustment formula. I(x, y) and I′(x, y) are the pixel values before and after adjustment, respectively. When α=1 and β=0, the image remains unchanged. When α>1, the image contrast is enhanced. When α<1, the image contrast is weakened. When β>0, the image becomes brighter as a whole; when β<0, the image becomes darker as a whole. By combining these two formulas, the image brightness and contrast can be adjusted at the same time, thereby achieving the purpose of enhancing image quality.
[0129] After the initial adjustment of brightness and contrast, the image is preprocessed, including random translation, random rotation, filtering and other image enhancement methods to further improve the diversity and adaptability of the image.
[0130] Image translation refers to moving the image horizontally or vertically. Assuming the pixel coordinates of the image are (x, y), the new coordinates after translation are (x′, y′), and the formula is as follows. x and t y is the translation amount randomly generated within a given range, representing the horizontal and vertical translations respectively. (x′, y′) is the new coordinate of the pixel after translation.
[0131] x′=x+t x
[0132] y=y+t y
[0133] Image rotation is the rotation around the center point of the image. The rotation formula is as follows, where θ is the rotation angle, expressed in radians, which can be randomly selected within a given range.
[0134] x′=x·cos(θ)-y·sin(θ)
[0135] y′=x·sin(θ)-y·cos(θ)
[0136] Filtering is the process of processing images through convolution operations. Common filters include Gaussian filtering, median filtering, and mean filtering. The formula for filtering can be expressed through convolution operations. The general form is as follows:
[0137]
[0138] Where I(x, y) is the pixel value at position (x, y) in the original image, and I′(x, y) is the pixel value after filtering. K(i, j) is the value of the convolution kernel, usually a (2k+1)×(2k+1) matrix. K is the radius of the convolution kernel, which determines the size of the filter.
[0139] Gaussian filtering is a commonly used smoothing process that uses a Gaussian function as the convolution kernel. The value of the convolution kernel K(i, j) is obtained by the following formula. σ is the standard deviation, which determines the width of the Gaussian kernel.
[0140]
[0141] Median filtering takes the median value of the pixel values in the neighborhood around each pixel of the image, which is obtained by the following formula
[0142] I′(x,y)=media{I(x+i,y+i)|i,j∈[-k,k]}
[0143] Mean filtering is to smooth the average value of pixels in the neighborhood, which reduces noise and blurs image details. The formula is:
[0144]
[0145] These operations can effectively improve the diversity of the dataset during image enhancement, thereby improving the robustness of the model.
[0146] like Figure 4 As shown in the figure, for the collected early tassel image of corn, the GrabCut algorithm is used here to segment the image foreground and background, which is used to process the background in complex scenes to achieve classification and labeling of sample images. The algorithm separates the foreground and background by iteratively optimizing and minimizing the energy function. The energy function E(L, z) consists of the data term U(L, z) and the smoothing term V(L). U(L, z) describes the degree of match between the pixel value and the Gaussian mixture model to which it is assigned. V(L) encourages adjacent pixels to have the same label.
[0147] The formula of the energy function is as follows:
[0148]
[0149] In the above formula, L i represents the label of the i-th pixel (foreground or background), Z i Indicates the color of the i-th pixel. U(L i , Z i )=-log(P(L i |Z i )), indicating that pixel i has a given label L i The likelihood at time (determined by the Gaussian module). It is used to penalize the inconsistent labels of adjacent pixels, δ is the standard deviation of color difference, and γ is the weight. By minimizing this energy function, GrabCut can effectively separate the corn tassel from the background.
[0150] According to the features extracted by the above algorithm and the segmentation results, the positions of corn ears in the corn image are manually annotated to ensure the accuracy of the annotation. A high-quality annotated dataset containing rich corn tassel color, shape and texture features is generated to improve the detection and recognition capabilities of the model in practical applications.
[0151] S103, inputting the target image to be identified into a corn tassel recognition model to obtain a recognition result.
[0152] When the model reaches the latest expectations, the model deployment phase is carried out. The model can be deployed on edge devices such as drones and low-computing platforms and can also run efficiently. During deployment, the model is integrated into the actual system to ensure that it can process input data in a real-time environment and complete the real-time recognition of early corn tassels. In addition, after deployment, the operation of the model needs to be continuously monitored, and the model needs to be continuously adjusted and optimized based on feedback from actual application scenarios to ensure its robustness and performance stability in different environments.
[0153] Specifically, the recognition effect of the model can be monitored. The target image to be identified is input into the corn tassel recognition model, the target image is identified through the Backbone module, and the irregular area in the target image is feature retained through partial convolution to obtain a preliminary feature map of the corn tassel; the preliminary feature map is feature extracted through the Neck module to obtain enhanced features, and the channel features of the preliminary feature map are extracted through the channel attention mechanism, and the temporal features of the preliminary feature map are extracted through the temporal attention mechanism. Based on the enhanced features, channel features and temporal features, the fusion features of the corn tassel are obtained; finally, the fusion features are identified through the Head module to obtain the recognition result of the corn tassel. Regular monitoring of the recognition results of the model, continuous adjustment and optimization based on feedback in actual application scenarios can ensure its robustness and performance stability.
[0154] In one embodiment, the growth status of the corn tassel can be determined based on the recognition result of the corn tassel, and then the optimal pollination period of the corn can be determined according to the growth status; in addition, the insect pest problem of the corn can be determined according to the growth status, and an alarm message can be issued if it is determined that there is an insect pest problem.
[0155] For example, data on corn tassels and the environment are collected by patrolling the fields, and then analyzed to provide a basis for subsequent agricultural management and decision-making. Using the images and data collected by drones, image processing and deep learning techniques are used to identify corn tassels, and the identification results are obtained, such as Figure 5 As shown, the optimal pollination period for corn can be determined. This plays a key role in increasing corn yields. Another important function is to optimize field management. Through data analysis, the growth status of crops can be monitored, and management measures such as irrigation and fertilization can be optimized to improve agricultural production efficiency. It can also identify pest and disease problems in farmland in a timely manner, and provide early warning information in combination with pest and disease model information. Such technology can help farmers take measures early to reduce the damage to crops caused by pests.
[0156] After the drone data analysis is completed, all the information is aggregated into an intelligent decision support system. The system combines multiple data to provide farmers with optimized management decisions and suggestions on when to irrigate, fertilize, or control pests and diseases. Ultimately, through drone data and intelligent decision support systems, we can promote the mechanization and intelligence of agricultural management, improve the efficiency of crop management, and realize the automation and precision management of modern agriculture.
[0157] By adopting the above method, firstly, by replacing the conventional convolution of the Backbone module in the YOLOv8 network architecture with partial convolution, it is possible to dynamically adapt to irregular input areas, ensure that when processing occluded or incomplete images, the feature information is accurately retained, and when processing targets with complex shapes or partial occlusions such as corn tassels, the detection accuracy can be significantly improved; secondly, a CTAM module is added to the Neck module, and the channel attention and temporal attention mechanisms are fused through the CTAM module, so that for the initially identified feature map, the dependency between different channels of the feature map can be enhanced, and more distinguishing features in the image can be captured, especially for targets such as corn tassels that may have multi-scale and changing forms in the image, which can effectively improve the recognition ability of the model; finally, the sparrow search algorithm is used to perform hyperparameter optimization on the improved YOLOv8 network architecture, which can significantly improve the model performance, save time and resources for model training, enhance the applicability and robustness of the model, and promote the application effect of the model in the present invention on corn tassel recognition.
[0158] Secondly, the present invention also provides a corn tassel identification device, such as Figure 6 As shown, including:
[0159] A construction module 601 is used to construct a YOLOv8 network architecture, replace the conventional convolution of the Backbone module in the YOLOv8 network architecture with partial convolution, and add a CTAM module to the Neck module. The channel attention and temporal attention mechanisms are integrated through the CTAM module to improve the YOLOv8 network architecture and obtain a Tassels-YOLO model. Finally, the Tassels-YOLO model is hyperparameter optimized through a sparrow search algorithm to obtain a target model.
[0160] A training module 602 is used to obtain training samples with corn tassels, and train the target model through the training samples to obtain a corn tassel recognition model;
[0161] The recognition module 603 is used to input the target image to be recognized into the corn tassel recognition model, recognize the target image through the Backbone module, and retain the features of irregular areas in the target image through partial convolution to obtain a preliminary feature map of the corn tassel; extract features of the preliminary feature map through the Neck module to obtain enhanced features, and extract channel features of the preliminary feature map through the channel attention mechanism, and extract temporal features of the preliminary feature map through the temporal attention mechanism. Based on the enhanced features, channel features and temporal features, the fused features of the corn tassel are obtained, and finally the fused features are recognized through the Head module to obtain the recognition result of the corn tassel.
[0162] The present invention also provides a computer-readable storage medium, which stores a computer program, which can be used to execute the above Figure 1 Steps of a method for identifying corn tassels are provided.
[0163] The present invention also provides a computer device. At the hardware level, the computer device includes a processor, an internal bus, a network interface, a memory, and a non-volatile memory. Of course, it may also include hardware required for other services. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to achieve the above Figure 1 Steps of a method for identifying corn tassels are provided.
[0164] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods, systems or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0165] The present invention is described with reference to flowcharts and / or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as a combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0166] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0167] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0168] It should be noted that the above specific implementation method can enable those skilled in the art to understand the invention more comprehensively, but does not limit the invention in any way. Therefore, although the present invention has been described in detail in this specification, those skilled in the art should understand that the invention can still be modified or replaced by equivalents; and all technical solutions and improvements that do not deviate from the spirit and scope of the invention are included in the protection scope of the patent for the invention. Any figure mark in the claims should not be regarded as limiting the claims involved.
Claims
1. A method for identifying corn tassels, characterized in that: The method comprises: The conventional convolution of the Backbone module in the YOLOv8 network architecture is replaced with partial convolution, and the CTAM module is added to the Neck module. The channel attention and temporal attention mechanisms are integrated through the CTAM module to improve the YOLOv8 network architecture and obtain the Tassels-YOLO model. The hyperparameters of the Tassels-YOLO model are optimized through the sparrow search algorithm to obtain the target model. Acquire training samples with corn tassels, and train the target model using the training samples to obtain a corn tassel recognition model; The target image to be identified is input into the corn tassel recognition model, the target image is identified by the Backbone module, and the irregular areas in the target image are feature retained by partial convolution to obtain a preliminary feature map of the corn tassel; the preliminary feature map is feature extracted by the Neck module to obtain enhanced features, and the channel features of the preliminary feature map are extracted by the channel attention mechanism, and the temporal features of the preliminary feature map are extracted by the temporal attention mechanism. Based on the enhanced features, channel features and temporal features, the fused features of the corn tassel are obtained, and finally the fused features are identified by the Head module to obtain the recognition result of the corn tassel.
2. A method for identifying corn tassels according to claim 1, characterized in that: Replacing the conventional convolution of the Backbone module in the YOLOv8 network architecture with partial convolution includes: The expression for establishing partial convolution based on the Backbone module in the YOLOv8 network architecture is: Among them, y i Represents the value of the i-th pixel in the output feature map. k is the value of the kth pixel in the convolution window corresponding to the input mask, 1 represents a valid pixel, and 0 represents an invalid pixel or an occluded part; M k is the weight of the convolution kernel corresponding to the position, x k is the value of the Kth pixel in the input feature map, ∈ is a small constant used to avoid the denominator being 0; When there are valid pixels in the convolution window, the output of the partial convolution is normalized by weighted summation based on the valid pixels; when all pixels in the convolution window are invalid, the output is 0; Among them, the mask update formula is: Among them, M' i It is a partial convolution operation followed by a new mask; if the valid pixel value ∑ k M k >0, the updated mask value is 1, indicating that the current output image is valid; If all pixels within the convolution window are invalid k M k =0, the updated mask value is 0, indicating that the output pixel is invalid.
3. A method for identifying corn tassels according to claim 1, characterized in that: The CTAM module is added to the Neck module, and the channel attention and temporal attention mechanisms are integrated through the CTAM module. Constructing channel attention mechanism: A c =σ(W2·ReLU(W1·AvgPool(X)+W1·MaxPool(X))) Where X is the input feature map with dimensions C×H×W, where C is the number of channels, H and W are the height and width respectively; AvgPool(X) and MaxPool(X) are global average pooling and global maximum pooling respectively, generating a feature vector with dimensions C×1×1; W1 and W2 are the weight matrices of the fully connected layer, σ(·) represents the Sigmoid activation function, and the output channel attention weight A c , i.e., channel characteristics; Constructing a temporal attention mechanism: TO t =σ(W3·ReLU(W4·TemporalAvgPool(X))) Among them, TemporalAvgPool(X) represents the average pooling operation in the time dimension, which is used to extract global information in time; ReLU(·) is the activation function, W3 and W4 are the weight matrices of the fully connected layer, similar to channel attention, which extracts temporal features by reducing and increasing dimensions; finally, the temporal attention weight A is output t , which is the time series feature; Construct feature fusion formula based on CTAM: By combining the channel attention weight and the temporal attention weight, the final feature weight A is expressed as: A=A c ·A t The channel attention weight A c and temporal attention weight A t The comprehensive attention weight A is obtained by fusion through the method of element-by-element multiplication at each level.
4. A method for identifying corn tassels according to claim 1, characterized in that: The hyperparameter optimization of the Tassels-YOLO model by the sparrow search algorithm includes: Initialize the sparrow population based on the Tassels-YOLO model, and regard each sparrow as a potential solution, represented by a set of hyperparameters x of the Tassels-YOLO model. i , where θ represents the hyperparameter of the model and i is the individual number; x i ={θ1,θ2,…,θ n } The fitness function is used to evaluate the quality of each individual sparrow; In the hyperparameter optimization of the Tassels-YOLO model, the loss function and mAP of the Tassels-YOLO model are selected as the optimization targets, and their formulas are: f(x i )=mAP(x i ) f(x i )=Loss(x i ) Update the position to iterate the heuristic algorithm; The sparrow population is divided into finders and joiners, responsible for global and local searches, respectively; Update individual positions. The update iteration formula for the discoverer is: Among them, N is the population size, r1 is a random number, and f best is the fitness function of the current optimal individual; For participants, the specific formula is: x i (t+1)=x i (t)+α·(x i (t)-x j (t))·r2 Among them, x j (t) is the neighboring individual, α is the adjustment parameter, and r2 is another random number; When the fitness function convergence condition is met or the maximum number of iterations is reached, the optimization is stopped to obtain the optimal hyperparameters of the Tassels-YOLO model.
5. A method for identifying corn tassels according to claim 1, characterized in that: The step of obtaining a training sample with corn tassels comprises: The images of corn tassels at different heights are acquired by using drones, and the image quality is enhanced to obtain optimized images of corn tassels; Use digital image segmentation technology to separate the foreground and background images of corn tassels, and highlight the color, shape and texture characteristics of corn tassels; The corn tassels are labeled according to their color, shape and texture features to obtain training samples with corn tassels.
6. A method for identifying corn tassels according to claim 5, characterized in that: The training sample with corn tassels includes an original image with corn tassels and a corresponding corn tassel annotation; The target model is trained by the training samples to obtain a corn tassel recognition model including: Inputting the original image with corn tassels into the target model to obtain an output recognition result; The target model is trained with the goal of minimizing the deviation between the recognition results and the corresponding corn tassel annotations; Monitor the model’s loss function, precision, recall, and mAP metrics during training; When the indicators meet the preset requirements, the training is determined to be completed and a corn tassel recognition model is obtained.
7. A method for identifying corn tassels according to claim 1, characterized in that: The method further comprises: Determining the growth state of the corn tassel based on the identification result of the corn tassel, and then determining the optimal pollination period of the corn according to the growth state; In addition, the insect pest problem of corn is determined based on the growth status, and an alarm message is issued when it is determined that the insect pest problem exists.
8. A corn tassel identification device, characterized in that: The device comprises: A construction module is used to construct a YOLOv8 network architecture, replace the conventional convolution of the Backbone module in the YOLOv8 network architecture with partial convolution, and add a CTAM module to the Neck module. The channel attention and temporal attention mechanisms are integrated through the CTAM module to improve the YOLOv8 network architecture and obtain a Tassels-YOLO model. Finally, the Tassels-YOLO model is hyperparameter optimized through a sparrow search algorithm to obtain a target model. A training module, used for obtaining training samples with corn tassels, training a target model with the training samples, and obtaining a corn tassel recognition model; The recognition module is used to input the target image to be recognized into the corn tassel recognition model, recognize the target image through the Backbone module, and retain the features of irregular areas in the target image through partial convolution to obtain a preliminary feature map of the corn tassel; extract features of the preliminary feature map through the Neck module to obtain enhanced features, and extract channel features of the preliminary feature map through the channel attention mechanism, and extract temporal features of the preliminary feature map through the temporal attention mechanism. Based on the enhanced features, channel features and temporal features, the fused features of the corn tassel are obtained, and finally the fused features are recognized through the Head module to obtain the recognition result of the corn tassel.
9. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
10. A computer device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to any one of claims 1 to 7 when executing the program.