Deep learning-based corn seed variety identification and contour segmentation method and device
By improving the YOLOv11 model to ConvNeXt V2 and designing a dual-task collaborative loss function, the problem of integrated detection of maize variety identification and seed segmentation was solved, achieving efficient maize seed variety identification and contour segmentation, which is suitable for resource-constrained scenarios.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ZHEJIANG GONGSHANG UNIVERSITY
- Filing Date
- 2025-12-18
- Publication Date
- 2026-05-01
AI Technical Summary
Existing technologies struggle to achieve integrated detection of maize varieties and seed segmentation, especially when the maize is naturally placed, making it difficult to handle subtle differences between similar varieties. Furthermore, the large number of model parameters and high computational costs make them difficult to deploy in resource-constrained scenarios.
An improved YOLOv11 model was adopted, replacing the backbone network with ConvNeXt V2. An image-level variety classification head was added, a dual-task collaborative loss function was designed, and the model was trained through data augmentation techniques to achieve parallel output of variety recognition and contour segmentation.
It achieves efficient corn seed variety identification and contour segmentation in resource-constrained scenarios, improves identification and segmentation efficiency, reduces model parameters and computational costs, and can handle subtle differences between similar varieties in natural placement.
Smart Images

Figure CN121963186A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of maize variety identification technology, and in particular to a method and apparatus for maize seed variety identification and contour segmentation based on deep learning. Background Technology
[0002] As one of the world's most important economic food crops, the accurate identification and quality testing of maize varieties are crucial for seed quality supervision, breeding optimization, and agricultural production. In recent years, with the rapid development of maize breeding technology, the number of varieties has increased dramatically, while the morphological differences between varieties have gradually narrowed, leading to a mixed variety market and inconsistent quality. Therefore, developing accurate and efficient methods for maize seed variety identification and seed quality testing is of significant practical importance.
[0003] Currently, research on maize quality identification and seed quality detection still has shortcomings: First, it often focuses on processing single tasks, making it difficult to achieve integrated detection of variety identification and seed segmentation, thus failing to meet practical application needs. Second, there is a significant gap between existing research and actual detection requirements. In real-world scenarios, it is necessary not only to identify batches of naturally placed seeds as a whole, but also to pay attention to morphological differences between seeds of the same variety. However, current research often adopts simplified solutions: either based on inefficient single-seed identification, or only performing image-level classification for a few significantly different varieties, and the samples are manually arranged according to rules before detection, resulting in limited generalization ability of the models in real complex scenarios, making it difficult to effectively handle subtle differences between similar varieties in naturally placed states and morphological changes between seeds of the same variety. Third, some models have a large number of parameters and high computational costs, making them difficult to deploy effectively in resource-constrained scenarios such as embedded devices. Summary of the Invention
[0004] The purpose of this application is to overcome the problems of existing maize variety recognition models, such as difficulty in achieving integrated detection of variety recognition and seed segmentation, difficulty in effectively handling subtle differences between similar varieties under natural placement conditions and morphological changes between seeds of the same variety, as well as large model parameters and high computational costs. This application provides a method and device for maize seed variety recognition and contour segmentation based on deep learning.
[0005] Firstly, a deep learning-based method for maize seed variety identification and contour segmentation is provided, including: Acquire images of corn kernels from multiple varieties, where each corn kernel image contains multiple corn kernels; The corn kernel images are labeled to obtain a training dataset, wherein the labeling content includes the outline of the corn kernels and the variety; An improved YOLOv11 model was constructed, specifically including: replacing the backbone network with the ConvNeXt V2 network on the basis of the YOLOv11 model, adding an image-level variety classification head, and adopting a dual-task collaborative loss function. The improved YOLOv11 model was trained using the training dataset to obtain a variety recognition and contour segmentation model. Acquire images of corn kernels to be detected, and use variety recognition and contour segmentation models to perform variety recognition and contour segmentation on the images of corn kernels to be detected.
[0006] Some possible implementations also include: data augmentation that randomly rotates, changes the brightness, and adds noise to the labeled maize kernel images.
[0007] In some possible implementations, the neck network of the improved YOLOv11 model includes an SPPF module, a C2PSA attention mechanism, and cross-level feature concatenation, which output three-level feature maps, P3, P4, and P5, corresponding to target detection information at different scales.
[0008] In some possible implementations, the ConvNeXt V2 network includes an input layer, a feature extraction layer, and an output layer. The input layer includes a convolutional layer and a normalization layer connected in sequence. The feature extraction layer includes a first stage, a second stage, a third stage, and a fourth stage, wherein the first, second, third, and fourth stages are connected in sequence. Each stage consists of a downsampling layer and repeatedly stacked ConvNeXt V2 modules. The downsampling layer consists of a normalization layer and a convolutional layer, achieving a halving of the feature map size and a doubling of the number of channels through a convolution with a stride of 2. The ConvNeXt V2 modules in the first, second, third, and fourth stages are repeated 2, 2, 6, and 2 times, respectively. Each ConvNeXt V2 module... The V2 module is internally connected to a 7×7 deep convolutional layer, a normalization layer, a 1×1 convolutional layer, an activation function, a global response normalization layer, a 1×1 convolutional layer, and a random dropout layer. The second, third, and fourth stages are aligned with the P3, P4, and P5 feature layers of the neck network input, respectively, and are responsible for the feature representation of small, medium, and large targets.
[0009] In some possible implementations, the improved YOLOv11 model uses a dual-branch output in the head network. The first output is a newly added image-level variety classification head, which is used to output an image-level category probability distribution vector based on the fused high-level semantic features, and outputs the maize variety identification result by selecting the maximum probability. The second output is the original instance segmentation head, which is used to output the seed bounding box localization information and mask segmentation results.
[0010] In some possible implementations, the loss function of the improved YOLOv11 model The calculation formula is: ; in, To achieve a complete intersection and comparison loss, For Dice's loss, For binary cross-entropy loss, For the distribution focus loss, For cross-entropy loss, , and For hyperparameter weights.
[0011] In some possible implementations, the formula for calculating the complete intersection-union ratio loss is:
[0012]
[0013]
[0014] in, IoU The intersection-union ratio (IU) of the predicted bounding box and the ground truth bounding box. ρ The Euclidean distance between the two center points. b and b gt These are the center points of the predicted bounding box and the ground truth bounding box, respectively. c It is the diagonal distance of the smallest closure region that simultaneously contains both the predicted bounding box and the ground truth bounding box. α As a balance factor, υ The aspect ratio difference coefficient. w and h These are the width and height of the predicted bounding box, respectively. w gt and h gt These are the width and height of the actual bounding box, respectively; The formula for calculating the Dice loss is as follows:
[0015] in, N The total number of mask pixels, P i and G i The respective i The predicted value and the true value of each pixel. To prevent tiny values with a denominator of 0; The formula for calculating the binary cross-entropy loss is as follows:
[0016] in, N Number of varietiesy i For real labels, p i To predict class probabilities; The formula for calculating the distribution focus loss is as follows:
[0017] in, The four regression parameters corresponding to the bounding box ; R For the number of regression channels, The distribution labels corresponding to the actual offsets. To predict the probability distribution.
[0018] The formula for calculating the cross-entropy loss is as follows:
[0019]
[0020] in, N Number of varieties y i Image-level realistic labels, The predicted probability is the result of activation by the normalized exponential function. z i The corresponding first-order output of the image-level classification head i The logarithmic probability value of the class.
[0021] Secondly, a deep learning-based device for corn seed variety identification and contour segmentation is provided, comprising: The image acquisition module is used to acquire images of corn kernels of multiple varieties, wherein each corn kernel image contains multiple corn kernels; The data annotation module is used to annotate the corn kernel images to obtain a training dataset, wherein the annotation content includes the outline and variety of the corn kernels; The model building module is used to build an improved YOLOv11 model. Specifically, it includes replacing the backbone network with the ConvNeXt V2 network on the basis of the YOLOv11 model, adding an image-level variety classification head, and adopting a dual-task collaborative loss function. The model training module is used to train the improved YOLOv11 model using the training dataset to obtain a variety recognition and contour segmentation model. The model application module is used to acquire images of corn kernels to be detected, and to perform variety identification and contour segmentation on the images of corn kernels to be detected using a variety identification and contour segmentation model.
[0022] Thirdly, a computer-readable storage medium is provided that stores program code for execution by a device, the program code including steps for performing a method as described in any of the implementations of the first aspect above.
[0023] Fourthly, an electronic device is provided, the electronic device including a processor, a memory, and a program or instructions stored in the memory and executable on the processor, wherein the program or instructions, when executed by the processor, implement the method as described in any of the implementations of the first aspect above.
[0024] This application offers the following advantages: It proposes a lightweight network, CN2-YOLO11, based on the YOLOv11 instance segmentation framework. The backbone network is replaced with ConvNeXt V2 to optimize feature extraction efficiency and reduce network weight, thereby lowering model parameters and computational costs. This makes it possible to deploy variety recognition and contour segmentation models in resource-constrained scenarios such as embedded systems. Simultaneously, an image-level variety classification head is added, and a dual-task collaborative loss function is designed to achieve parallel output of image-level variety classification and seed contour segmentation. Subsequently, based on the segmentation results of CN2-YOLO11, morphological and color features of the seeds are extracted, enabling the identification of multiple corn kernels in a single image and simultaneous parallel output of seed contour segmentation, significantly improving recognition and segmentation efficiency. Attached Figure Description
[0025] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments of this application and their descriptions are used to explain this application and do not constitute an undue limitation of this application.
[0026] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0027] Figure 1 This is a flowchart of the deep learning-based maize seed variety identification and contour segmentation method of Embodiment 1 of this application; Figure 2 These are sample images of some maize seeds collected in Example 1 of this application; Figure 3 This is a labeled image of some maize seed samples from Example 1 of this application; Figure 4 This is a structural diagram of the improved YOLOv11 model in Embodiment 1 of this application; Figure 5This is a diagram of the ConvNeXt V2 network structure in Embodiment 1 of this application; Figure 6 This is an image-level variety classification head structure diagram from Embodiment 1 of this application; Figure 7 This is a structural block diagram of the deep learning-based corn seed variety identification and contour segmentation device according to Embodiment 2 of this application; Figure 8 This is a schematic diagram of the internal structure of the electronic device according to Embodiment 4 of this application.
[0028] Figure label: 100. Image acquisition module; 200. Data annotation module; 300. Model building module; 400. Model training module; 500. Model application module. Detailed Implementation
[0029] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention. Example 1
[0030] like Figure 1 As shown in Embodiment 1 of this application, a method for corn seed variety identification and contour segmentation based on deep learning includes: S100. Obtain images of corn kernels of multiple varieties, wherein each corn kernel image contains multiple corn kernels.
[0031] In this embodiment, corn kernels from 20 varieties were selected as experimental samples to construct a small corn kernel variety dataset. The selected varieties are shown in Table 1, and images of some varieties of corn kernels are shown in the figure below. Figure 2 As shown. Images of corn kernels randomly placed on a black flocked cloth were captured using a Daheng HV1351UC camera (25 mm true-color high-definition camera) under natural light conditions in the laboratory. All images had a resolution of 640×640, and each image contained 10-20 corn kernels. For each corn variety, 50 images each of the germ surface, endosperm surface, and the mixed surface of the germ and endosperm were collected, totaling 3000 images. Samples of some corn varieties are shown below. Figure 4 As shown, the differences in color and shape are relatively small.
[0032] Table 1: Selected Varieties
[0033] S200. The corn kernel images are labeled to obtain a training dataset, wherein the labeling content includes the outline and variety of the corn kernels.
[0034] In this embodiment, EIseg software is used to annotate maize kernel sample images. The annotations include the outline of the maize kernels and the variety. Images of some maize varieties are annotated as follows: Figure 3 As shown, corresponding JSON files were generated, and the training, validation, and test sets were randomly divided in a 7:1.5:1.5 ratio. To improve the generalization and robustness of the trained model and prevent overfitting, data augmentation operations such as rotation, brightness adjustment, and noise addition were randomly applied to the labeled files. Since real-world samples are more complex than those in laboratory environments, the augmentation coefficients in the test set were larger, and two or more augmentation methods were randomly superimposed. The final training, validation, and test sets contained 2800, 600, and 600 sample images, respectively.
[0035] S300. Construct an improved YOLOv11 model (i.e., CN2-YOLO11 network structure diagram), specifically including: on the basis of the YOLOv11 model, replacing the backbone network with the ConvNeXt V2 network, adding an image-level variety classification head, and adopting a dual-task collaborative loss function.
[0036] The YOLOv11 model uses CSPDarknet as its backbone network, combined with the neck structure of a weighted feature pyramid to achieve efficient feature extraction and fusion. When extended to instance segmentation tasks, this framework introduces a dynamic masking mechanism in the detection head, which generates pixel-level instance segmentation contours while outputting bounding boxes and category information. The masking mechanism first constructs a basic mask prototype through a prototype layer, and then the prediction mask layer dynamically filters and adjusts it based on the detection box features, thereby achieving joint optimization of detection and segmentation.
[0037] Through experiments, we found that YOLOv11 still has limitations in corn kernel contour segmentation: First, the synergy between feature extraction and mask generation is insufficient. The 3×3 convolutional receptive field of the backbone CSPDarknet is limited, resulting in weak capture of small grains and edge details, leading to blurred boundaries of adhered grains. Dynamic masking relies on detection box localization, which can easily exacerbate mask overflow or loss when there is a deviation. Second, the overall architecture still has redundant computation, and the inference efficiency needs to be improved in resource-constrained scenarios. Third, and most importantly, YOLOv11's image-level classification and instance segmentation require two separate network modules. These two functions cannot be implemented simultaneously in one network and must be processed separately, which increases computational overhead and restricts efficiency in practical applications.
[0038] To address the aforementioned shortcomings, this application proposes a lightweight network, CN2-YOLO11, which can simultaneously perform image-level classification and instance segmentation, based on the YOLOv11s-seg instance segmentation network. The network structure of CN2-YOLO11 is as follows: Figure 4 As shown.
[0039] This network uses the pico version of ConvNeXt V2 with a channel scaling factor of 0.5 as the new backbone. Stages 2, 3, and 4 of the ConvNeXt V2 backbone are aligned with the P3, P4, and P5 feature layers of the YOLOv11s-seg neck input, respectively, and are responsible for the feature representation of small, medium, and large-scale targets. Specifically, the 7×7 depthwise convolution used in Stage 2 effectively expands the receptive field, enhancing the ability to capture details of small corn kernels. While reducing model complexity, it also provides richer semantic information for subsequent image-level classification tasks.
[0040] In the neck region, the original structure is preserved to maintain the multi-scale feature fusion capability, including the SPPF module, C2PSA attention mechanism and cross-level feature splicing, and finally outputs three-level feature maps of P3, P4 and P5 corresponding to target detection information at different scales.
[0041] In the head design, the model adopts a dual-branch output structure: Output 1 is a newly added image-level variety classification head (Classify), which outputs an image-level category probability distribution vector based on the fused high-level semantic features, and outputs the maize variety identification result by selecting the maximum probability; Output 2 uses the original instance segmentation head, outputting the seed bounding box localization information and mask segmentation result. This design achieves rapid image-level classification of maize seed varieties while maintaining instance segmentation accuracy, forming a dual-task collaborative detection mechanism.
[0042] The ConvNeXt V2 backbone network effectively solves the feature collapse problem in traditional convolutional network mask modeling by co-designing a fully convolutional mask autoencoder (FCMAE) and a global response normalization (GRN) layer. The ConvNeXt V2 network architecture is as follows: Figure 5As shown, the ConvNeXt V2 network consists of an input layer, four stages, and an output layer connected sequentially. The input layer first preprocesses the input image, using a convolutional layer (Conv2d) to extract initial features and map channels. A normalization layer (Layer norm) then normalizes the features, and the output features are fed into the first stage (Stage 1). This invention uses the pico version of the ConvNeXt V2 network, which contains four sequentially connected stages (Stage 1-Stage 4). Each stage consists of a downsampling layer and repeatedly stacked ConvNeXt V2 blocks. The downsampling layer comprises a normalization layer (Layer norm) and a convolutional layer (Conv2d), using a convolution with a stride of 2 to halve the feature map size and double the number of channels. The ConvNeXt V2 modules in each stage are stacked 2, 2, 6, and 2 times respectively: Stage 1 is stacked 2 times, Stage 2 is stacked 2 times, Stage 3 is stacked 6 times, and Stage 4 is stacked 2 times. Each module is internally connected to a 7×7 depthwise convolutional layer, a layernorm, a 1×1 pointwise convolutional layer, an activation function (GELU), a global response normalization layer (GRN), another 1×1 pointwise convolutional layer, and a drop path layer. Finally, the module's input is added to the processed output via residual connections to complete the forward pass. The ConvNeXt V2 network can progressively extract and fuse multi-level visual features, achieving semantic abstraction from low to high levels, effectively meeting the need for collaborative extraction of fine-grained features and global semantic information in maize seeds.
[0043] To achieve end-to-end maize variety identification that directly outputs variety categories from input images, and to fully utilize the rich semantic features extracted by the ConvNeXt V2 backbone network, this paper adds an image-level variety classification head to the original instance segmentation task. This module can directly perform image-level variety identification on the input image without relying on pixel-by-pixel detection results, forming a dual-task collaborative parallel mechanism with the original segmentation head.
[0044] The input features of the image-level variety classification head are taken from Figure 4 The C3k2 module at the mid-neck end integrates deep semantic information from Stage 4 of the main trunk and spatial details from the P3-P5 multi-scale feature layers. It possesses both class discriminative power and multi-scale representation capabilities, providing a feature foundation for image-level variety classification. Its structure is as follows: Figure 6As shown in the diagram. The specific processing flow is as follows: A convolutional layer is set before the classification head as a channel adapter. This layer increases the channel dimensionality while maintaining the spatial dimension, enhancing the feature representation capability. It also stabilizes the feature distribution through normalization and non-linear activation, providing richer semantic support for the classification task. The adapted features are then passed through a global average pooling layer, where their spatial dimension is compressed to 1×1, thereby aggregating the global statistical information of each channel and suppressing irrelevant local detail interference. To address the issue of subtle texture differences among similar corn varieties and the tendency for the model to overfit, a random deactivation layer with a deactivation probability of 0.1 is connected after the pooling layer to randomly mask some feature channels. Finally, a fully connected layer linearly maps the processed features to a class probability distribution vector corresponding to the number of classes, completing the variety classification prediction.
[0045] Design of the dual-task collaborative loss function: CN2-YOLO11 uses "instance segmentation loss as the core and image-level classification loss as an auxiliary" to construct a multi-sub-loss weighted fusion system, realizing the collaborative update of the "classification + segmentation" dual tasks, and avoiding the learning of parameters dominated by a single task. In view of the needs of bounding box localization, dense segmentation and multi-variety classification in the corn seed detection scenario, the sub-losses are fused into a total loss through weight allocation to ensure that the performance of each task is complementary and improved. The total loss function is shown in formula (1): (1)
[0046] in, To achieve a complete intersection and comparison loss, For Dice's loss, For binary cross-entropy loss, For the distribution focus loss, For cross-entropy loss, , and In this embodiment, the hyperparameter weights are used as the basis for the calculation. =7.5、 =0.5 and =1.5, determined through validation using a maize grain dataset. The highest weight is used to ensure the core accuracy of segmentation and positioning; The weights are low to avoid excessive use of gradient resources in classification tasks; To balance the refined requirements of bounding box regression, the performance of both tasks is ultimately optimized collaboratively. The sub-loss functions are designed as follows: To address the issue of corn seed bounding box positioning accuracy, the intersection-union ratio (CIoU) loss is used to calculate the positional deviation between the predicted box and the actual box, taking into account the overlap, center point distance, and aspect ratio consistency, as shown in formula (2): (2) (3) (4) in, IoU The intersection-union ratio (IU) of the predicted bounding box and the ground truth bounding box. ρ The Euclidean distance between the two center points. b and b gt These are the center points of the predicted bounding box and the ground truth bounding box, respectively. c It is the diagonal distance of the smallest closure region that simultaneously contains both the predicted bounding box and the ground truth bounding box. α As a balance factor, υ The aspect ratio difference coefficient. w and h These are the width and height of the predicted bounding box, respectively. w gt and h gt These represent the width and height of the true bounding box, respectively; the Complete Intersection over Union (CIoU) loss can quickly converge the bounding box regression error of small seed particles, improving positioning accuracy.
[0047] To address the class imbalance problem in densely populated corn kernel scenarios, Dice loss is used to measure the overlap between the predicted mask and the true mask, as shown in formula (5): (5) in, N The total number of mask pixels, P i and G i The respective i The predicted value and the true value of each pixel. To prevent tiny values with a denominator of 0; Dice loss is sensitive to edge pixel errors and can optimize the segmentation accuracy of seed-grain adhesion regions.
[0048] For the task of fine classification of varieties of single seeds, the binary cross-entropy (BCE) loss is used to optimize the class probability output, as shown in formula (6): (6) in, N Number of varieties y i For real labels, p i To predict category probabilities, the binary cross-entropy (BCE) loss is applicable to multi-variety subcategories, which can accurately optimize the classification error of individual seeds and reduce the impact of local misjudgments on the global task.
[0049] To mitigate the discretization error in bounding box regression, the distribution focus loss (DFL) is used to optimize the centrality of the regression distribution, as shown in formula (7): (7) in, The four regression parameters corresponding to the bounding box ; R For the number of regression channels, The distribution labels corresponding to the actual offsets. To predict the probability distribution, the Distribution Focus Loss (DFL) improves the regression accuracy of small seed bounding boxes by refining the offset distribution.
[0050] The newly added image-level classification task adopts cross-entropy loss (CE), with the log odds output by the image-level classification head (without normalized exponential activation processing) as input and the image-level variety label as the supervision signal to achieve global discrimination of maize seed batches, as shown in formula (8): (8) (9) in, N Number of varieties y i Image-level realistic labels, The predicted probability is the result of activation by the normalized exponential function. z i The corresponding first-order output of the image-level classification head i The log-odds ratio of the class. Cross-entropy loss (CE) relies on image-level global semantic features. Even if some individual classification results have errors, it can still accurately determine the variety category of the entire batch, thus significantly improving the robustness of similar variety classification.
[0051] S400. The improved YOLOv11 model is trained using the training dataset to obtain a variety recognition and contour segmentation model.
[0052] In this embodiment, the improved YOLOv11 model in step S300 is trained using 2800, 600, and 600 sample images from the training set, validation set, and test set, respectively, to obtain the variety recognition and contour segmentation model.
[0053] To comprehensively evaluate the model's performance in maize seed variety identification and instance segmentation tasks, multiple evaluation metrics were used. In the variety identification task, the Top 1 accuracy and Top 5 accuracy in the accuracy (Accuracy, Acc) were selected as evaluation criteria. The formula for calculating the accuracy is shown in (10): (10) In this model, TP represents a true positive instance that is correctly predicted; FP represents a false positive instance that is incorrectly predicted; FN represents a false negative instance that is actually positive but is predicted negative; and TN represents a true negative instance that is correctly predicted negative. Top-1 accuracy is the proportion of the model's highest predicted class for an input sample that matches the true class of the sample; Top-5 accuracy is the proportion of the model's top 5 most probable classes for an input sample that include the true class of the sample. Combining these two metrics allows us to evaluate the model's classification performance; higher values indicate stronger classification ability.
[0054] In seed-grain splitting tasks, precision (P), recall (R), and mean average precision (mAP) are used as evaluation criteria. mAP is the average of the mean precision (AP) across all classes, while mAP50 is the mean precision value at the 50% IoU threshold, and mAP50–95 is the mean precision value within the 50%–95% IoU threshold range. All these are then averaged. The calculation formula is as follows: (11) (12) (13) (14) (15) (16) in, N The average precision is the number of classes; a higher average precision indicates better segmentation performance. In addition, the number of model parameters, computational cost, and weight file size are used as evaluation metrics, corresponding to memory usage, computational requirements, and ease of deployment, respectively, to comprehensively measure the model's lightweight nature and complexity.
[0055] After the corn kernels are segmented, their appearance quality needs to be tested, including the morphological characteristics of each corn variety kernel: average area, perimeter, aspect ratio, and roundness; RGB color space characteristics: red channel intensity, green channel intensity, and blue channel intensity; and HSV color space characteristics: hue, saturation, and brightness. This data can quickly determine whether a batch of seeds meets the standards, providing data support for the breeding of high-quality kernels.
[0056] Instance segmentation performs precise pixel-level segmentation on each corn seed in the image, obtaining a mask for each seed. Based on the segmented masks, the morphological and colorimetric features of each seed are extracted from the image. The extracted feature data is then compared and evaluated using data within a normal feature range provided by the seed company.
[0057] 1) Fullness assessment indicators: Area: The total number of pixels in the mask of a single corn kernel.
[0058] Aspect ratio: minor axis length / major axis length.
[0059] Convexity: (Convex hull area) / (Mask area). The convex hull is the smallest convex polygon that contains the entire contour.
[0060] 2) Regularity assessment indicators: Aspect ratio: minor axis length / major axis length.
[0061] Contour smoothness (S): Evaluated by the "curvature change" of the mask contour, the standard deviation of curvature of all pixels on the contour is calculated (the smaller the curvature and the smaller the standard deviation, the smoother the contour), and then normalized to a smoothness score of 0-100 (the smaller the standard deviation, the closer S is to 100).
[0062] 3) Maturity assessment index: Calculate the mean and standard deviation of all pixels in the H, S, and V channels within the mask area.
[0063] H (hue) mean: directly reflects the dominant color. Yellow tones usually represent maturity, greenish tones represent immaturity, and brown / black tones may represent mold or overripeness.
[0064] S (Saturation) mean: the vividness of color. Full-bodied, mature seeds usually have higher saturation.
[0065] Values and Standard Deviation (V): The value of lightness reflects the overall brightness, while the standard deviation reflects the consistency of color. Mold or blemishes can cause a decrease in lightness and an increase in the standard deviation.
[0066] S500: Acquire the image of the corn kernels to be detected, and use the variety recognition and contour segmentation model to perform variety recognition and contour segmentation on the image of the corn kernels to be detected.
[0067] In this embodiment, the image of the corn kernels to be identified is input into the variety identification and contour segmentation model, which can simultaneously perform variety identification and contour segmentation on multiple corn kernels in the input image. This application proposes a lightweight network CN2-YOLO11. First, based on the YOLOv11 instance segmentation framework, the backbone network is replaced with ConvNeXt V2 to optimize feature extraction efficiency and network lightweighting. At the same time, an image-level variety classification head is added and a dual-task collaborative loss function is designed to achieve parallel output of image-level variety classification and kernel contour segmentation. Subsequently, based on the segmentation results of CN2-YOLO11, the morphological and color features of the kernels are extracted to construct a corn kernel appearance quality detection model, realizing the quantitative evaluation of kernel fullness, regularity, and maturity, and improving the whole-process detection system of identification-segmentation-quality evaluation.
[0068] Example 2 like Figure 7 As shown in Embodiment 2 of this application, a corn seed variety identification and contour segmentation device based on deep learning includes: The image acquisition module 100 is used to acquire images of corn kernels of multiple varieties, wherein each corn kernel image contains multiple corn kernels. The data annotation module 200 is used to annotate the corn kernel images to obtain a training dataset, wherein the annotation content includes the outline and variety of the corn kernels; The model building module 300 is used to build an improved YOLOv11 model, specifically including: replacing the backbone network with the ConvNeXt V2 network on the basis of the YOLOv11 model, adding an image-level variety classification head, and adopting a dual-task collaborative loss function for the loss function; The model training module 400 is used to train the improved YOLOv11 model using the training dataset to obtain a variety recognition and contour segmentation model. The model application module 500 is used to acquire images of corn kernels to be detected and to perform variety identification and contour segmentation on the images of corn kernels to be detected using a variety identification and contour segmentation model.
[0069] It should be noted that other specific implementations of the deep learning-based corn seed variety identification and contour segmentation device in this embodiment can be found in the specific implementations of the deep learning-based corn seed variety identification and contour segmentation method described above. To avoid redundancy, they will not be repeated here.
[0070] Example 3 This application relates to a computer-readable storage medium in Embodiment 3, which is used for program code executed by a device, the program code including steps for performing a method as described in any implementation of Embodiment 1 of this application; The computer-readable storage medium may be a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM); the computer-readable storage medium may store program code, and when the program stored in the computer-readable storage medium is executed by a processor, the processor is used to perform the steps of the method in any of the implementations of Embodiment 1 of this application.
[0071] Example 4 like Figure 8 As shown, an electronic device according to Embodiment 4 of this application includes a processor, a memory, and a program or instructions stored in the memory and executable on the processor. When the program or instructions are executed by the processor, they implement the method in any of the implementations in Embodiment 1 of this application. The processor can be a general-purpose central processing unit (CPU), microprocessor, application-specific integrated circuit (ASIC), graphics processing unit (GPU), or one or more integrated circuits, used to execute related programs to implement the method in any of the implementations of Embodiment 1 of this application.
[0072] The processor can also be an integrated circuit electronic device with signal processing capabilities. In implementation, each step of the method in any of the implementations of Embodiment 1 of this application can be completed by the integrated logic circuitry in the processor's hardware or by software instructions.
[0073] The aforementioned processor can also be a general-purpose processor, digital signal processor, application-specific integrated circuit (ASIC), field-programmable gate array (FPGA), or other programmable logic device, discrete gate or transistor logic device, or discrete hardware component. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly embodied in the execution of a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software modules can be located in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. The storage medium is located in memory; the processor reads information from the memory and, in conjunction with its hardware, completes the functions required by the units included in the data processing apparatus of the embodiments of this application, or executes the methods in any implementation of Embodiment 1 of this application.
[0074] The above are merely preferred embodiments of this application; however, the scope of protection of this application is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in this application, based on the technical solution and its improved concept, should be covered within the scope of protection of this application.
Claims
1. A method for corn seed variety identification and contour segmentation based on deep learning, characterized in that, include: Acquire images of corn kernels from multiple varieties, where each corn kernel image contains multiple corn kernels; The corn kernel images are labeled to obtain a training dataset, wherein the labeling content includes the outline of the corn kernels and the variety; An improved YOLOv11 model was constructed, specifically including: replacing the backbone network with the ConvNeXt V2 network on the basis of the YOLOv11 model, adding an image-level variety classification head, and adopting a dual-task collaborative loss function. The improved YOLOv11 model was trained using the training dataset to obtain a variety recognition and contour segmentation model. Acquire images of corn kernels to be detected, and use variety recognition and contour segmentation models to perform variety recognition and contour segmentation on the images of corn kernels to be detected.
2. The method for corn seed variety identification and contour segmentation based on deep learning according to claim 1, characterized in that, Also includes: Data augmentation was performed on labeled maize kernel images by random rotation, brightness adjustment, and noise addition.
3. The method for corn seed variety identification and contour segmentation based on deep learning according to claim 1, characterized in that, The original structure of the neck network in the improved YOLOv11 model is retained to maintain the multi-scale feature fusion capability, including the SPPF module, C2PSA attention mechanism and cross-level feature concatenation, and finally outputs three-level feature maps of P3, P4 and P5 corresponding to target detection information at different scales.
4. The method for corn seed variety identification and contour segmentation based on deep learning according to claim 3, characterized in that, The ConvNeXt V2 network includes an input layer, a feature extraction layer, and an output layer. The input layer includes a convolutional layer and a normalization layer connected in sequence. The feature extraction layer includes a first stage, a second stage, a third stage, and a fourth stage, which are connected in sequence. Each stage consists of a downsampling layer and repeatedly stacked ConvNeXt V2 modules. The downsampling layer consists of a normalization layer and a convolutional layer, achieving a halving of the feature map size and a doubling of the number of channels through a convolution with a stride of 2. The ConvNeXt V2 modules in the first, second, third, and fourth stages are repeated 2, 2, 6, and 2 times, respectively. Each ConvNeXt... The V2 module is internally connected to a 7×7 deep convolutional layer, a normalization layer, a 1×1 convolutional layer, an activation function, a global response normalization layer, a 1×1 convolutional layer, and a random dropout layer. The second, third, and fourth stages are aligned with the P3, P4, and P5 feature layers of the neck network input, respectively, and are responsible for the feature representation of small, medium, and large targets.
5. The method for corn seed variety identification and contour segmentation based on deep learning according to claim 1, characterized in that, The improved YOLOv11 model adopts a dual-branch output in the head network. The first output is a newly added image-level variety classification head, which is used to output the image-level category probability distribution vector based on the fused high-level semantic features, and outputs the maize variety identification result by selecting the maximum probability. The second output is the original instance segmentation head, which is used to output the seed bounding box localization information and mask segmentation result.
6. The method for maize seed variety identification and contour segmentation based on deep learning according to any one of claims 1-5, characterized in that, The loss function of the improved YOLOv11 model The calculation formula is: ; in, To achieve a complete intersection and comparison loss, For Dice's loss, For binary cross-entropy loss, For the distribution focus loss, For cross-entropy loss, , and For hyperparameter weights.
7. The method for corn seed variety identification and contour segmentation based on deep learning according to claim 6, characterized in that, The formula for calculating the perfect crossover ratio loss is: ; ; ; Where IoU is the intersection-union ratio of the predicted bounding box and the ground truth bounding box, ρ is the Euclidean distance between the two center points, and b and b gt Let be the center points of the predicted bounding box and the ground truth bounding box, respectively; c be the diagonal distance of the smallest closure region containing both the predicted and ground truth bounding boxes; α be the balance factor; υ be the aspect ratio difference coefficient; and w and h be the width and height of the predicted bounding box, respectively. gt and h gt These are the width and height of the actual bounding box, respectively; The formula for calculating the Dice loss is as follows: ; Where N is the total number of mask pixels, P i and G i Let the predicted value and the true value of the i-th pixel be compared separately. To prevent tiny values with a denominator of 0; The formula for calculating the binary cross-entropy loss is as follows: ; Where N is the number of variety categories, y i For real labels, p i To predict class probabilities; The formula for calculating the distribution focus loss is as follows: ; Where i corresponds to the four regression parameters x, y, w, and h of the bounding box, R is the number of regression channels, and q i,j p represents the distribution label corresponding to the actual offset. i,j To predict the probability distribution; The formula for calculating the cross-entropy loss is as follows: ; ; Where N is the number of variety categories, y i Image-level realistic labels z is the predicted probability after activation by the normalized exponential function. i This is the log-odds value for the i-th class output by the image-level classification head.
8. A device for corn seed variety identification and contour segmentation based on deep learning, characterized in that, include: The image acquisition module is used to acquire images of corn kernels of multiple varieties, wherein each corn kernel image contains multiple corn kernels; The data annotation module is used to annotate the corn kernel images to obtain a training dataset, wherein the annotation content includes the outline and variety of the corn kernels; The model building module is used to build an improved YOLOv11 model. Specifically, it includes replacing the backbone network with the ConvNeXt V2 network on the basis of the YOLOv11 model, adding an image-level variety classification head, and adopting a dual-task collaborative loss function. The model training module is used to train the improved YOLOv11 model using the training dataset to obtain a variety recognition and contour segmentation model. The model application module is used to acquire images of corn kernels to be detected, and to perform variety identification and contour segmentation on the images of corn kernels to be detected using a variety identification and contour segmentation model.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores program code for execution by the device, the program code including steps for performing the method as described in any one of claims 1-7.
10. An electronic device, characterized in that, The electronic device includes a processor, a memory, and a program or instructions stored in the memory and executable on the processor, wherein the program or instructions, when executed by the processor, implement the method as described in any one of claims 1-7.