A method, system and electronic device for classifying corn seed varieties

By combining a sparse band attention strategy with a convolutional neural network, representative bands of maize seed varieties are selected, solving the problem of hyperspectral data redundancy and achieving more efficient seed variety identification.

CN116843981BActive Publication Date: 2026-05-15CHINA AGRI UNIV
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CHINA AGRI UNIV
Filing Date
2023-07-19
Publication Date
2026-05-15

AI Technical Summary

Technical Problem

Existing hyperspectral data for maize seed variety identification is high in dimensionality and contains a lot of redundant information, resulting in insufficient real-time performance and accuracy. Traditional methods have failed to effectively consider the nonlinearity and global interaction between spectral bands.

Method used

A sparse band attention strategy is adopted, which generates weights for full-band spectral data through a band attention module and applies sparse constraints. This is combined with a convolutional neural network for seed variety classification, and a representative subset of bands is selected.

Benefits of technology

It significantly improves the real-time performance and accuracy of maize seed variety identification, reduces redundant information, and enhances classification performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116843981B_ABST
    Figure CN116843981B_ABST
Patent Text Reader

Abstract

The application discloses a corn seed variety classification method and system and electronic equipment, and relates to the field of hyperspectral data dimension reduction technology. After the obtained spectral image is preprocessed to obtain a single seed image, full-band spectral data of the single seed is extracted. Then, the full-band spectral data is input into a band attention module to generate the weight of each band in the full-band spectral data. Then, a sparse band attention strategy is introduced to perform sparse constraint on the weight of each band to obtain sparse band weight. Finally, the full-band spectral data and the sparse band weight are weighted to obtain weighted spectral, which is input into a convolutional neural network to obtain a corn seed variety classification result, so that better classification performance is obtained, and the real-time performance and accuracy of seed variety identification are significantly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of hyperspectral data dimensionality reduction technology, and in particular to a method, system, and electronic device for classifying maize seed varieties. Background Technology

[0002] Seeds are the most important production material in agriculture. Corn, along with rice and wheat, is known as one of the world's three major grains and is a primary food crop. Different varieties of corn seeds have different nutritional values ​​and uses. Variety identification is crucial for selecting corn seeds for different purposes, such as food, feed, and breeding.

[0003] Traditional seed variety identification methods are highly destructive, time-consuming, labor-intensive, and costly, making them difficult to widely implement. In recent years, non-destructive seed variety identification methods, represented by machine vision, near-infrared spectroscopy, and hyperspectral imaging, have received extensive research. However, both machine vision and near-infrared spectroscopy can only acquire seed information in isolation, which is insufficient for complex application scenarios. Hyperspectral imaging integrates the advantages of machine vision and spectral techniques, becoming a more powerful non-destructive testing technology. It can simultaneously acquire both image and spectral information of the seed, resulting in a stronger ability to identify varieties.

[0004] However, hyperspectral data is not only high-dimensional but also contains a large amount of redundant information, which is very unfriendly to real-time online applications. Selecting a few representative bands from the entire working spectral region can significantly reduce the equipment cost and computational load of hyperspectral imaging. In the analysis of hyperspectral data of food and agricultural products, chemometric band selection methods, such as Successive Projections Algorithm (SPA), Competitive Adaptive Reweighting Algorithm (CARS), Random Frog (RF), Monte Carlo Uninformative Variable Elimination (MCUVE), and Principal Component Analysis-loading (PCA-loading), have long been dominant. However, most of these methods cannot fully consider the nonlinear and global interactions between spectral bands, which may lead to the selection of some adjacent bands while still retaining a lot of redundant information. Therefore, how to improve the real-time performance and accuracy of seed variety identification has become a technical problem that urgently needs to be solved in this field. Summary of the Invention

[0005] To address the aforementioned problems in the existing technology, this invention provides a method, system, and electronic device for classifying maize seed varieties.

[0006] To achieve the above objectives, the present invention provides the following solution:

[0007] A method for classifying corn seed varieties, comprising:

