Method and System for Detecting Rice Seed Vigor Based on Hyperspectral Images
Through the rice seed vitality detection method based on hyperspectral images, using neural network model combined with Transformer-CNN-LightGBM integrated network, the problem of time-consuming and damaged traditional measurement methods is solved, and fast and accurate rice seed vitality detection is achieved.
Patent Information
- Application Number
- CN202510398362.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-01
- Publication Date
- 2025-06-13
- Estimated Expiration
- 2045-04-01
AI Technical Summary
The traditional rice seed vigor determination method takes a long time and causes damage to the seeds, making it difficult to meet the needs of modern agriculture for efficient and non-destructive testing technology.
The rice seed vitality detection method based on hyperspectral images is used to aging the sample rice seeds, collect spectral data, train neural network models, and use the Transformer-CNN-LightGBM integrated network to perform vitality detection.
The vitality level of rice seeds has been achieved quickly and non-destructively detected, which has improved the accuracy and adaptability of detection, and has met the demand for efficient detection technology in modern agriculture.
Smart Images

Figure CN119915771B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of measurement technology, and particularly to a method and system for detecting the vigor of rice seeds based on hyperspectral images. Background Art
[0002] Rice, as one of the most important food crops in the world, ranks second in terms of planting area and total output globally. During the production and planting process of rice, seed vigor is considered one of the key indicators for evaluating seed quality. Seed vigor not only reflects the germination ability of seeds but also determines the growth rate of seedlings and the final harvest yield of crops. Therefore, accurately, quickly, and non-destructively measuring the vigor of rice seeds has important practical application value.
[0003] Traditional methods for measuring seed vigor mainly rely on germination tests and chemical reagent detections. Although these methods have high accuracy, they usually require a long time and cause certain damage to seeds during the measurement process. Therefore, it is difficult to meet the requirements of modern agriculture for efficient and non-destructive detection technologies. With the rapid development of information technology and optical detection technology, non-destructive detection technologies based on spectral imaging have gradually become an emerging means in the field of seed quality detection. In particular, near-infrared hyperspectral imaging technology, with its ability to simultaneously obtain spectral information and image information in multiple bands, has received extensive attention and application in the agricultural field and demonstrated good prospects.
[0004] Near-infrared hyperspectral imaging technology (NIR-HSI) combines the advantages of spectral analysis and imaging technology and can obtain the physical and chemical information of seeds without damaging the samples. This technology can not only identify the external characteristics of seeds but also infer the internal structure and physiological state of seeds by analyzing their spectral data. Hyperspectral imaging technology has been widely applied in the field of non-destructive detection by efficiently collecting the surface images and spectral information of samples to be measured and has achieved remarkable results. Existing research has covered the variety detection of crops such as tea, red dates, apples, and corn and achieved good application effects. Summary of the Invention
[0005] In view of the problems existing in the above-mentioned prior art, the present invention provides a method and system for detecting the vigor of rice seeds based on hyperspectral images. The technical solution is as follows:
[0006] In a first aspect, a method for detecting the vigor of rice seeds based on hyperspectral images is provided, including:
[0007] Randomly grouping the sample rice seeds, leaving one group untreated with aging, and subjecting the remaining groups to different aging degrees of treatment to obtain an untreated sample rice seed group and multiple sample rice seed groups with different aging degrees;
[0008] Collect the rice seed spectral data of different sample rice seed groups as training samples;
[0009] Place different sample rice seed groups in a preset environment for germination, and determine the vitality levels of different sample rice seed groups based on the germination rates of different sample rice seed groups;
[0010] Train a pre-constructed neural network model based on the rice seed spectral data and the corresponding vitality levels of different sample rice seed groups to obtain a trained rice seed vitality detection model. The pre-constructed neural network model includes a Transformer module, and the Transformer module uses an improved attention score acquisition method to determine the attention score based on a dynamic self-attention mechanism;
[0011] For the rice seeds to be detected, collect the rice seed spectral data, input it into the rice seed vitality detection model, and obtain the detection result of the rice seed vitality level.
[0012] In some embodiments, before inputting the rice seed spectral data into the neural network model or the rice seed vitality detection model, it further includes: preprocessing the rice seed spectral data, and the preprocessing includes:
[0013] Process the spectral data by using at least one of polynomial convolution smoothing SG, standard normal variate SNV, and multiplicative scatter correction MSC;
[0014] Perform dimensionality reduction processing on the spectral data by using principal component analysis PCA;
[0015] Extract characteristic wavelengths from the spectral data by using successive projections algorithm SPA.
[0016] In some embodiments, the pre-constructed neural network model includes:
[0017] A Transformer module, which is used to receive the rice seed spectral data and capture global features of the multi-dimensional rice seed spectral data;
[0018] A CNN module, which is used to extract local features from the spectral feature data output by the Transformer module;
[0019] A LightGBM module, which is used to classify the spectral feature data output by the CNN module and output a classification result.
[0020] In some embodiments, the calculation of the attention score in the Transformer module is:
[0021] Obtain the input spectral data sequence ;
[0022] Obtain the spectral data sequence through the local feature extraction network The local feature representation at the i-th position ;
[0023] Based on the local feature representation at the i-th position and the local feature representation at the j-th position to determine the local feature change weight matrix of the association weight the weight element value of the i-th row and j-th column in ;
[0024] Based on the attention score calculation formula to obtain the attention score in the Transformer module, the attention score calculation formula is: , where the query vector , the key vector , the value vector , where , , are weight matrices, is the input spectral data sequence, is the key vector dimension, is the local feature change weight matrix calculated according to the local feature change of the spectral data.
[0025] In some embodiments, the calculation of the attention score in the Transformer module further includes:
[0026] When a key wavelength region related to seed vigor appears in the spectrum, with an enhancement factor to enhance the attention weight of the region, the adjusted attention score is:
[0027] , where > 1.
[0028] In some embodiments, a deformable convolution kernel is used in the CNN module.
[0029] In some embodiments, the LightGBM module uses quantum computing for feature discretization and optimizes the discretization process by utilizing the superposition and entanglement characteristics of quantum states.
[0030] In some embodiments, the process of using quantum computing for feature discretization in the LightGBM module includes:
[0031] Step a1, for continuous features, based on the distribution of the feature values, starting from the larger values of the feature, iteratively analyze until the minimum value of the feature values to determine the cut-off points of each bin one by one, obtaining the value intervals of the bins and the number of bins n;
[0032] Step a2: Convert the eigenvalue of the sample into a quantum state to obtain the quantum state of the box and the quantum state of the sample eigenvalue. The conversion is performed through quantum gate operations. Perform a quantum state transformation on the eigenvalue. , where represents the quantum state of the eigenvalue;
[0033] Step a3: Based on the eigenvalue of the sample, use the binning function to divide the samples into different boxes. , where represents the quantum state of the b-th box, b = 1, 2,..., n, x represents the sample, and this binning function characterizes obtaining the box number b to which the sample x is assigned when it is maximized;
[0034] Step a4: Use the quantum statistical function to count the samples in each box.
[0035] In some embodiments, the aging treatment includes: using the saturated salt accelerated aging test method to create a high-humidity environment with a saturated salt solution, and performing aging treatments on rice seeds for durations of 1 day, 2 days, 3 days, 4 days, and 5 days under high-temperature and high-humidity conditions.
[0036] In a second aspect, a rice seed vigor detection system based on hyperspectral images is provided, including:
[0037] A sample preprocessing unit for randomly grouping the sample rice seeds, leaving one group untreated and subjecting the remaining groups to different aging treatments to obtain an untreated sample rice seed group and multiple sample rice seed groups with different aging degrees;
[0038] A first sample data acquisition unit for acquiring the rice seed spectral data of different sample rice seed groups as training samples;
[0039] A second sample data acquisition unit for germinating different sample rice seed groups in a preset environment and determining the vigor levels of different sample rice seed groups based on the germination rates of different sample rice seed groups;
[0040] A vigor detection model training unit for training a pre-constructed neural network model based on the rice seed spectral data of different sample rice seed groups and the corresponding vigor levels to obtain a trained rice seed vigor detection model. The pre-constructed neural network model includes a Transformer module, and the Transformer module uses an improved attention score acquisition method to determine the attention score based on a dynamic self-attention mechanism;
[0041] The rice seed vigor detection unit is used to collect the spectral data of the rice seeds to be detected, input the spectral data into the rice seed vigor detection model, and obtain the detection result of the rice seed vigor level.
[0042] A method and system for detecting rice seed vigor based on hyperspectral images according to the present invention have the following beneficial effects: Compared with traditional models, the innovation of the Transformer-CNN-LightGBM integrated network classification model has significant advantages. In the Transformer part, the traditional self-attention mechanism has relatively fixed attention allocation for each position, while the dynamic self-attention mechanism can flexibly adjust the weights according to the changes in the local spectral features. When the key wavelength region appears, it enhances the attention. Compared with the traditional mechanism, it can capture the key information of seed vigor more accurately, greatly improve the judgment accuracy, and has stronger adaptability to different spectral data. In the CNN part, the traditional fixed convolution kernel is difficult to adapt to the complex feature distribution of the spectrum. The deformable convolution kernel can automatically adjust its size and shape according to the feature distribution. The small kernel captures fine features, and the large kernel extracts extensive information. Compared with the traditional convolution kernel, it extracts features more comprehensively and endows the model with higher flexibility in processing complex data. In the LightGBM part, the traditional histogram algorithm has limited computational efficiency and accuracy. After being optimized by quantum computing, the discretization and statistical calculations are more efficient and accurate. Compared with the traditional method, the model performance is significantly improved, and it has obvious advantages in processing spectral data features. Description of the Drawings
[0043] Figure 1 is a schematic flowchart of a method for detecting rice seed vigor based on hyperspectral images according to an embodiment of the present application;
[0044] Figure 2 is the original spectrum of rice seeds with different aging degrees;
[0045] Figure 3 is the average spectrogram of rice seeds with different aging degrees;
[0046] Figure 4 is a schematic diagram of the detection result of Mahalanobis distance outliers for the SG preprocessing effect of the spectral data of rice seeds;
[0047] Figure 5 is a schematic diagram of the detection result of Mahalanobis distance outliers for the MSC preprocessing of the spectral data of rice seeds;
[0048] Figure 6 is a schematic diagram of the detection result of Mahalanobis distance outliers for the SNV preprocessing of the spectral data of rice seeds;
[0049] Figure 7 is a feature point diagram of SPA feature extraction. Detailed Embodiments
[0050] It should be understood that the specific embodiments described herein are merely for explaining the present invention and are not intended to limit the present invention.
[0051] As Figure 1 shown, a rice seed vigor detection method based on hyperspectral images provided by an embodiment of the present application includes:
[0052] Step 1: Randomly group the sample rice seeds, leave one group untreated with aging, and perform different aging degree treatments on the remaining groups to obtain an untreated sample rice seed group and multiple sample rice seed groups with different aging degrees;
[0053] Step 2: Collect the rice seed spectral data of different sample rice seed groups as training samples;
[0054] Step 3: Place different sample rice seed groups in a preset environment for germination, and determine the vigor levels of different sample rice seed groups based on the germination rates of different sample rice seed groups;
[0055] Step 4: Train a pre-constructed neural network model based on the rice seed spectral data of different sample rice seed groups and the corresponding vigor levels to obtain a trained rice seed vigor detection model; the pre-constructed neural network model includes a Transformer module, and the Transformer module adopts an improved attention score acquisition method to determine the attention score based on a dynamic self-attention mechanism. Specifically, the calculation process of the self-attention score is dynamically adjusted according to the correlation relationship of local features at different positions in the spectral data, that is, the attention degree of the model to different positions in the spectral data is dynamically adjusted according to the correlation relationship of local features at different positions in the spectral data;
[0056] Step 5: For the rice seeds to be detected, collect the rice seed spectral data and input it into the rice seed vigor detection model to obtain the detection result of the rice seed vigor level.
[0057] Specifically, in the above step 1, the selected rice seeds are subjected to aging treatment for durations of 1 day, 2 days, 3 days, 4 days, and 5 days, and at the same time, rice seeds without aging treatment are set as the control group. After completing the artificial aging treatment, when selecting seed samples, damaged and shriveled seeds are removed, and samples with uniform color and intact grains are selected. A total of 1200 rice seeds are prepared. All samples are randomly divided into a training set, a validation set, and a test set according to a ratio of 7:2:1 for subsequent data analysis and model validation. In the embodiment of the present application, the saturated salt accelerated aging test method uses a saturated salt solution to create a high-humidity environment. The saturated salt solution at 48 degrees Celsius can provide a stable high-humidity environment. Under this high-temperature and high-humidity condition, the rice seeds are subjected to aging treatment for durations of 1 day, 2 days, 3 days, 4 days, and 5 days, and at the same time, rice seeds without aging treatment are set as the control group. The sample rice seeds are packed into nylon mesh bags with good air permeability, and the number of seeds in each bag is the same. Plastic bottles are prepared and holes are made on the sides to facilitate the addition of saturated sodium chloride solution to control the relative humidity of the environment. The saturated salt solution is prepared by dissolving sodium chloride in water in proportion until solid precipitation appears and stirring is stopped to ensure that the solution is in a saturated state. The prepared solution is poured into the plastic bottle, and the nylon mesh bag containing the rice seeds is hung at the mouth of the plastic bottle, and the bottle cap is screwed on. The release amount of water vapor is controlled by making small holes in the bottle cap to ensure that the seeds are in a high-humidity environment but do not contact the solution. The entire system is placed in an oven set at 48 degrees Celsius for aging treatment. The saturated salt solution at 48 degrees Celsius can provide a stable high-humidity environment to simulate the high-temperature and high-humidity aging conditions of the seeds. According to the experimental design, the aging times are set to 1 day, 2 days, 3 days, 4 days, and 5 days respectively, and the seeds in the corresponding treatment groups are taken out after each time period ends. During the experiment, the amount of saturated salt solution in the plastic bottle is regularly checked, and the solution is supplemented through the side holes when necessary to maintain a constant relative humidity of the environment.
[0058] In one implementation manner, in the above step 2, the original spectra of rice seed samples without aging treatment, aging treatment for 1 day, aging treatment for 2 days, aging treatment for 3 days, aging treatment for 4 days, and aging treatment for 5 days are collected by a near-infrared hyperspectral spectrometer at the full-band wavelength (300 - 1100 nm); the hyperspectral images are collected by the FigSpec series hyperspectral imaging camera FS-20: Open the FigSpec software. After calibrating the near-infrared hyperspectral spectrometer with a whiteboard, the hyperspectral camera takes pictures of the rice seeds, and the Envi software is used to extract the reflectance of the region of interest of the rice seeds. The collected original data spectrogram and the average spectrogram are as Figure 2 , Figure 3 shown.
[0059] In one embodiment, in the above step 3, the relationship between the seed vigor level and the germination rate was analyzed through a seed germination experiment. The rice seed germination experiment was conducted in accordance with the regulations of the International Seed Testing Association (ISTA). 120 rice seeds of different aging degrees were selected and randomly divided into 3 groups, and the results were averaged. The seeds were evenly placed in a petri dish lined with a layer of moist filter paper, watered with sterile water, and placed in a greenhouse at a temperature of 23°C and a humidity of 60% for a 14-day germination test. The germination of each group of seeds was observed regularly, and the average germination rate was recorded. The vigor level of different sample rice seed groups was determined based on the germination rate of different sample rice seed groups.
[0060] In one embodiment, in the above step 4, the pre-constructed neural network model was trained based on the rice seed spectral data and the corresponding vigor levels of different sample rice seed groups to obtain a trained rice seed vigor detection model, including:
[0061] Step 41, first preprocess the rice seed spectral data collected from different sample rice seed groups.
[0062] Step 42, then train the pre-constructed neural network model based on the preprocessed rice seed spectral data and the corresponding vigor level annotation data.
[0063] Among them, in step 41, the preprocessing of the rice seed spectral data includes:
[0064] Step 411, process the spectral data using at least one of the methods of polynomial convolution smoothing SG, standard normal variate transformation SNV, and multiplicative scatter correction MSC;
[0065] Step 412, perform dimensionality reduction processing on the spectral data using principal component analysis PCA;
[0066] Step 413, extract the characteristic wavelengths of the spectral data using the successive projections algorithm SPA.
[0067] In the embodiments of the present application, to reduce the influence of interference factors on the spectral data of rice seed samples and improve the discrimination accuracy of the model, three commonly used spectral data preprocessing methods are adopted: Savitzky-Golay (SG) polynomial convolution smoothing, Standard Normal Variate (SNV), and Multiplicative Scatter Correction (MSC), and the Mahalanobis distance outlier detection is used to compare and evaluate their effects. The SG method is based on the sliding window and polynomial fitting techniques to smooth the noise in the spectral data; while SNV and MSC correct each spectrum by taking the average spectrum of the sample spectra as the benchmark and combining linear regression or normalization transformation, thereby effectively reducing the interference of multivariate scattering on the data. From Figure 4 , Figure 5 , Figure 6 the evaluation of the effect of Mahalanobis distance outlier detection, it can be seen that the SG preprocessing method achieves the best effect. Therefore, the SG method is adopted to preprocess the spectral data in the embodiments of the present application.
[0068] Furthermore, the PCA method is used to perform exploratory analysis on the spectral data and evaluate the applicability of the classification task, providing a solid data foundation for the construction of the subsequent classification model. Principal Component Analysis (PCA) is a technique widely used in data dimensionality reduction, which effectively reduces the dimension of the data by extracting the main components in the data, removing noise and redundant information.
[0069] To extract the most valuable feature information for modeling from the spectral data, the Successive Projection Algorithm (SPA) is used for the selection and extraction of characteristic wavelengths. SPA transforms the variable selection problem into a combinatorial optimization problem with constraints, performs projection operations in the vector space, and selects a subset of variables with the smallest multicollinearity. This algorithm evaluates the similarity between wavelengths by measuring the angular difference between spectra, thereby preferentially selecting wavelengths with stronger correlation with the target variable. This way significantly reduces the dimension of the data, reduces redundant information, effectively reduces the complexity of subsequent analysis, and provides a concise and representative feature set for the establishment of an efficient classification model. Figure 7 Figure of characteristic points extracted by SPA.
[0070] The pre-constructed neural network model described in step 4 or step 42 above adopts a Transformer-CNN-LightGBM integrated model. In this pre-constructed neural network model, it includes:
[0071] A Transformer module for receiving rice seed spectral data and capturing global features of multi-dimensional rice seed spectral data;
[0072] A CNN module for extracting local features from the spectral feature data output by the Transformer module;
[0073] A LightGBM module for classifying the spectral feature data output by the CNN module and outputting a classification result.
[0074] In the embodiment of the present application, the Transformer-CNN-LightGBM classification model is used for rapid detection of rice seed vigor level, combining the global feature capture ability of Transformer, the local feature extraction advantage of CNN, and the efficient classification performance of LightGBM.
[0075] The present invention makes an innovative optimization of the Transformer-CNN-LightGBM classification model as follows: In the Transformer part, a dynamic self-attention mechanism is innovatively introduced. The traditional Transformer architecture takes the self-attention mechanism as the core, calculates the attention scores through the Query, Key, and Value matrices, multiplies with the value matrix after normalization by the softmax function to obtain the output, so as to capture the dependencies within the sequence. Let the input spectral data sequence be , the query vector , the key vector , the value vector , the traditional attention score calculation formula is . Among them, , , are weight matrices, is the input spectral data sequence, is the key vector dimension.
[0076] The dynamic self-attention mechanism introduced in the embodiment of the present application extracts the local features of the spectral data through an additional local feature extraction module, and then generates a weight adjustment factor to adjust the attention weights in the traditional self-attention mechanism. The attention score calculation process of the Transformer module in the embodiment of the present application includes:
[0077] Step 421, obtain the input spectral data sequence ;
[0078] Step 422, obtain the local feature representation of the i-th position in the spectral data sequence through the local feature extraction network;
[0079] Step 423, based on the local feature representation and the local feature representation at the j-th position The associated weights determine the local feature change weight matrix The weight element value at the i-th row and j-th column in to obtain the local feature change weight matrix ;
[0080] Step 424, obtaining the attention scores in the Transformer module based on the attention score calculation formula, where the attention score calculation formula is: , where the query vector , the key vector , the value vector , where , , are weight matrices, is the input spectral data sequence, is the key vector dimension, is the local feature change weight matrix calculated based on the local feature changes of the spectral data. The matrix records the change relationships between local features at various positions in the entire spectral data sequence.
[0081] In the embodiments of the present application, under the dynamic self-attention mechanism, a local feature change weight matrix calculated based on the local feature changes of the spectral data is introduced . Assuming that the local feature representation is obtained through the local feature extraction network, where the local feature extraction network can adopt algorithms such as the CNN convolutional network, represents the association weight based on local features between the -th position and the -th position. This association weight can be determined based on the dot product of the local feature vector extracted by the local feature extraction network and its own transpose. The matrix reflects the relationships between features at different positions in the spectral data, enabling more attention to different parts of the entire spectral data in the attention score calculation. The dynamically adjusted attention score calculation formula is . When a key wavelength region closely related to seed vigor appears in the spectrum (assuming the index set is S), the attention weights in this region are enhanced with an enhancement factor ( > 1), and the adjusted attention score is , achieving more accurate capture of key information.
[0082] In one implementation, in order to better explore the hidden correlation relationships of the local features of the spectral data sequence, after calculating the attention scores of the Transformer module, it may further include: inputting the attention data calculated based on the attention mechanism into a preset convolutional module, and after processing by the preset convolutional module, the result is fused with the attention data calculated based on the attention mechanism through residual connection and then input into the feed-forward neural network layer; the preset convolutional module includes: a convolutional layer, a causal convolutional layer, and a dilated convolutional layer connected in series in sequence. The causal convolutional layer and the dilated convolutional layer are combined to fully explore the hidden correlation relationships of the local features of the spectral data sequence. Further, in order to better capture the local and global features of the spectral data sequence, in the Transformer module, it may further include: using the ConvFFN algorithm as the above-mentioned feed-forward neural network layer.
[0083] In the CNN part, deformable convolutional kernels are adopted. The sampling positions of traditional convolutional kernels are fixed, and they are insufficiently adaptable to the complex feature distributions of spectral data. In the present invention, the size and shape of the deformable convolutional kernels can be adaptively adjusted according to the feature distributions of the spectral data. Let the input feature map be F, and the traditional convolutional operation is expressed as (( ) is the position of the output feature map, and (( ) is the position of the convolutional kernel)). The present invention introduces the offset learned by an additional convolutional layer, and the deformable convolutional operation formula becomes . At the same time, let the adaptive adjustment function be , and according to the statistical information (such as variance, mean, etc.) of the input feature map F, the adjustment parameters of the size and shape of the convolutional kernel are calculated, and then the adjusted convolutional kernel is obtained, improving the ability to extract local features of different scales and shapes.
[0084] In the LightGBM part, the histogram algorithm is improved by combining the principles of quantum computing. LightGBM originally uses the histogram algorithm for feature discretization, discretizing continuous floating feature values into integers, forming discrete bins and constructing a histogram with a width of , and searching for the optimal splitting point by traversing the data to accumulate statistical information. The present invention combines the principles of quantum computing and uses the superposition and entanglement characteristics of quantum states to optimize the discretization process, which specifically includes the following steps:
[0085] Step a1, for continuous features, based on the distribution of the feature values, starting from the larger feature values and iteratively analyzing until the minimum feature value, the splitting points of each bin are determined one by one to obtain the value intervals of the bins and the number of bins n;
[0086] Step a2: Convert the eigenvalue of the sample into a quantum state to obtain the quantum state of the box and the quantum state of the sample eigenvalue. The conversion is performed through quantum gate operations. Perform a quantum state transformation on the eigenvalue. , where represents the quantum state of the eigenvalue.
[0087] Step a3: Based on the eigenvalue of the sample, divide the samples into different boxes through a binning function. , where represents the quantum state of the b-th box, b = 1, 2,..., n, x represents the sample, and this binning function characterizes obtaining the box number b to which the sample x is assigned when it is maximized.
[0088] Step a4: Use the quantum statistical function to count the samples in each box.
[0089] Specifically, the quantum state transformation is achieved through quantum gate operations, the box to which the sample belongs is determined through the binning function, and the quantum parallelism is used to accelerate the calculation through , improving the calculation efficiency and classification accuracy. Among them, in one implementation, in the above step a1, based on the distribution of the values of the feature, the number of value categories of the feature and the frequency of each category of values can be determined first; start analyzing the cut-off point of the first box from the maximum value of the feature, and then sequentially analyze the cut-off points of each box in descending order of the values of the feature until the minimum value of the feature is reached, to determine the cut-off points of all boxes and the total number of boxes. Among them, whether the cut-off point of each box is a large number is determined based on whether the number of values of the current feature is greater than the quotient of the total number of values of the remaining features in the current stage and the total number of available boxes remaining in the current stage (the total number of available boxes remaining in the current stage is equal to the preset maximum number of boxes minus the number of boxes for which the cut-off points have been determined). If it is greater, it is a large number; if it is less, it is a small number in the current stage. The value of the current feature determined to be a large number is determined as a cut-off point, and the value of the next feature after the value of the current feature determined to be a large number is determined as the next cut-off point; for the remaining values of the current feature determined to be small numbers, count the number of values of the feature between the values of two adjacent determined cut-off point features. When the count reaches the quotient of the current stage, determine the value of the current feature as a cut-off point. If a previously determined cut-off point is encountered before the count reaches the quotient of the current stage, the value of a feature before the value of the determined cut-off point is a cut-off point. In one implementation, for the above step a3, through maximizing to determine the box number b to which the sample x is assigned, the best binning can be adaptively determined. In one implementation, for the above step a4, use the quantum statistical function The samples in each box can be counted, and data such as the number of samples in each box and the gradient of the samples can be counted.
[0090] An embodiment of the present application also provides a rice seed vigor detection system based on hyperspectral images, including:
[0091] A sample preprocessing unit for randomly grouping the sample rice seeds, leaving one group untreated with aging, and treating the remaining groups with different aging degrees respectively to obtain an untreated sample rice seed group and multiple sample rice seed groups with different aging degrees;
[0092] A first sample data acquisition unit for acquiring the rice seed spectral data of different sample rice seed groups as training samples;
[0093] A second sample data acquisition unit for germinating different sample rice seed groups in a preset environment and determining the vigor levels of different sample rice seed groups based on the germination rates of different sample rice seed groups;
[0094] A vigor detection model training unit for training a pre-constructed neural network model based on the rice seed spectral data and the corresponding vigor levels of different sample rice seed groups to obtain a trained rice seed vigor detection model;
[0095] A rice seed vigor detection unit for collecting the rice seed spectral data of the rice seeds to be detected, inputting the rice seed spectral data into the rice seed vigor detection model, and obtaining a detection result of the rice seed vigor level.
[0096] For the specific limitations of the rapid non-destructive detection system for rice seed vigor level based on near-infrared spectroscopy, reference can be made to the limitations of the rice seed vigor detection method based on hyperspectral images in the above text, which will not be elaborated here. Each unit in the above rapid non-destructive detection system for rice seed vigor level based on near-infrared spectroscopy can be implemented in whole or in part by software, hardware, and their combination. The above units can be embedded in the processor of the computer device in hardware form or be independent of it, or be stored in the memory of the computer device in software form so that the processor can call and execute the operations corresponding to the above units.
[0097] The present invention is not limited to the above specific embodiments. Those of ordinary skill in the art starting from the above concepts and making various transformations without creative labor fall within the protection scope of the present invention.
Claims
1. A rice seed vitality detection method based on hyperspectral images, characterized in that: include: The sample rice seeds are randomly grouped, one of the groups is not subjected to aging treatment, and the remaining groups are subjected to different aging degree treatments, so as to obtain a sample rice seed group that is not subjected to aging treatment and a plurality of sample rice seed groups with different aging degrees; Collecting rice seed spectral data of different sample rice seed groups as training samples; placing different sample rice seed groups in a preset environment for germination, and determining the vitality levels of the different sample rice seed groups based on the germination rates of the different sample rice seed groups; Training a pre-constructed neural network model based on rice seed spectral data and corresponding vitality levels of different sample rice seed groups to obtain a trained rice seed vitality detection model, wherein the pre-constructed neural network model includes a Transformer module, and the Transformer module adopts an improved attention score acquisition method to determine the attention score based on a dynamic self-attention mechanism; The attention score calculation formula is: , where the query vector , the key vector , value vector ,in, , , is the weight matrix, For the input spectral data sequence, is the key vector dimension, is the local feature change weight matrix calculated according to the local feature change of spectral data; For the rice seeds to be tested, the rice seed spectrum data is collected and input into the rice seed vitality detection model to obtain the rice seed vitality level detection result.
2. The rice seed vitality detection method based on hyperspectral images according to claim 1, characterized in that: Before inputting the rice seed spectral data into the neural network model or the rice seed vitality detection model, the method further includes: preprocessing the rice seed spectral data, wherein the preprocessing includes: The spectral data are processed by using at least one of polynomial convolution smoothing SG, standard normal transformation SNV, and multivariate scatter correction MSC; The spectral data were processed by principal component analysis (PCA) to reduce the dimension. The successive projection algorithm SPA is used to extract characteristic wavelengths from spectral data.
3. The rice seed vitality detection method based on hyperspectral image according to claim 1, characterized in that: The pre-built neural network model includes: Transformer module, used to receive rice seed spectral data and capture global features of multi-dimensional rice seed spectral data; CNN module, used to extract local features from the spectral feature data output by the Transformer module; The LightGBM module is used to classify the spectral feature data output by the CNN module and output the classification results.
4. The rice seed vitality detection method based on hyperspectral image according to claim 3, characterized in that: The attention score calculation in the Transformer module includes: Get the input spectral data sequence ; Obtaining spectral data sequence through local feature extraction network The local feature representation of the i-th position in ; Local feature representation based on the i-th position and the local feature representation of the jth position The association weights determine the local feature change weight matrix The weight element value of the i-th row and j-th column in the local feature change weight matrix is obtained. ; The attention score in the Transformer module is obtained based on the attention score calculation formula.
5. The rice seed vitality detection method based on hyperspectral image according to claim 4, characterized in that: The attention score calculation in the Transformer module also includes: When the critical wavelength region related to seed vigor appears in the spectrum, the enhancement factor The attention weight of the region is enhanced, and the adjusted attention score is: ,in >
1.
6. The rice seed vitality detection method based on hyperspectral image according to claim 3, characterized in that: The CNN module uses a deformable convolution kernel.
7. The rice seed vitality detection method based on hyperspectral image according to claim 3, characterized in that: The LightGBM module uses quantum computing to discretize features and uses the superposition and entanglement characteristics of quantum states to optimize the discretization process.
8. The rice seed vitality detection method based on hyperspectral image according to claim 7, characterized in that: The LightGBM module uses quantum computing to discretize features, including: Step a1: for continuous features, based on the distribution of feature values, iterative analysis is performed starting from the larger value of the feature until the minimum value of the feature value is reached, and the split points of each box are determined one by one to obtain the value range of the box and the number of boxes n; Step a2, converting the characteristic value of the sample into a quantum state, obtaining the quantum state of the box and the quantum state of the characteristic value of the sample, the conversion is performed by quantum gate operation Perform quantum state transformation on the eigenvalues, ,in, A quantum state representing an eigenvalue; Step a3: Based on the feature values of the samples, the samples are divided into different boxes through the binning function. ,in, represents the quantum state of the b-th box, b=1, 2, ..., n, x represents the sample, and the binning function characterizes the acquisition The box number b to which the maximum sample x is assigned; Step a4, using quantum statistical function Count the samples in each box.
9. The rice seed vitality detection method based on hyperspectral image according to claim 1, characterized in that: The aging treatment includes: using a saturated salt accelerated aging test method to create a high humidity environment using a saturated salt solution, and performing aging treatment on rice seeds for 1 day, 2 days, 3 days, 4 days, or 5 days under high temperature and high humidity conditions.
10. A rapid non-destructive detection system for rice seed vitality level based on near infrared spectroscopy, characterized in that: include: The sample pretreatment unit is used to randomly group the sample rice seeds, not perform aging treatment on one of the groups, and perform different aging degree treatments on the remaining groups, so as to obtain a sample rice seed group without aging treatment and a plurality of sample rice seed groups with different aging degrees; A first sample data collection unit is used to collect rice seed spectrum data of different sample rice seed groups as training samples; The second sample data collection unit is used to place different sample rice seed groups in a preset environment for germination, and determine the vitality levels of the different sample rice seed groups based on the germination rates of the different sample rice seed groups; The vitality detection model training unit trains a pre-constructed neural network model based on the rice seed spectral data and corresponding vitality levels of different sample rice seed groups to obtain a trained rice seed vitality detection model, wherein the pre-constructed neural network model includes a Transformer module, and the Transformer module adopts an improved attention score acquisition method to determine the attention score based on a dynamic self-attention mechanism; the attention score calculation formula is: , where the query vector , the key vector , value vector ,in, , , is the weight matrix, For the input spectral data sequence, is the key vector dimension, is the local feature change weight matrix calculated according to the local feature change of spectral data; The rice seed vitality detection unit is used to collect rice seed spectrum data for the rice seeds to be detected, input the rice seed vitality detection model, and obtain the rice seed vitality level detection result.
Citation Information
Patent Citations
Rapid rice seed vigor detection method based on near infrared spectrum
CN119498063A
CIELAB color space-based quantitative testing and analysis method for rice seed viability
US12002242B1