Intelligent kidney bean seed vigor detection method based on hyperspectrum and deep learning
Through hyperspectral imaging and deep learning technology, combined with convolutional filtering, Gaussian filtering and multi-scale spectral attention residual network (MSARN) model, the problems of long time, strong destructiveness and low accuracy of seed vitality detection of bean seeds are solved, and lossless and efficient vitality recognition is achieved.
Patent Information
- Application Number
- CN202510579010.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-06
- Publication Date
- 2025-08-15
AI Technical Summary
In the prior art, the vigor detection of seeds of bean seeds takes a long time and is highly destructive, the image preprocessing method is insufficiently targeted, the feature extraction is complex and efficient, and the model generalization ability is limited, resulting in low detection accuracy.
Hyperspectral imaging technology combined with deep learning is used to remove noise through a combination of convolutional filtering and Gaussian filtering, and the feature wavelength extraction algorithm and multi-scale spectral attention residual network (MSARN) model are used to detect the seed vitality of beans, including image preprocessing, feature wavelength extraction and model construction.
It realizes non-destructive, efficient and accurate identification of seed vitality detection of bean seeds, improves detection efficiency and accuracy, and provides strong support for bean breeding and large-scale planting.
Smart Images

Figure CN120495883A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of seed vigor detection, and in particular to an intelligent detection method for kidney bean seed vigor based on hyperspectral and deep learning. Background Art
[0002] Kidney beans are widely cultivated as edible legumes, and seed vigor significantly impacts their yield and quality. High-vibrant seeds demonstrate robust growth momentum, disease resistance, and strong adaptability. However, bean seeds are prone to irreversible aging due to adverse storage conditions or mechanical processing, leading to a decrease in vigor. Testing seed vigor helps ensure the quality of crop production.
[0003] Traditional seed viability testing methods are time-consuming and highly destructive, making them difficult to meet the needs of large-scale planting. However, research on seed viability testing, particularly for kidney bean seeds, based on hyperspectral imaging combined with deep learning as a non-destructive testing technology is insufficient and presents the following challenges:
[0004] 1. The preprocessing method is not targeted enough and the processing effect is limited: insufficient consideration is given to seed morphological characteristics, and the image segmentation accuracy and noise removal effect are limited. In particular, there is a lack of optimization for the characteristics of kidney bean seeds with thin seed coat and small spectral differences.
[0005] 2. Feature extraction is complex and inefficient: It is difficult to fully eliminate redundant information, resulting in high model complexity and low extraction efficiency.
[0006] 3. Limited model generalization and low accuracy: Traditional or single models are unable to capture the multi-scale features and key wavelengths of hyperspectral data, resulting in low accuracy in multi-variety mixed detection scenarios.
[0007] Therefore, there is an urgent need for a non-destructive, efficient and accurate vitality detection method for kidney bean seeds to solve at least one of the defects in image preprocessing, characteristic wavelength extraction and model design in the existing technology, and provide strong support for kidney bean breeding and large-scale planting. Summary of the Invention
[0008] The purpose of the present invention is to provide an intelligent detection method for kidney bean seed vitality based on hyperspectral and deep learning, which solves at least one of the defects in image preprocessing, characteristic wavelength extraction and model design in the prior art.
[0009] In order to solve the above technical problems, the technical solutions of the present invention are as follows:
[0010] The present invention provides an intelligent detection method for kidney bean seed vitality based on hyperspectral and deep learning, comprising the following steps: photographing kidney bean seeds of multiple varieties with different vitality levels to obtain original hyperspectral images of the kidney bean seeds; performing image preprocessing on the original hyperspectral images, removing noise by combining convolution filtering and Gaussian filtering, and extracting the original average spectrum of the kidney bean seeds; extracting the characteristic wavelengths in the original average spectrum by using a characteristic wavelength extraction algorithm; constructing a multi-scale spectral attention residual network (MSARN) detection model, dividing the average spectrum into multiple scales according to bands, extracting multi-scale features by using a parallel convolutional network, and outputting the final vitality level recognition results of different kidney bean seeds after fusing them through residual connection and multi-head attention mechanism.
[0011] Furthermore, the photographing of kidney bean seeds of multiple varieties and different vitality levels specifically includes the following steps: constructing a kidney bean seed hyperspectral image acquisition system, including: a hyperspectral imager, a light source system, a sample storage table, a tripod, an aluminum frame, a black blackout cloth and a computer; the hyperspectral imager is used to photograph the characteristics of the kidney bean seeds to obtain original hyperspectral images; the light source system is composed of multiple halogen lamps, which are used to provide uniform and sufficient light for the hyperspectral imager to ensure that the brightness and darkness on the original hyperspectral image are balanced and the details of the measured object are accurately presented; the sample storage table is used to place the kidney bean seeds to ensure that the kidney bean seeds remain stable during the photographing process; the tripod is used to carry the hyperspectral imager to ensure that the original hyperspectral image is smooth and the details of the measured object are accurately presented. The installation position of the imager is fixed and remains stable; the aluminum frame is used to place the hyperspectral imager, light source system, sample storage table and tripod, etc., to ensure that the collection environment is independent and reduce the influence of external factors; the black blackout cloth is covered on the outside of the aluminum frame to create an interference-free shooting environment to prevent external light interference; the computer is used to control the hyperspectral imager, process the original hyperspectral image, and perform feature extraction; a certain number of kidney bean seeds are placed on the sample storage table, and the focal length and aperture of the hyperspectral imager and the illumination angle of the halogen lamp are adjusted to obtain clear seed hyperspectral images with less shadows; the original images of all kidney bean seeds are collected group by group, and each seed is numbered according to "variety name + aging time + group number + serial number".
[0012] Furthermore, the image preprocessing of the original hyperspectral image specifically includes the following steps: using a gray matter plate to calibrate the original hyperspectral image into a reflectance image; at the wavelength where the reflectance difference between the background and the seed area is the largest, the image is sequentially subjected to convolution filtering and Gaussian filtering to remove noise; the image is binarized using the Ostu method, and the morphological opening operation is used to eliminate small noise and small spots, generate a seed area mask and segment a single seed, and calculate the regional average spectrum.
[0013] Furthermore, a characteristic wavelength extraction algorithm is used to extract characteristic wavelengths from the original average spectrum, specifically including the following steps: using two successive projection methods (SPA) to extract characteristic wavelengths from the original average spectrum, first screening initial characteristic wavelengths related to vitality from all wavelengths, and then further eliminating redundant wavelengths, and finally obtaining characteristic wavelengths that are more relevant to bean seed vitality.
[0014] Furthermore, the architecture of the multi-scale spectral attention residual network (MSARN) model includes: an input layer, which contains four parallel CNN networks, dividing the spectral data into four scales according to the number of bands (spectral band / 8, spectral band / 4, spectral band / 2, and full band); multi-scale convolution branches, each CNN branch contains two consecutive one-dimensional convolution modules (Conv); a residual connection structure, in which residual connections (Res1, Res2) are set between the CNN output and the LSTM output, and between the input and output of the multi-head attention mechanism; an output layer (FC), which receives the residual result of Res2 and outputs the final vitality level recognition result.
[0015] Furthermore, the output of the final vitality level recognition result is specifically as follows: using SoftMax to convert the result of the output layer into a probability value, and using the label with the highest probability value as the predicted label of the input seed vitality level.
[0016] Furthermore, constructing the MSARN model specifically includes the following steps: dividing the average spectrum after extracting the characteristic wavelength into a training set, a validation set and a test set; the training set is a set of training samples of kidney bean seeds of various vigor levels; the validation set is a set of validation samples of kidney bean seeds of various vigor levels; the test set is a set of test samples of kidney bean seeds of various vigor levels; and the average spectrum of kidney bean seeds of different vigor levels in all varieties is randomly divided into training samples, validation samples and test samples according to proportion.
[0017] Furthermore, constructing the MSARN model specifically includes the following steps: taking the characteristic wavelength of the original average spectrum as input and the true vigor grade label of the seed sample as output; training the model using the training set data, performing parameter tuning based on the detection performance of the model on the validation set, and obtaining a trained classification model for detecting bean seeds of different vigors in the test set.
[0018] Furthermore, the parameter tuning specifically includes: in the two Conv1d of MSARN, the convolution kernel size is 1×3, the stride is 1, the padding is 1, and the output channels are 32 and 64 respectively; the hidden layer dimension of each LSTM network is set to 128, and dropout with p=0.5 is used for regularization.
[0019] Compared with the prior art, the present invention has at least the following beneficial effects:
[0020] The present invention adopts the preprocessing process of "convolution filter and Gaussian filter combination + Ostu method + morphological operation", which is designed according to the morphological and spectral characteristics of kidney bean seeds. By finding the wavelength with the largest difference in reflectance between the background and seed area, targeted filtering is performed to more efficiently remove noise and retain spectral characteristics. After preprocessing, the spectral curve has higher discrimination (such as Figure 4 ), providing a high-quality data foundation for subsequent modeling.
[0021] The present invention uses the two-step successive projection method (SPA) to extract characteristic wavelengths from the original average spectrum, screening out 40 characteristic wavelengths, which only account for 13.3% of the total number of wavelengths. The running time is reduced by 129s, a reduction of nearly 31%, which greatly reduces the complexity of the model and improves the extraction efficiency.
[0022] This paper proposes the use of a multi-scale spectral attention residual network (MSARN) model for bean seed viability detection. The multi-head attention mechanism is used to effectively capture the multi-scale features in spectral data, and the gradient vanishing problem is avoided through residual connections, effectively improving the accuracy and generalization ability of the model classification.
[0023] The present invention combines multiple technical means such as hyperspectral imaging technology, image processing, deep learning, and characteristic wavelength extraction to achieve rapid, accurate, and non-destructive intelligent identification and classification of kidney bean seed vitality, providing strong support for kidney bean breeding and large-scale planting. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the specific embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0025] Figure 1 This is a flow chart of intelligent identification and classification provided by the present invention;
[0026] Figure 2 Schematic diagram of the image acquisition system provided by the present invention;
[0027] Figure 3 This is a flow chart of image preprocessing and average spectrum extraction provided by the present invention;
[0028] Figure 4 It is the average spectral curve corresponding to four aging degrees among the five varieties of kidney bean seeds provided by the present invention;
[0029] Figure 5It is a structural diagram of the MSARN model provided by the present invention;
[0030] Figure 6 This is a characteristic wavelength distribution diagram of the multiple characteristic wavelengths extracted provided by the present invention. DETAILED DESCRIPTION
[0031] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the present invention.
[0032] This embodiment provides a method for intelligent detection of bean seed vitality based on hyperspectral and deep learning. Figure 1 As shown, the following steps are included:
[0033] A bean seed hyperspectral image acquisition system (including a hyperspectral imager, a light source system, a sample storage platform, a tripod, an aluminum frame, a black shade cloth, and a computer) was constructed to capture bean seeds of multiple varieties and varying vigor levels, obtaining raw hyperspectral images of the seeds.
[0034] The original hyperspectral image was preprocessed and calibrated into a reflectance image using a gray matter plate. At the wavelength where the reflectance difference between the background and seed region was the largest, the image was sequentially subjected to convolution filtering and Gaussian filtering to remove noise. The image was binarized using the Ostu method, and morphological opening was performed to eliminate small noise and speckles. A seed region mask was generated and a single seed was segmented, and the regional average spectrum was calculated.
[0035] The double successive projection method (SPA) was used to extract characteristic wavelengths from the original average spectrum. Initial characteristic wavelengths related to vitality were first screened from all wavelengths, and then redundant wavelengths were further eliminated to finally obtain characteristic wavelengths that were more relevant to bean seed vitality.
[0036] The architecture of the Multi-scale Spectral Attention Residual Network (MSARN) is:
[0037] The input consists of four parallel CNN networks (named CNN1 to CNN4). The input spectral vector is divided into four scales, so the input data of the four CNNs includes spectral band / 8, spectral band / 4, spectral band / 2, and all spectral bands, respectively. CNN1 to CNN4 have the same structure, and each CNN branch contains two consecutive one-dimensional convolution modules (named Conv). Each Conv contains a one-dimensional convolution layer (Conv1d), a batch normalization layer (BN), and a ReLU activation function. The feature results after the convolution of the four CNN branches are then passed to four LSTMs (named LSTM1 to LSTM4).
[0038] MSARN incorporates two residual structures (named Res1 and Res2). Specifically, in each of the four branches described above, the first residual structure (Res1) is added between the CNN output and the LSTM output. These four residuals are then concatenated as the input to the multi-head attention mechanism (Multi-HeadAttention). A second residual structure (Res2) is added between the input and output of Multi-HeadAttention, and the residual of Res2 is fed into a fully connected layer (FC) to output the final vitality level recognition result.
[0039] The output of the final vitality level recognition result is specifically: using SoftMax to convert the result of the output layer into a probability value, and using the label with the highest probability value as the predicted label of the input seed vitality level.
[0040] Constructing the MSARN model specifically includes the following steps:
[0041] The average spectrum after extracting the characteristic wavelength is divided into a training set, a validation set and a test set; the training set is a collection of training samples of kidney bean seeds of various vigor levels; the validation set is a collection of validation samples of kidney bean seeds of various vigor levels; the test set is a collection of test samples of kidney bean seeds of various vigor levels; the average spectrum of kidney bean seeds of different vigor levels in all varieties is randomly divided into training samples, validation samples and test samples in a ratio of 7:2:1.
[0042] The characteristic wavelength of the original average spectrum was used as input, and the true vigor grade label of the seed sample was used as output. The model was trained using the training set data, and parameters were tuned according to the detection performance of the model on the validation set (specifically, in the two Conv1d of MSARN, the convolution kernel size was 1×3, the stride was 1, the padding was 1, and the output channels were 32 and 64 respectively; the hidden layer dimension of each LSTM network was set to 128, and dropout with p=0.5 was used for regularization). The trained classification model was then used to detect bean seeds of different vigors in the test set.
[0043] The present invention also provides the following specific embodiments:
[0044] Example 1
[0045] 1. Sample Preparation. The beans used in this experiment were seeds from five varieties of beans, including "Purple Crown," "Green Crown," "Green Crown," "Green Crown," "Green Crown," and "Xia Crown," provided by the Horticulture Research Laboratory of the College of Modern Agriculture and Ecology and Environment at Heilongjiang University. A total of 4,000 seeds were selected, 800 of each variety. All seeds were stored at room temperature before the experiment.
[0046] Artificial aging experiments can manipulate the degree of seed aging and yield relatively objective experimental data. In this study, 800 seeds of each variety were divided equally into four groups (200 seeds each) and placed in four nylon bags labeled AA0, AA2, AA4, and AA6. Group AA0 served as the control group, while the other three groups underwent accelerated aging. The aging times for AA0 to AA6 were 0, 2, 4, and 6 days, respectively. The aging experiments were conducted in an artificial climate chamber set at 45°C and 80% relative humidity. On the first day, all 15 bags of seeds (AA2, AA4, and AA6 samples from the five varieties) were placed in the chamber. Samples were removed from the bags every two days, following the order of the bags' labels, until all seeds were removed on the sixth day, marking the end of the aging experiment. To eliminate the effects of uneven moisture distribution, each sample was air-dried at room temperature for one day to equilibrate moisture content before hyperspectral data acquisition.
[0047] 2. Collect sample images; build a hyperspectral image acquisition system for kidney bean seed samples. Figure 2 As shown in the figure, the system consists of a hyperspectral imager, a light source system, a sample storage table, a tripod, an aluminum frame, a black light shielding cloth, and a computer, as follows:
[0048] (1) Hyperspectral imager: The HY-6010 near-infrared portable hyperspectral imager is used. The spectral resolution of this imager is greater than 2.8 nm, and it can obtain spatial information with 300 wavelengths and 480 pixels × 543 pixels in the range of 396.77206 to 1031.88454 nm.
[0049] (2) Light source system: It consists of four 75W halogen lamps, placed at the top corners of the aluminum frame. By adjusting the incident angle of the halogen lamp, the light can be evenly illuminated to the sample to reduce the adverse effects of light source brightness and shadows on the experimental results;
[0050] (3) Sample stage: a white base plate is placed on a black alumina stage;
[0051] (4) Tripod: Placed in the center of the aluminum frame, the hyperspectral imager is placed on the tripod to ensure that the imager remains stable and prevents shaking during the shooting process;
[0052] Sample stage: Using white PVB light-absorbing background board can effectively reduce the impact of reflection and background color on the quality of the captured image;
[0053] (5) Aluminum frame: Made of solid aluminum material, the frame size is 120cm×120cm×160cm, which can accommodate experimental instruments and samples, ensuring the independence of the collection environment and reducing the influence of external factors;
[0054] (6) Black blackout cloth: A special blackout cloth with a shading rate of 99% is used to cover the outside of the aluminum frame. It can block external light interference, ensure the stability and consistency of the shooting environment, and thus improve the quality and stability of the image;
[0055] (7) Computer: The hyperspectral imager is connected to a computer via a USB 3.0 interface, which allows the collected hyperspectral images to be transferred to the computer for storage and processing. The hyperspectral image data were processed using Pycharm and Matlab software on the computer, including image preprocessing, extraction of the average spectrum of kidney bean seeds, extraction of characteristic wavelengths, and model building.
[0056] After the acquisition system is built, hyperspectral image acquisition is carried out; the specific process is as follows:
[0057] (1) The seeds were randomly divided into 200 groups according to their variety and vitality level, with 20 seeds in each group;
[0058] (2) Place a group of 20 bean seeds on the sample holder each time, i.e., each hyperspectral image contains 20 bean seeds;
[0059] (2) Adjust the focal length and aperture of the hyperspectral imager and the irradiation angle of the halogen lamp to obtain a clear hyperspectral image of the seeds with less shadows;
[0060] (3) Collect the original hyperspectral images of all kidney bean seeds in groups, and number each seed according to "variety name + aging time + group number + sequence number". Among them, "Purple Crown", "Emerald Crown", "Green Crown", "Green Crown", and "Sunset Crown" correspond to 0 to 4 respectively; AA0, AA2, AA4, and AA6 correspond to 0 to 3 respectively.
[0061] 3. Standard Germination Test: After aging bean seeds under high temperature and high humidity, their internal substances deteriorate. To examine the effects of artificially accelerated aging on bean seeds, hyperspectral images of four aged bean seeds were collected. Germination tests were then conducted according to GB / T 3543.4—1995, Regulations for the Inspection of Crop Seeds, Germination Test. All seeds were disinfected with a 0.1% sodium hypochlorite solution, rinsed with distilled water, and then dried with filter paper. The seeds were then placed sequentially in the absorbent sponge compartments of a germination box. The germination boxes were placed in a 25°C climate chamber in the dark for germination. For this study, the second day after seed placement was considered the first day. Seed germination was observed daily, all seeds were rinsed, and any deteriorated seeds were removed. Water was added to ensure the sponge remained moist. Germination rates were calculated after seven days. The germination rates for the bean seeds are shown in Table 1.
[0062] As shown in Table 1, the germination rates of the five seed varieties decreased to varying degrees with increasing aging time, and the germination rates of the seeds at the four aging levels varied significantly. This suggests that artificially accelerated aging is feasible for producing samples of kidney bean seeds with varying vigor. However, treated seeds are less likely to produce vigorous seedlings under suitable germination conditions.
[0063] Table 1 Germination rate of kidney bean seeds
[0064]
[0065]
[0066] 4. Perform image preprocessing on the collected hyperspectral images and extract the average spectrum of the seeds. Figure 3The following is a flowchart for image preprocessing and average spectrum extraction. First, the original hyperspectral image was calibrated to a reflectance image using a gray matter plate. The reflectance difference between the background and seed regions in the image was compared, and the wavelength with the maximum reflectance difference was found. The image was then subjected to convolution filtering and Gaussian filtering at the 18th wavelength (439.6936 nm) to remove noise. The image was then binarized using the Ostu method. A morphological opening operation was then used to remove small noise and speckles, resulting in an image mask. The mask was then inverted, with the background set to "0" and the seed region set to "1." The outline of a single seed was obtained from the mask, and a 70×70 pixel rectangular box was set to segment the seed. The single bean seed region was considered the useful region. Finally, the mean of all pixels in this region at each wavelength was calculated to form the average spectrum curve.
[0067] According to the above average spectrum extraction process, the average spectra of five varieties of kidney bean seeds were extracted respectively. Figure 4 The average spectral curves corresponding to four aging degrees of the five varieties of bean seeds are shown, as well as the average spectral curves of all samples after the five varieties are mixed. These spectral curves all show similar trends and have peaks and troughs in similar positions, which may be related to the similar chemical composition inside the seeds. There are troughs in the range of 400-550nm, mainly because this band is related to various pigments in the seed coat and the starch content inside the seeds. The peaks and troughs at 850-950nm are related to the third overshoot vibration of the CH bond in the protein inside the seeds. The peak at 950-980nm may be due to the combined effect of the OH secondary overtone produced by carbohydrates and water. In addition, there are certain differences in the spectral reflectance of bean seeds with different aging degrees, which is due to the change in the content of their internal chemical components after aging. After aging, the moisture content of bean seeds usually decreases, causing the seeds to become dry, and the starch and protein content may also decrease, causing the optical density of the seeds to change, resulting in light being more easily reflected and reducing the ability to absorb light. According to Figure 4 It can also be seen that as the number of days of seed aging increases, the spectral reflectance also increases, which is consistent with the analysis of the influence of content changes. Most of the average spectra can be distinguished visually, indicating that the present invention has a high feasibility of using the vitality level classification of kidney bean seeds. Figure 4 For the Ziguan variety shown in a), the spectral reflectance differences between seeds of varying vigor are small, making visual distinction unreliable. Therefore, a discriminant analysis model is necessary to accurately identify seeds of varying vigor.
[0068] 5. Divide the dataset: Collect hyperspectral image samples of various varieties at different aging levels and randomly divide the average spectra of bean seeds of all varieties at different vigor levels into training, validation, and test samples in a ratio of 7:2:1. All training samples are combined to form the training set, all validation samples are combined to form the validation set, and all test samples are combined to form the test set. At this point, the training set contains 2800 average spectral samples, the validation set contains 800 average spectral samples, and the test set contains 400 average spectral samples.
[0069] 6. Training model. The training set data is used as the input of the model, and the four different vitality level labels corresponding to the predicted training set data are used as the output to preliminarily establish the detection model. The detection model is the Multi-Scale Spectral Attention Residual Network (MSARN), and its model structure is as follows: Figure 5 As shown in the figure, since the hyperspectral image data collected by the present invention contains 300 spectral wavelengths, the number of spectral inputs for the four scale networks in the MSARN model is 37, 75, 150, and 300, respectively. The established detection model was then parameter-tuned using the validation set data. The learning rate of the MSARN model was set to 0.0002, the weight decay was set to 0.001, the batch size was set to 32, and the softmax was optimized using the Adam algorithm.
[0070] 7. Spectral Preprocessing: The raw average spectral data for the training, validation, and test sets were preprocessed using first-order differences (1D), second-order differences (2D), smoothing (SG), detrending correction (DET), multivariate scatter correction (MSC), and standard normal transformation (SNV). The performance of the MSARN model using different preprocessing methods is shown in Table 2. The results show that the MSARN model without preprocessing the raw spectra achieved the best performance on the test set, with classification accuracy, precision, recall, and F1 of 99.75%, 99.79%, 99.76%, and 99.76%, respectively.
[0071] Table 2 Performance of MSARN model under different preprocessing methods
[0072]
[0073] 8. Characteristic wavelength extraction: Using the successive projection method (SPA), competitive adaptive weighted sampling method (CARS) and their combination, the characteristic wavelength that is most sensitive to the vitality of kidney bean seeds is selected. The characteristic wavelength distribution is as follows: Figure 6The above characteristic wavelengths were used as model inputs to train, validate, and test the MSARN model. The accuracy of the MSARN model on the test set is shown in Table 3. The results show that the MSARN model based on the characteristic wavelengths extracted using CARS and two SPA algorithms achieved the best accuracy of 98.75% on the test set. Taking all factors into consideration, the two SPA algorithms only screened out 40 characteristic wavelengths, representing only 13.3% of the total number of wavelengths. This reduced the runtime by 129 seconds, a nearly 31% reduction, significantly reducing the model's complexity.
[0074] Table 3 Accuracy of the MSARN model on the test set
[0075] Characteristic wavelength extraction method Number of characteristic wavelengths Test set accuracy (%) Full wavelength 300 99.75 SPA 55 98.50 CARS 147 98.75 CARS+CARS 80 98.00 CARS+SPA 56 98.50 SPA+CARS 45 98.00 SPA+SPA 40 98.75
[0076] Table 4 Identification results of seed vigor grades of different bean varieties
[0077]
[0078] 9. Vitality Identification of Single Variety Seeds. The above steps were implemented using a mixed dataset of multiple varieties. The performance of the SPA-SPA-MSARN model was now validated using five single bean variety datasets: "Purple Crown," "Cui Crown," "Green Crown," "Green Crown," "Green Crown," and "Xia Crown." Each variety dataset was divided into training, validation, and test sets in a 7:2:1 ratio, with 560, 160, and 80 samples, respectively.
[0079] The results of seed vigor grade recognition for different bean varieties are shown in Table 4. The experimental results show that the MSARN model has a 100% accuracy rate in identifying seed vigor grades for four varieties of bean, demonstrating strong robustness and generalization capabilities.
[0080] Example 2
[0081] 1. Steps 1-5 are the same as steps 1-5 in Example 1.
[0082] 2. A support vector machine model (SVM) is established based on the training set samples. The model parameters are tuned according to the validation set results. The kernel function is finally determined to be the linear kernel function "linear" and the penalty coefficient C is 0.1.
[0083] 3. Six spectral preprocessing methods were used to process the original spectra. The performance of the SVM model under different preprocessing methods is shown in Table 5. The results show that after SG preprocessing, the SVM model achieved the best performance on the test set, with classification accuracy, precision, recall rate and F1 of 96.00%, 96.01%, 96.00% and 96.00% respectively.
[0084] Table 5 SVM model performance under different preprocessing methods
[0085]
[0086]
[0087] 4. SPA, CARS, and a combination of the two were used to extract characteristic wavelengths from the spectral data after SG preprocessing. These characteristic wavelengths were used as model input to train, validate, and test the SVM model. The accuracy of the SVM model on the test set is shown in Table 6. The results show that the SVM model based on the characteristic wavelengths extracted after two CARS applications achieved the best accuracy of 97.25% on the test set.
[0088] Table 6 Accuracy of SVM model on the test set
[0089] Characteristic wavelength extraction method Number of characteristic wavelengths Test set accuracy (%) Full wavelength 300 97.00 SPA 55 96.50 CARS 147 96.75 CARS+CARS 80 97.25 CARS+SPA 56 96.75 SPA+CARS 45 95.75 SPA+SPA 40 96.25
[0090] Example 3
[0091] 1. Steps 1-5 are the same as steps 1-5 in Example 1.
[0092] 2. Build a K-nearest neighbor model (KNN) for the training set samples. Optimize the model parameters based on the validation set results. Finally, determine the number of nearest neighbor samples K as 5 and select "distance" as the weight.
[0093] 3. Six spectral preprocessing methods were used to process the original spectra. The performance of the KNN model under different preprocessing methods is shown in Table 7. The results show that after 1D preprocessing, the KNN model achieved the best performance on the test set, with classification accuracy, precision, recall, and F1 of 82.00%, 82.15%, 82.00%, and 81.89%, respectively.
[0094] 4. SPA, CARS, and a combination of the two were used to extract characteristic wavelengths from the spectral data after 1D preprocessing. These characteristic wavelengths were used as model input to train, validate, and test the KNN model. The accuracy of the KNN model on the test set is shown in Table 8. The results show that the KNN model based on the characteristic wavelengths extracted by CARS and SPA achieved the best accuracy of 78.00% on the test set.
[0095] Table 7 KNN model performance under different preprocessing methods
[0096]
[0097] Table 8 Accuracy of KNN model on the test set
[0098]
[0099]
[0100] Comprehensive Examples 1-3, it can be found that the MSARN model classification effect is significantly better than other models, and the accuracy, precision, recall rate and F1 of MSARN all reach the best. At the same time, MSARN has good feature extraction ability, does not need to pre-process the original spectral data, greatly reduces the workload, and traditional machine learning (SVM, KNN) all requires certain pre-processing to improve model performance. By applying two SPAs, useless information can be greatly reduced, the minimum characteristic wavelength is extracted, and MSARN can utilize the minimum characteristic variables to complete the identification of kidney bean seeds with different vigor. While SVN and KNN are weaker in identifying kidney bean seeds with different vigors, KNN has the worst effect. In the vigor identification of single kidney bean varieties, MSARN reaches 100% for the identification accuracy of purple crown, green crown, blue crown and rosy crown. After comparative analysis and comprehensive consideration of actual application, the classification performance of the MSARN model set up in Example 1 is the best, and the identification of kidney bean seed vigor can be accurately and quickly realized.
Claims
1. A method for intelligent detection of bean seed vitality based on hyperspectral and deep learning, characterized in that: The following steps are involved: Photograph bean seeds of multiple varieties and different vitality levels to obtain original hyperspectral images of bean seeds; The original hyperspectral image was preprocessed by combining convolution filtering and Gaussian filtering to remove noise and extract the original average spectrum of kidney bean seeds. The characteristic wavelength is extracted from the original average spectrum using the characteristic wavelength extraction algorithm; A multi-scale spectral attention residual network (MSARN) detection model was constructed. The average spectrum was divided into multiple scales by band. Multi-scale features were extracted through a parallel convolutional network. After fusion through residual connection and multi-head attention mechanism, the final vitality level recognition results of different bean seeds were output.
2. The intelligent detection method for kidney bean seed vitality based on hyperspectral and deep learning according to claim 1 is characterized in that: The method of photographing multiple varieties of kidney bean seeds with different vitality levels specifically comprises the following steps: Construct a hyperspectral image acquisition system for kidney bean seeds, including a hyperspectral imager, a light source system, a sample storage platform, a tripod, an aluminum frame, a black shade cloth, and a computer. The hyperspectral imager is used to capture the characteristics of kidney bean seeds to obtain an original hyperspectral image; The light source system is composed of multiple halogen lamps and is used to provide uniform and sufficient light to the hyperspectral imager to ensure that the brightness and darkness on the original hyperspectral image are balanced and the details of the measured object are accurately presented; The sample storage platform is used to place bean seeds to ensure that the bean seeds remain stable during the shooting process; The tripod is used to carry the hyperspectral imager to ensure that the imager is installed in a fixed position and remains stable during the shooting process; The aluminum frame is used to place the hyperspectral imager, light source system, sample storage table and tripod, etc., to ensure the independent collection environment and reduce the influence of external factors; The black blackout cloth is covered on the outside of the aluminum frame to create an interference-free shooting environment to prevent interference from external light; The computer is used to control the hyperspectral imager, process the original hyperspectral image, and perform feature extraction; A certain number of bean seeds were placed on the sample holder, and the focus and aperture of the hyperspectral imager, as well as the irradiation angle of the halogen lamp, were adjusted to obtain clear hyperspectral images of the seeds with less shadows. The original images of all kidney bean seeds were collected group by group, and each seed was numbered according to "variety name + aging time + group number + serial number".
3. The intelligent detection method for bean seed vitality based on hyperspectral and deep learning according to claim 1 is characterized in that: The image preprocessing of the original hyperspectral image specifically includes the following steps: The original hyperspectral image is calibrated into a reflectance image using a gray matter plate; At the wavelength where the difference in reflectance between the background and seed area is the largest, the image is sequentially subjected to convolution filtering and Gaussian filtering to remove noise; The image was binarized using the Ostu method, and morphological opening was used to eliminate small noise and small spots. A seed region mask was generated and a single seed was segmented. The regional average spectrum was calculated.
4. The method for intelligent detection of bean seed vitality based on hyperspectral and deep learning according to claim 1, characterized in that: The characteristic wavelength extraction algorithm is used to extract the characteristic wavelengths in the original average spectrum, which specifically includes the following steps: the characteristic wavelengths in the original average spectrum are extracted using the two-step successive projection method (SPA), the initial characteristic wavelengths related to vitality are first screened from the full wavelengths, and then the redundant wavelengths are further eliminated, and finally the characteristic wavelengths that are more relevant to the vitality of kidney bean seeds are obtained.
5. The method for intelligent detection of bean seed vitality based on hyperspectral and deep learning according to claim 1, characterized in that: The architecture of the Multi-Scale Spectral Attention Residual Network (MSARN) model includes: The input layer contains four parallel CNN networks, which divide the spectral data into four scales according to the number of bands (spectral band / 8, spectral band / 4, spectral band / 2, and full band); Multi-scale convolutional branches, each CNN branch contains two consecutive one-dimensional convolution modules (Conv); Residual connection structure, with residual connections (Res1, Res2) set between CNN output and LSTM output, and between the input and output of the multi-head attention mechanism; The output layer (FC) receives the residual result of Res2 and outputs the final vitality level recognition result.
6. The method for intelligent detection of bean seed vitality based on hyperspectral and deep learning according to claim 5, characterized in that: The output of the final vitality level recognition result is specifically: using SoftMax to convert the result of the output layer into a probability value, and using the label with the highest probability value as the predicted label of the input seed vitality level.
7. The method for intelligent detection of bean seed vitality based on hyperspectral and deep learning according to any one of claims 1 to 6, characterized in that: Constructing the MSARN model specifically includes the following steps: The average spectrum after extracting the characteristic wavelength is divided into a training set, a validation set and a test set; the training set is a set of training samples of kidney bean seeds of various vigor levels; the validation set is a set of validation samples of kidney bean seeds of various vigor levels; and the test set is a set of test samples of kidney bean seeds of various vigor levels; The average spectra of common bean seeds of different vigor levels in all varieties were randomly divided into training samples, validation samples and test samples in proportion.
8. The method for intelligent detection of bean seed vitality based on hyperspectral and deep learning according to claim 7, characterized in that: Constructing the MSARN model specifically includes the following steps: The characteristic wavelength of the original average spectrum is used as input, and the true vigor grade label of the seed sample is used as output. The model is trained using the training set data, and the parameters are tuned according to the detection performance of the model on the validation set to obtain a trained classification model, which is used to detect bean seeds with different vigors in the test set.
9. The method for intelligent detection of bean seed vitality based on hyperspectral and deep learning according to claim 8, characterized in that: The parameter tuning specifically includes: in the two Conv1d of MSARN, the convolution kernel size is 1×3, the stride is 1, the padding is 1, and the output channels are 32 and 64 respectively; the hidden layer dimension of each LSTM network is set to 128, and dropout with p = 0.5 is used for regularization.