[0008] Obtain spectral images of different varieties of maize seeds;

[0009] The spectral image is preprocessed to obtain a single seed image;

[0010] Extract full-band spectral data of a single seed based on the single seed image;

[0011] The full-band spectral data is input into the band attention module to generate the weight of each band in the full-band spectral data;

[0012] Sparse band weights are obtained by applying sparsity constraints to the weights of each band.

[0013] The full-band spectral data and the sparse band weights are weighted to obtain the weighted spectrum;

[0014] The weighted spectrum is input into a convolutional neural network to obtain the classification results of maize seed varieties.

[0015] Optionally, the spectral image is preprocessed to obtain a single seed image, specifically including:

[0016] The spectral image is subjected to black-and-white correction and threshold segmentation to remove the background from the spectral image, and the spectral image is segmented to obtain the single seed image.

[0017] Optionally, extracting full-band spectral data of a single seed based on the single seed image specifically includes:

[0018] The entire region of a single corn kernel in the single seed image is taken as the region of interest;

[0019] The average value of the pixel spectrum used in the region of interest is determined to obtain the average spectral data; the average spectral data is used as the full-band spectral data of a single seed.

[0020] Optionally, the band attention module includes two fully connected neural networks; the first fully connected neural network is followed by the ELU activation function, and the second fully connected neural network is followed by the sigmoid activation function.

[0021] Optionally, sparse constraints are applied to the weights of each band to obtain sparse band weights, specifically including:

[0022] Arrange the weights of all bands in descending order to obtain the weight sequence;

[0023] The k-th weight value in the weight sequence is set as a threshold, and the bands with weights less than the threshold are assigned a value of 0 to obtain the sparse band weights.

[0024] Optionally, the formula for weighted processing is:

[0025]

[0026] In the formula, X i Let x represent the weighted spectrum of the spectral data of the i-th seed sample. i This represents the spectral data of the i-th seed sample. Indicates the sparse band weights. This represents element-wise multiplication.

[0027] Optionally, before inputting the weighted spectrum into the convolutional neural network to obtain the maize seed variety classification result, the method further includes:

[0028] By using an end-to-end training method, representative bands corresponding to each corn seed variety are selected to obtain a band subset.

[0029] According to specific embodiments provided by the present invention, the present invention discloses the following technical effects:

[0030] The corn seed variety classification method provided by this invention introduces a sparse band attention strategy. Compared with traditional methods, the bands selected by the method of this invention contain less redundant information, which can achieve better classification performance and significantly improve the real-time performance and accuracy of seed variety identification.

[0031] The present invention also provides the following embodiments:

[0032] A corn seed variety classification system, applied to the corn seed variety classification method provided above; the system includes:

[0033] The spectral image acquisition module is used to acquire spectral images of different varieties of corn seeds;

[0034] The preprocessing module is used to preprocess the spectral image to obtain a single seed image;

[0035] The spectral data extraction module is used to extract full-band spectral data of a single seed based on the single seed image;

[0036] The band weight determination module is used to input the full-band spectral data into the band attention module to generate the weight of each band in the full-band spectral data;

[0037] The weight sparsity constraint module is used to apply sparsity constraints to the weights of each band to obtain sparse band weights.

[0038] The spectral weighting processing module is used to perform weighted processing on the full-band spectral data and the sparse band weights to obtain the weighted spectrum;

[0039] The seed variety classification module is used to input the weighted spectrum into a convolutional neural network to obtain the corn seed variety classification results.

[0040] An electronic device includes: at least one processor, at least one memory, and a computer program stored in the memory;

[0041] When the computer program is executed by the processor, it implements the corn seed variety classification method provided above.

[0042] Optionally, the memory is a computer-readable storage medium.

[0043] Since the technical effects achieved by the two implementation structures provided by the present invention are the same as those achieved by the corn seed variety classification method provided by the present invention, they will not be described again here. Attached Figure Description

[0044] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0045] Figure 1 A flowchart of the corn seed variety classification method provided by the present invention;

[0046] Figure 2 This is a schematic diagram of the hyperspectral imaging system provided by the present invention;

[0047] Figure 3 The band attention module architecture diagram provided by this invention;

[0048] Figure 4 A comparison chart of Kappa coefficients for various methods under different band subset sizes provided by this invention;

[0049] Figure 5 A comparison chart showing the overall accuracy of various methods under different band subset sizes provided by this invention;

[0050] Figure 6This is a schematic diagram illustrating the location distribution and entropy values ​​of the bands selected by different band selection methods provided by the present invention; wherein, Figure 6 Part (a) is a schematic diagram showing the location distribution of bands selected by different band selection methods. Figure 6 Part (b) is a schematic diagram showing the entropy values ​​of the bands selected by different band selection methods;

[0051] Figure 7 A schematic diagram showing the sum of the entropy values ​​of the bands selected by the different band selection methods provided by this invention. Detailed Implementation

[0052] 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.

[0053] The purpose of this invention is to provide a method, system, and electronic device for classifying maize seed varieties, which can improve the real-time performance and accuracy of seed variety identification.

[0054] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0055] like Figure 1 As shown, the corn seed variety classification method provided by the present invention includes:

[0056] Step 100: Obtain spectral images of different varieties of maize seeds. In this invention, this step involves acquiring hyperspectral images of maize seeds.

[0057] Step 101: Preprocess the spectral image to obtain a single seed image. Specifically, this preprocessing step can use methods such as black-and-white correction or thresholding to remove the background and segment the image into single seeds.

[0058] Step 102: Extract full-band spectral data of a single seed based on the single seed image. Specifically:

[0059] The entire region of a single corn kernel in a single seed image is designated as the Region of Interest (ROI).

[0060] The average value of the pixel spectra used within the ROI is determined to obtain the average spectral data. This average spectral data is then used as the full-band spectral data for a single seed to better represent it.

[0061] Step 103: Input the full-band spectral data into the band attention module to generate the weights for each band in the full-band spectral data. The band attention module consists of two fully connected neural networks. The first layer uses the ELU activation function, and the second layer uses the sigmoid activation function.

[0062] Step 104: Apply sparsity constraints to the weights of each band to obtain sparse band weights. The purpose of this step is to maximize the removal of redundant information. In practical applications, this step can be implemented as follows:

[0063] Sort all band weights in descending order.

[0064] Set the kth weight value as a threshold. Once the weight of a certain band is less than the threshold, it will be assigned a value of 0.

[0065] Step 105: Weight the full-band spectral data and the sparse band weights to obtain the weighted spectrum. Specifically, the full-band spectral data and the sparse band weights are multiplied element-wise using the following formula:

[0066]

[0067] In the formula, X i Let x represent the weighted spectrum of the spectral data in the i-th band. i This represents the spectral data for the i-th band. Indicates the sparse band weights. This represents element-wise multiplication.

[0068] Step 106: Input the weighted spectrum into the convolutional neural network to obtain the corn seed variety classification results. That is, the weighted spectrum is input into the convolutional neural network for seed classification.

[0069] Furthermore, before proceeding to step 106, the present invention also selects representative bands corresponding to each corn seed variety through an end-to-end training method to obtain a band subset.

[0070] Based on this, the corn seed variety classification method provided by this invention introduces a sparse band attention strategy, which selects an effective band subset through end-to-end training. Compared with traditional methods, the band subset selected by this invention contains less redundant information and can achieve better classification performance, providing a solid theoretical foundation for further development of online detection systems.

[0071] The following example illustrates the specific implementation process of the corn seed variety classification method provided by the present invention.

[0072] This embodiment collected 20 high-quality maize varieties widely grown in China, each containing 500 seeds, for a total of 10,000 seeds. All seeds were produced in Shandong Province, China, and were harvested in 2021. After natural drying, damaged seeds were rigorously selected by hand to remove any broken kernels, ensuring that each seed was intact. Finally, they were stored in sterile kraft paper bags. Hyperspectral images of all seeds were acquired using a pushbroom hyperspectral imaging system. Figure 2 As shown, the core components of this system mainly include a hyperspectral imager 1 (hyperspectral camera), a computer 2, a conveyor belt 3, a tungsten bromide lamp light source 4, a USB data transmission cable 5, and a motor 6. The connection and positional relationships between these components can be found in [reference needed]. Figure 2 The spectrometer camera is model ImSpectorV10E, with a spectral range of 382.2-1026.7nm, a spectral resolution of 3.2nm, a spatial resolution of 1024*1024 pixels, and a total of 728 bands.

[0073] In this embodiment, the training set and the test set are divided in an 8:2 ratio. That is, each variety in the training set contains 400 seeds, for a total of 8,000 seeds, while each variety in the test set contains 100 seeds, for a total of 2,000 seeds.

[0074] To remove the influence of dark current in the system on the image and to convert the spectral image of the digital intensity values ​​collected by the sensor into reflectance values ​​(i.e., 0 to 1), black and white correction is required for the image. The correction formula is as follows:

[0075]

[0076] In the formula, I c I represents the corrected image. o Represents the original hyperspectral image, I b Indicates a completely black calibration image, I w This indicates a fully white calibration image.

[0077] To remove background interference and segment each corn seed from the entire image, a specific band was selected from the full spectral density spectrum. This band exhibits the greatest difference in spectral reflectance between the seeds and the background in the grayscale image and was ultimately used to construct a mask. In this example, this band is 729.1 nm. After a series of tests, a threshold of 0.3 was set; pixels with a reflectance less than 0.3 were considered background and represented as 0, while those with a reflectance greater than 0.3 were represented as 1. Finally, the mask was used to remove the background and segment individual seeds.

[0078] Furthermore, the entire region of a single seed is defined as the Region of Interest (ROI), and the average value of the pixel spectra used within the ROI is calculated as the average spectrum of a single corn seed to better represent a single corn seed.

[0079] Due to limitations inherent in optical instruments, the noise at the beginning and end of the original spectral curve was relatively high, and ultimately only 678 bands with high signal-to-noise ratios in the range of 400.8-1000.7nm were retained.

[0080] Furthermore, HSI obtains a large number of spectral bands through dense sampling from the visible to the infrared region. This imaging mechanism results in many bands being redundant; specifically, adjacent bands are highly correlated, and even distant bands may exhibit correlation. Since the presence of redundant bands weakens the accuracy of seed variety identification, it is necessary to select some of the most discriminative or information-rich bands from the entire spectrum to address this issue. Attention mechanisms can cleverly allocate available processing resources biased towards the most informative parts of the input signal. This embodiment utilizes a band attention module to generate weights for all bands, automatically assigning larger weight values ​​to useful bands, thereby suppressing the negative impact of redundant bands. Figure 3 As shown, the band attention module consists of two fully connected layers (first layer neurons: 678-512; second layer neurons: 512-678). Let x i ∈R 1*1*L Let w represent the average spectrum of the i-th seed with L bands, then the generated band weights w i ∈R 1*1*L The formula is:

[0081] w i =σ(f(x) i (2)

[0082] In the formula, f(·) represents the band attention module, and δ represents the sigmoid function, which is used to map the generated band weight values ​​to 0 to 1.

[0083] Furthermore, the band weights generated by the band attention module can be seen as an evaluation of each corresponding spectral band; that is, the smaller the weight, the more likely the corresponding band is to be a redundant band. Theoretically, after sigmoid function mapping, the useful band weight value is close to 1, and the redundant band weight value is close to 0. However, this embodiment aims to further reduce the weight values ​​of bands with weight values ​​close to 0 to zero, in order to maximize the removal of interference from redundant information. Therefore, a sparse constraint rule is proposed to achieve the above objective, namely, the band weights w are determined according to the following rules. i Sparse constraints are applied to form new sparse band weights. for:

[0084]

[0085] In the formula, g(·) represents the sparsity constraint function, j represents the number of bands, and w ijLet represent the weight corresponding to the j-th band of the i-th seed, and k represent the threshold. That is, all band weights are sorted in descending order, and the m-th weight is set to k. Once w... ij If the value is greater than the threshold, it remains unchanged; otherwise, it is assigned a value of 0. Finally, according to the formula... Reweight the input spectrum:

[0086] Furthermore, such as Figure 3 As shown, the original spectrum is weighted with sparse band weights and then input into the band attention module. This module consists of a three-layer one-dimensional convolutional neural network (3×1 kernel, stride 1, padding 1). Each convolutional layer is followed by a batch normalization layer, an ELU activation function, and a max pooling layer (kernel size 2, stride 2). Band selection, feature extraction, and seed variety classification are achieved through end-to-end training. However, the sparsity constraint presents an optimization challenge: some bands with zero weights have gradients of 0 during backpropagation and become unupdable, making it difficult for the network to learn the most representative bands for identifying seed varieties. This can be explained in detail by the following formula:

[0087]

[0088] In the formula, for bands with zero weight, the derivative of the sparse constraint function g(·) is always zero, which limits the model from gradually searching for useful bands across all spectral bands. A limitation of this optimization problem is the lack of full-band updates; therefore, the participation of the entire band is needed to assist in the update process. Thus, this embodiment proposes a loss optimization method to address the problem of updating the entire network parameters.

[0089]

[0090] In the formula, Loss represents the total loss function, the first term represents the cross-entropy loss function, n is the number of training samples in the batch, and m is the number of classes. It is a sign function; it is 1 if the true class of sample i is equal to c, and 0 otherwise. The first term represents the predicted probability that observed sample i belongs to category c. The second term is the full-band weighted auxiliary loss function, where L represents the number of bands, and w... ij λ represents the non-sparse constraint weight of the j-th band of the i-th sample. λ is the adjustment parameter.

[0091] In the early stages of training, the gradual updating of sparse weights requires more full-band assistance. As training stabilizes in the later stages, less full-band assistance is needed. Therefore, the adjustment parameter λ should gradually decrease as training progresses. In this embodiment, λ = β * exp(-t1 / t2) is used as the adjustment parameter, where t1 and t2 represent the current training epochs and the total number of epochs, respectively. β is also a balancing parameter, set to 10. -4 .

[0092] This embodiment selects six band selection methods for comparison with our method, including six well-known chemometric methods in the field of food and agricultural product quality monitoring: CARS, SPA, RF, MCUVE, PCA-loading, and a band selection method based on band attention (BS-Net).

[0093] To better evaluate the performance of different algorithms in selecting feature wavelengths, a support vector machine with a kernel function and a radial basis function (RBF) was selected as the classifier. A grid search optimization procedure was used to select the parameters of the RBF-SVM, searching for c in the range {1, 10, 100, 1000, 10000} and gamma in the range {0.01, 0.1, 1, 10, 100}. Overall accuracy (OA) and the Kappa coefficient were selected as evaluation metrics. For fairness, the program for each band selection method was run 10 times independently.

[0094] The CARS, RF, and MCUVE algorithms all set the number of sampling attempts and the maximum number of latent variables for cross-validation to 1000 and 10, respectively. SPA and PCA-loading have no specific parameter settings. For the method in this embodiment and BS-Net, their parameters are set consistently: batch size, learning rate, and number of iterations are all kept consistent at 128, 0.001, and 500, respectively. Both use the Adam optimizer with an initial learning rate of 0.001, beta_1 = 0.9, and beta_2 = 0.999 to minimize the loss.

[0095] Figure 4 and Figure 5The average results of Kappa and OA, obtained by running these algorithms 10 times independently, are shown. These metrics were statistically analyzed with band subset sizes ranging from 10 to 100, at intervals of 10. Overall, the method provided by this invention is significantly superior to the other six methods compared. Among them, CARS and MCUVE performed the worst, while the performance of the other four methods was relatively close. Furthermore, an interesting phenomenon was observed: except for the CARS algorithm, all algorithms initially showed improved performance with increasing band count. However, after reaching a certain performance limit, performance declined with further increases in the number of bands. This phenomenon is known as the Hughes phenomenon in hyperspectral band selection, where classification performance initially improves and then decreases with increasing selected bands. For example, the method provided by this invention achieves the best classification performance with 50 bands. CARS did not exhibit this phenomenon, possibly because the first 100 bands do not fully represent the optimal performance of the method, thus requiring more bands. Compared to the full-band method, the performance of the method provided by this invention is significantly better than that of the full-band method, while the performance of other comparative methods is either slightly better or worse than that of the full-band method. Furthermore, when the number of bands selected is 20, the performance of the method provided by this invention is better than that of the full-band method, and it remains significantly better than the full-band method as the number of bands increases thereafter.

[0096] To more clearly display the experimental results, statistical analysis was performed on the 20 best bands selected by each band selection method. The selection of bands was mainly evaluated based on their location and Shannon entropy value. The distribution of the selected bands is as follows: Figure 6 As shown in section (a), each row represents a band method and the corresponding position of the selected bands. It can be seen that MCUVE and CARS select very dense bands with high correlation between adjacent bands, resulting in significant information redundancy. Compared to MCUVE and CARS, RF, SPA, PCA-loading, BS-Net, and the method provided in this invention select a wider and more dispersed range of bands. Overall, the four methods RF, SPA, PCA-loading, and BS-Net select more adjacent bands than the method provided in this invention. The method provided in this invention selects fewer adjacent bands, and their distribution is relatively uniform.

[0097] Further analysis from the perspective of Shannon entropy, such as Figure 6As shown in section (b), entropy reflects the amount of information; therefore, a spectral band with a higher entropy value indicates that it contains more information. It can be seen that the bands selected by CARS all fall within the low-entropy region, thus its classification performance is the worst. SPA and BS-Net also select a significant number of bands within the low-entropy region. In contrast, RF, MCUVE, PCA-loading, and the method provided in this invention select fewer low-entropy bands. To more thoroughly compare the entropy differences in band selection by different band selection methods, Figure 7 The sum of entropy values ​​for different numbers of bands is given. Clearly, except for CARS which has the lowest total entropy, the total entropy values ​​for all methods are very similar. However, from... Figure 7 The magnified sub-image shows that the total entropy value of the band selected by the method provided by this invention is higher than that of other methods.

[0098] Furthermore, the present invention also provides the following implementation structure:

[0099] A corn seed variety classification system, applied to the corn seed variety classification method provided above. The system includes:

[0100] The spectral image acquisition module is used to acquire spectral images of different varieties of corn seeds.

[0101] The preprocessing module is used to preprocess the spectral image to obtain a single seed image.

[0102] The spectral data extraction module is used to extract full-band spectral data of a single seed based on a single seed image.

[0103] The band weight determination module is used to input full-band spectral data into the band attention module to generate the weight of each band in the full-band spectral data.

[0104] The weight sparsity constraint module is used to apply sparsity constraints to the weights of each band to obtain sparse band weights.

[0105] The spectral weighting processing module is used to perform weighted processing on the full-band spectral data and the sparse band weights to obtain the weighted spectrum.

[0106] The seed variety classification module is used to input the weighted spectrum into a convolutional neural network to obtain the corn seed variety classification results.

[0107] An electronic device includes: at least one processor, at least one memory, and a computer program stored in the memory.

[0108] The above-described method for classifying corn seed varieties is implemented when the computer program is executed by the processor.

[0109] Furthermore, when the computer program in the aforementioned memory is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory, random access memory, magnetic disks, or optical disks.

[0110] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the systems disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple; relevant parts can be referred to the method section.

[0111] This document uses specific examples to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. Furthermore, those skilled in the art will recognize that, based on the ideas of the present invention, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of the present invention.

Claims

1. A method for classifying maize seed varieties, characterized in that, include: Obtain spectral images of different varieties of maize seeds; The spectral image is preprocessed to obtain a single seed image; Extract full-band spectral data of a single seed based on the single seed image; The full-band spectral data is input into the band attention module to generate the weight of each band in the full-band spectral data; the band attention module includes two fully connected neural networks; the first fully connected neural network is followed by the ELU activation function, and the second fully connected neural network is followed by the sigmoid activation function; Sparse band weights are obtained by applying sparsity constraints to the weights of each band. The full-band spectral data and the sparse band weights are weighted to obtain the weighted spectrum; The weighted spectrum is input into a convolutional neural network to obtain the classification results of maize seed varieties. A loss optimization method is used to solve the problem of updating the parameters of the entire network. ; In the formula, Loss This represents the total loss function, and the first term represents the cross-entropy loss function. n For the number of training samples in a batch, m For the number of categories, It is a sign function, if the sample i The true category equals c It is 1 if it is positive and 0 otherwise. For observation samples i Category c The first term is the predicted probability; the second term is the full-band weighted auxiliary loss function. L Indicates the number of bands. Indicates the first i The first sample j Non-sparse constraint weights for each band; Will λ=β exp(-t 1 / t 2 ) To adjust the parameters, t 1 and t 2 These represent the current training epoch and the total number of epochs, respectively. β It is a balance parameter.

2. The method for classifying maize seed varieties according to claim 1, characterized in that, Preprocessing the spectral image to obtain a single seed image specifically includes: The spectral image is subjected to black-and-white correction and threshold segmentation to remove the background from the spectral image, and the spectral image is segmented to obtain the single seed image.

3. The method for classifying maize seed varieties according to claim 1, characterized in that, Extracting full-band spectral data of a single seed based on the single seed image, specifically including: The entire region of a single corn kernel in the single seed image is taken as the region of interest; The average value of the pixel spectrum used in the region of interest is determined to obtain the average spectral data; the average spectral data is used as the full-band spectral data of a single seed.

4. The method for classifying maize seed varieties according to claim 1, characterized in that, The sparse band weights are obtained by applying sparsity constraints to the weights of each band, specifically including: Arrange the weights of all bands in descending order to obtain the weight sequence; The k-th weight value in the weight sequence is set as a threshold, and the bands with weights less than the threshold are assigned a value of 0 to obtain the sparse band weights.

5. The method for classifying maize seed varieties according to claim 1, characterized in that, The formula for weighted processing is: ; In the formula, Indicates the first i The weighted spectrum of the spectral data of each seed sample. Indicates the first i Spectral data of one seed sample, Indicates the sparse band weights. This represents element-wise multiplication.

6. The method for classifying maize seed varieties according to claim 1, characterized in that, Before inputting the weighted spectrum into the convolutional neural network to obtain the maize seed variety classification results, the method further includes: By using an end-to-end training method, representative bands corresponding to each corn seed variety are selected to obtain a band subset.

7. A corn seed variety classification system, characterized in that, The system is applied to the corn seed variety classification method as described in any one of claims 1-6; the system comprises: The spectral image acquisition module is used to acquire spectral images of different varieties of corn seeds; The preprocessing module is used to preprocess the spectral image to obtain a single seed image; The spectral data extraction module is used to extract full-band spectral data of a single seed based on the single seed image; The band weight determination module is used to input the full-band spectral data into the band attention module to generate the weight of each band in the full-band spectral data; The weight sparsity constraint module is used to apply sparsity constraints to the weights of each band to obtain sparse band weights. The spectral weighting processing module is used to perform weighted processing on the full-band spectral data and the sparse band weights to obtain the weighted spectrum; The seed variety classification module is used to input the weighted spectrum into a convolutional neural network to obtain the corn seed variety classification results.

8. An electronic device, characterized in that, include: At least one processor, at least one memory, and a computer program stored in the memory; When the computer program is executed by the processor, it implements the corn seed variety classification method as described in any one of claims 1-6.

9. The electronic device according to claim 8, characterized in that, The memory is a computer-readable storage medium.