Method and system for online sorting of peanut seed quality

By using online monitoring and adaptive updates to the peanut seed sorting model, the problem of decreased sorting accuracy caused by feature drift was solved, achieving efficient and stable sorting without human intervention, and improving production efficiency and automation level.

CN121684738BActive Publication Date: 2026-05-12NANCHONG ACAD OF AGRI SCI +2
View PDF 4 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
NANCHONG ACAD OF AGRI SCI
Filing Date
2026-02-10
Publication Date
2026-05-12

AI Technical Summary

Technical Problem

Existing peanut seed sorting technology suffers from decreased sorting accuracy due to feature drift during long-term, multi-batch continuous production, requiring frequent shutdowns for manual labeling and model retraining, which affects production efficiency and automation level.

Method used

An initial image set of peanut seeds is obtained online, a feature vector set is generated, and an initial sorting model is trained. Feature drift is monitored in real time, and a high-confidence feature subset is selected for model updates to generate an updated sorting model, which is then applied to the subsequent sorting process.

Benefits of technology

It achieves adaptive feature drift without human intervention, maintains sorting accuracy, reduces downtime for maintenance, and improves production efficiency and automation level.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121684738B_ABST
    Figure CN121684738B_ABST
Patent Text Reader

Abstract

The application discloses a peanut seed quality online sorting method and system, relates to the technical field of agricultural product sorting automation, and discloses the peanut seed quality online sorting method and system, which solves the problem of sorting precision reduction caused by feature drift by detecting feature drift and automatically updating a model, has the ability of self-adaptive feature drift detection and model updating, automatically maintains sorting precision in a continuous production process, reduces downtime maintenance time, and improves production efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of automated sorting technology for agricultural products, and in particular to a method and system for online sorting of peanut seed quality. Background Technology

[0002] Currently, peanut seed sorting primarily relies on machine vision technology to construct static classification models, using image feature analysis to determine quality. However, in actual industrial production environments, peanut seeds, as natural biological materials, exhibit dynamic changes in their appearance. Different varieties of peanut seeds possess inherent differences in color saturation, surface texture roughness, and reflectivity. Simultaneously, seasonal changes in production lead to variations in seed maturity distribution, humidity fluctuations during storage cause gradual changes in skin color, and random fluctuations in the intensity and angle of ambient light on the production line further exacerbate the instability of image features. These factors collectively cause a systematic shift in the distribution of visual feature data input to the model over time, resulting in a continuously evolving feature drift phenomenon. Static models, unable to adapt to these distributional changes, cause the classification decision boundary to gradually deviate from the true quality threshold. Specifically, the proportion of high-quality seeds incorrectly rejected or low-quality seeds incorrectly retained continues to rise. To address this problem, existing sorting equipment must interrupt continuous production processes, recollect large numbers of samples, and rely on manual quality labeling, followed by hours of model retraining and deployment. This periodic downtime for maintenance not only significantly reduces the effective operating time of the production line, but also introduces new uncertainties due to subjective differences in manual labeling, severely restricting the automated operation capability and long-term stability of the sorting system. Especially in large-scale seed processing scenarios spanning multiple seasons, the cumulative effect of feature drift causes an irreversible decline in sorting accuracy, making it difficult for existing technological frameworks to achieve adaptive quality control under unattended conditions.

[0003] The above content is only used to help understand the technical solution of this application and does not represent an admission that the above content is prior art. Summary of the Invention

[0004] The main purpose of this application is to provide an online sorting method and system for peanut seeds, which aims to reduce downtime and maintenance time and improve production efficiency.

[0005] To achieve the above objectives, this application proposes an online sorting method for peanut seeds, the method comprising:

[0006] An initial image set of peanut seeds is obtained; feature extraction processing is performed on the initial image set to generate a first feature vector set; and statistical parameters of the first feature vector set are calculated to generate first baseline distribution data; manually labeled quality label data corresponding to the first feature vector set is obtained; and an initial sorting model is trained based on the first feature vector set and the quality label data.

[0007] Collect online images of peanuts to be sorted, perform feature extraction processing on the online images, and generate online feature vectors;

[0008] The online feature vector is input into the current sorting model for prediction processing to generate real-time quality prediction results and corresponding prediction confidence data; based on the real-time quality prediction results, sorting control commands are generated to control the sorting execution mechanism to perform corresponding actions;

[0009] After running continuously for a preset period of time, the online feature vectors corresponding to all sorted peanuts within the preset period of time are obtained, and they are summarized and processed to construct the feature set of the current period of time. The statistical parameters of the feature set of the current period of time are calculated to generate the current feature distribution data.

[0010] Calculate the difference between the first baseline distribution data and the current feature distribution data to generate feature drift index data;

[0011] The feature drift index data is compared with a preset drift threshold. If the feature drift index data exceeds the drift threshold, a model update process is triggered. The model update process includes:

[0012] Based on the current time period feature set and the corresponding prediction confidence data, a filtering process is performed to generate a high-confidence feature subset and corresponding prediction quality label data;

[0013] Based on the high-confidence feature subset, the first baseline distribution data is updated to generate the second baseline distribution data;

[0014] Based on the high-confidence feature subset and the corresponding predicted quality label data, the parameters of the current sorting model are fine-tuned to generate the first updated sorting model.

[0015] The second baseline distribution data and the first updated sorting model are then applied to the subsequent real-time sorting process.

[0016] In one embodiment, the step of performing feature extraction processing on the initial image set to generate a first feature vector set includes:

[0017] For a single image in the initial image set, its color space is converted, and a histogram of pixel values ​​on the target color channel is calculated to generate color distribution feature data.

[0018] For a single image in the initial image set, a local binary mode operator is used to traverse the pixels and their neighborhoods in the image. A binary mode is generated by comparing the gray values ​​of the neighboring pixels with the center pixel. The binary mode histogram of all pixels is then calculated to generate texture feature data.

[0019] For a single image in the initial image set, the outline of the seed is determined by edge detection, and the aspect ratio and area duty cycle of its bounding rectangle are calculated based on the outline to generate shape feature data.

[0020] The color distribution feature data, the texture feature data, and the shape feature data are concatenated to form the multi-dimensional visual features of the seed, resulting in the first feature vector; the first feature vectors of all seeds are then collected to obtain the first feature vector set.

[0021] In one embodiment, the step of calculating the difference between the first baseline distribution data and the current feature distribution data to generate feature drift index data includes:

[0022] The first benchmark mean vector and the first benchmark covariance matrix are obtained by parsing from the first benchmark distribution data; the current mean vector and the current covariance matrix are obtained by parsing from the current feature distribution data;

[0023] Based on the first benchmark covariance matrix, its inverse matrix is ​​calculated to generate the first inverse matrix data;

[0024] The feature drift index data is calculated based on the first baseline mean vector, the current mean vector, the first inverse matrix data, and the current covariance matrix.

[0025] In one embodiment, the step of performing a filtering process based on the current time period feature set and the corresponding prediction confidence data to generate a high-confidence feature subset and corresponding prediction quality label data includes:

[0026] Based on the statistical characteristics of the feature set of the current time period in the current feature distribution data, a pre-trained screening model is constructed; the online feature vectors in the feature set of the current time period are input into the pre-trained screening model to generate the membership score corresponding to each online feature vector;

[0027] The membership score is compared with the predicted confidence data of the corresponding online feature vector, and online feature vectors with membership scores higher than the first screening threshold and predicted confidence data higher than the second screening threshold are retained to form a preliminary screening set;

[0028] For each online feature vector retained in the initial screening set, its corresponding real-time quality prediction result is appended as the predicted quality label of the online feature vector, thereby obtaining the high-confidence feature subset and the corresponding predicted quality label data.

[0029] In one embodiment, the step of inputting online feature vectors from the current time period feature set into the pre-trained screening model to generate a membership score corresponding to each online feature vector includes:

[0030] Using the current time period feature set as input data, a portion of the feature subspace is randomly extracted.

[0031] In the extracted feature subspace, features and their segmentation values ​​are recursively and randomly selected to construct multiple binary tree structures;

[0032] For any online feature vector in the feature set of the current time period, calculate the path length from the root node to the leaf node in each binary tree structure;

[0033] Based on the average path length of the online feature vector across all binary tree structures, the corresponding membership score is obtained through mapping.

[0034] In one embodiment, the step of updating the first baseline distribution data based on the high-confidence feature subset to generate the second baseline distribution data includes:

[0035] Calculate the mean of all online feature vectors within the high-confidence feature subset to generate candidate mean vectors; calculate their covariance to generate candidate covariance matrices.

[0036] Read the first benchmark mean vector and the first benchmark covariance matrix from the first benchmark distribution data;

[0037] The first baseline mean vector and the candidate mean vector are weighted and summed, wherein the weight of the candidate mean vector is a preset learning rate, and the weight of the first baseline mean vector is one minus the learning rate. The summation result is the second baseline mean vector.

[0038] The first benchmark covariance matrix and the candidate covariance matrix are weighted and fused using the same weighting strategy to obtain the second benchmark covariance matrix.

[0039] The second benchmark mean vector is combined with the second benchmark covariance matrix to generate the second benchmark distribution data.

[0040] In one embodiment, the step of fine-tuning the parameters of the current sorting model to generate a first updated sorting model based on the high-confidence feature subset and the corresponding predicted quality label data includes:

[0041] The high-confidence feature subset is input into the pre-trained current sorting model to perform a forward propagation, and the importance weight distribution data of each model parameter for correctly predicting the high-confidence feature subset is obtained.

[0042] Based on the importance weight distribution data, a regularized constraint loss function is constructed;

[0043] The high-confidence feature subset and its corresponding predicted quality label data are used as training data. Combined with the regularized constraint loss function, the first updated sorting model is generated by iteratively updating the model parameters.

[0044] In one embodiment, the step of inputting the high-confidence feature subset into a pre-trained current sorting model to perform a forward propagation to obtain the importance weight distribution data of each model parameter for correctly predicting the high-confidence feature subset includes:

[0045] For each online feature vector in the high-confidence feature subset, calculate the gradient of the loss function of the model output layer on that online feature vector after it passes through the current sorting model;

[0046] Based on the gradient of the online feature vector, the expected value of the squared gradient of all online feature vectors corresponding to each model parameter is calculated to obtain the importance estimate of the model parameter;

[0047] The importance estimates of all model parameters are normalized to obtain the importance weight distribution data.

[0048] In one embodiment, the step of generating sorting control commands based on real-time quality prediction results to control the sorting actuator to perform corresponding actions includes:

[0049] When the real-time quality prediction result is lower than the preset threshold, the external size data and surface smoothness estimation data are obtained by parsing the online feature vector corresponding to the peanut to be sorted.

[0050] Based on pre-stored empirical correspondences, the pressure value of the high-speed airflow and the adjustment amount of the injection duration are dynamically calculated according to the external dimension data and the surface smoothness estimation data.

[0051] Based on the calculated pressure value and the adjustment amount of the injection duration, the sorting control command containing specific action parameters is generated.

[0052] Furthermore, to achieve the above objectives, this application also proposes an online peanut seed quality sorting system, which includes: a memory, a processor, and an online peanut seed quality sorting program stored in the memory and executable on the processor. The online peanut seed quality sorting program is configured to implement the steps of the online peanut seed quality sorting method described above.

[0053] The online peanut seed quality sorting method and system proposed in this application solves the problem of decreased sorting accuracy caused by feature drift by detecting feature drift online and automatically updating the model. It has adaptive feature drift detection and model update capabilities, automatically maintains sorting accuracy during continuous production, reduces downtime maintenance time, and improves production efficiency. Attached Figure Description

[0054] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0055] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0056] Figure 1 This is a flowchart illustrating an embodiment of the online peanut seed quality sorting method of this application.

[0057] Figure 2 This is a schematic diagram of a structure provided for an embodiment of the online peanut seed quality sorting system of this application.

[0058] Explanation of icon numbers:

[0059] 10. Memory; 20. Processor.

[0060] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0061] The technical solutions of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. The components of this application described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of this application, but merely represents selected embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.

[0062] It should be understood that similar reference numerals and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. Furthermore, in the description of this application, the terms "first," "second," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0063] Existing machine vision-based online peanut seed sorting technology suffers from "feature drift" in long-term, multi-batch continuous production scenarios. Changes in the external characteristics of peanut seeds cause a shift in the statistical distribution of the model's input features. This makes the pre-trained model unable to adapt to the new data distribution, leading to boundary failures and reduced sorting accuracy, as well as increased false rejection and false retention rates. Current technologies require frequent downtime, sample re-collection, and manual annotation to train new models, impacting production efficiency and the level of continuous automation of the sorting line.

[0064] Based on this, the embodiments of this application provide an online sorting method for peanut seed quality, referring to... Figure 1 The online sorting method for peanut seeds includes steps S100 to S600, wherein:

[0065] Step S100: Obtain an initial image set of peanut seeds, perform feature extraction processing on the initial image set to generate a first feature vector set, and calculate the statistical parameters of the first feature vector set to generate first baseline distribution data; obtain manually labeled quality label data corresponding to the first feature vector set, and train an initial sorting model based on the first feature vector set and the quality label data.

[0066] Step S200: Acquire online images of peanuts to be sorted, perform feature extraction processing on the online images, and generate online feature vectors;

[0067] Step S300: Input the online feature vector into the current sorting model for prediction processing to generate real-time quality prediction results and corresponding prediction confidence data; Based on the real-time quality prediction results, generate sorting control commands to control the sorting execution mechanism to perform corresponding actions;

[0068] Step S400: After running continuously for a preset period of time, obtain the online feature vectors corresponding to all sorted peanuts within the preset period of time, summarize and process them to construct the feature set of the current period of time, and calculate the statistical parameters of the feature set of the current period of time to generate the current feature distribution data.

[0069] Step S500: Calculate the difference between the first baseline distribution data and the current feature distribution data, and generate feature drift index data;

[0070] Step S600: Compare the feature drift index data with a preset drift threshold. If the feature drift index data exceeds the drift threshold, trigger the model update process. The model update process includes:

[0071] Based on the current time period feature set and the corresponding prediction confidence data, a filtering process is performed to generate a high-confidence feature subset and corresponding prediction quality label data;

[0072] Based on the high-confidence feature subset, the first baseline distribution data is updated to generate the second baseline distribution data;

[0073] Based on the high-confidence feature subset and the corresponding predicted quality label data, the parameters of the current sorting model are fine-tuned to generate the first updated sorting model.

[0074] The second baseline distribution data and the first updated sorting model are then applied to the subsequent real-time sorting process.

[0075] In this embodiment, the initial image set refers to a batch of representative peanut seed image data collected before the sorting system is put into operation to establish an initial model. This image set typically contains samples of different quality levels for initial model training. Feature extraction processing refers to extracting numerical information that can characterize the quality attributes of peanut seed images from the images using image processing algorithms. This information can be visual features such as color, texture, and shape. The first feature vector set refers to the set formed by combining multiple extracted feature values ​​into a vector after feature extraction from each image in the initial image set, and then aggregating the feature vectors of all images. This set is the input data for initial model training. Statistical parameters refer to numerical values ​​used to describe the distribution characteristics of the data set, such as mean, variance, and covariance. These parameters can quantify the central tendency and dispersion of the feature data. The first baseline distribution data is reference data used to characterize the initial peanut seed feature distribution, obtained by calculating the statistical parameters of the first feature vector set. This data serves as the benchmark for subsequent feature drift detection.

[0076] In this embodiment, the quality label data consists of manually determined peanut seed quality grade information corresponding to each feature vector in the first feature vector set. These labels are the actual outputs of the model trained in supervised learning. The initial sorting model refers to the algorithm model trained based on the first feature vector set and the quality label data, used for preliminary classification or regression prediction of peanut seed quality. This model undertakes the sorting task in the early stages of system operation. Online images refer to images of peanuts to be sorted that are acquired in real time by a visual sensor during the actual operation of the sorting system. Online feature vectors refer to the numerical feature representation obtained after feature extraction from the real-time acquired online images. This vector represents the visual attributes of the peanuts currently to be sorted. The current sorting model refers to the sorting model currently in use during real-time sorting. This model can be the initial sorting model or an updated model. The real-time quality prediction result refers to the peanut seed quality grade or score output by the current sorting model after predicting the online feature vectors.

[0077] In this embodiment, the prediction confidence data refers to the numerical value output along with the real-time quality prediction result, representing the reliability of the prediction result. A higher confidence level indicates a greater grasp of the prediction result by the model. The sorting control command refers to the control signal generated based on the real-time quality prediction result and sent to the sorting execution mechanism to guide the mechanism in physically sorting peanut seeds. The sorting execution mechanism refers to a mechanical device, such as a valve or robotic arm, that physically separates or processes peanut seeds according to the sorting control command. The preset time period refers to a period of continuous system operation; after this time interval, feature drift detection and model update evaluation are triggered. The current time period feature set refers to the set of online feature vectors corresponding to all sorted peanuts within the preset time period. This set reflects the feature distribution of peanut seeds in the current production batch or time period. The current feature distribution data refers to the data used to characterize the current peanut seed feature distribution, obtained by calculating the statistical parameters of the current time period feature set. The difference is an indicator that quantifies the similarity or difference between two data distributions. A greater difference indicates a greater deviation between the two distributions.

[0078] In this embodiment, the feature drift index data refers to the numerical value obtained by calculating the difference between the first baseline distribution data and the current feature distribution data. This value is used to measure the degree of change in the feature distribution. The drift threshold is a pre-set value; when the feature drift index data exceeds this threshold, it indicates that the feature drift has reached a point where a model update is required. The model update process is a series of operations automatically initiated by the system when the feature drift reaches the preset threshold, aimed at adjusting or retraining the sorting model to adapt to the new feature distribution. The high-confidence feature subset refers to a subset of online feature vectors selected from the current time-period feature set whose prediction results have high confidence (e.g., exceeding the preset confidence threshold). This data is considered reliable and can be used for model updates. The predicted quality label data refers to the quality label predicted by the current sorting model corresponding to each feature vector in the high-confidence feature subset. The second baseline distribution data refers to the new baseline distribution data obtained after updating the first baseline distribution data based on the high-confidence feature subset in the model update process. This data will serve as the new baseline for subsequent feature drift detection. The first updated sorting model refers to the new sorting model obtained by fine-tuning the parameters of the current sorting model based on a high-confidence feature subset and the corresponding predicted quality label data during the model update process. This model will be applied to the subsequent real-time sorting process.

[0079] In this embodiment, the online peanut seed quality sorting method first acquires an initial image set of peanut seeds and performs feature extraction processing on the initial image set to generate a first feature vector set. Subsequently, the statistical parameters of the first feature vector set are calculated to generate first baseline distribution data. Simultaneously, manually labeled quality label data corresponding to the first feature vector set is acquired, and an initial sorting model is trained based on the first feature vector set and the quality label data. For example, the initial image set can consist of images of peanut seeds of different batches and qualities taken manually. Feature extraction can employ simple image processing algorithms, such as calculating the average brightness or color channel average of the image. The statistical parameters of the first feature vector set can include the mean and standard deviation, thus forming the first baseline distribution data. The quality label data can be manually recorded after visual inspection or physical testing. The initial sorting model can be trained using a rule-based decision tree or a linear classifier.

[0080] Furthermore, online images of the peanuts to be sorted are acquired, and feature extraction processing is performed on these images to generate online feature vectors. For example, online images can be obtained by setting a fixed camera on the sorting line and continuously shooting at a fixed frame rate. The generation of online feature vectors can employ methods similar to the initial feature extraction, such as calculating the average brightness of the image.

[0081] In this embodiment, the online feature vector is then input into the current sorting model for prediction processing, generating a real-time quality prediction result and corresponding prediction confidence data. Based on the real-time quality prediction result, a sorting control command is generated to control the sorting execution mechanism to perform corresponding actions. Specifically, the online feature vector is input into the current sorting model, and the model outputs a category label as the real-time quality prediction result, along with a probability value as the prediction confidence data. For example, if the prediction result is "defective," a binary signal is generated as a sorting control command, instructing the sorting execution mechanism (e.g., a mechanical lever) to push the peanut away from the main sorting path.

[0082] In this embodiment, after running continuously for a preset time period, the online feature vectors corresponding to all sorted peanuts within that preset time period are acquired, summarized, and processed to construct the current time period feature set. The statistical parameters of the current time period feature set are then calculated to generate the current feature distribution data. For example, the preset time period can be set to one hour. Within this time period, the online feature vectors of all sorted peanut seeds are stored and aggregated to form the current time period feature set. The statistical parameters of this set, such as the mean and standard deviation, are calculated to generate the current feature distribution data.

[0083] In this embodiment, the difference between the first baseline distribution data and the current feature distribution data is then calculated to generate feature drift index data. This feature drift index data is compared to a preset drift threshold. If the feature drift index data exceeds the threshold, a model update process is triggered. For example, the difference can be calculated by comparing the Euclidean distance between the mean vectors of the two distributions; this distance value is the feature drift index data. When the index data exceeds a preset fixed value, the system automatically starts the model update procedure.

[0084] In this embodiment, the model update process includes: filtering based on the current time-period feature set and the corresponding predicted confidence data to generate a high-confidence feature subset and corresponding predicted quality label data; updating the first benchmark distribution data based on the high-confidence feature subset to generate a second benchmark distribution data; fine-tuning the parameters of the current sorting model based on the high-confidence feature subset and the corresponding predicted quality label data to generate a first updated sorting model; and applying the second benchmark distribution data and the first updated sorting model to the subsequent real-time sorting process. Specifically, a confidence threshold, such as 0.9, can be set, and online feature vectors with predicted confidence higher than the threshold can be selected from the current time-period feature set to form a high-confidence feature subset and its corresponding predicted quality label data. Subsequently, the mean and standard deviation of all feature vectors in the high-confidence feature subset are calculated and directly replace the corresponding parameters in the first benchmark distribution data to form the second benchmark distribution data. Simultaneously, using this high-confidence feature subset and its predicted quality label data as new training samples, a mini-batch gradient descent training is performed on the current sorting model to fine-tune the model's weight parameters, generating the first updated sorting model. Finally, the updated second baseline distribution data is set as the new baseline, and the first updated sorting model is loaded as the new current sorting model for application in subsequent real-time sorting processes.

[0085] In this embodiment, by introducing an online feature drift monitoring and adaptive model update mechanism, the problem of reduced sorting accuracy of a fixed model due to changes in external features during long-term, multi-batch continuous sorting of peanut seeds is solved. This method can sense the shift in feature distribution online and iteratively optimize the baseline distribution and sorting model using high-confidence data. This ensures that the peanut seed sorting system maintains stable sorting accuracy over a long period without manual intervention, thereby improving production efficiency and automation.

[0086] In one feasible implementation, the step of performing feature extraction processing on the initial image set to generate a first feature vector set includes: for a single image in the initial image set, converting its color space and calculating a pixel value histogram on the target color channel to generate color distribution feature data; for a single image in the initial image set, using a local binary mode operator to traverse the pixels and their neighborhoods in the image, generating a binary mode by comparing the gray values ​​of neighboring pixels with the center pixel, and statistically analyzing the binary mode histograms of all pixels to generate texture feature data; for a single image in the initial image set, determining the contour of a seed by edge detection, and calculating the aspect ratio and area occupancy of its bounding rectangle based on the contour to generate shape feature data; concatenating the color distribution feature data, the texture feature data, and the shape feature data to form the multi-dimensional visual features of the seed, obtaining the first feature vector; and collecting the first feature vectors of all seeds to obtain the first feature vector set.

[0087] In this embodiment, for a single image in the initial image set, a color space conversion is performed, and a pixel value histogram on the target color channel is calculated to generate color distribution feature data. Specifically, the image can be converted from the RGB color space to color spaces such as HSV, Lab, or YCbCr. These color spaces can better separate color information from brightness information, thereby improving the robustness of the features. For example, in the HSV color space, pixel value histograms for the H (hue), S (saturation), or V (brightness) channels can be calculated to quantify the color composition and distribution of the image. This is of great significance for identifying color-related quality issues such as the maturity, freshness, or presence of mold in peanut seeds.

[0088] In this embodiment, for a single image in the initial image set, the Local Binary Pattern (LBP) operator is used to traverse the pixels and their neighborhoods in the image. A binary pattern is generated by comparing the grayscale values ​​of neighboring pixels with those of the center pixel, and the histogram of the binary patterns of all pixels is statistically analyzed to generate texture feature data. The LBP operator can effectively capture local texture information of the image. For example, for a center pixel, its grayscale values ​​can be compared with those of its eight surrounding neighboring pixels to generate an 8-bit binary number as the LBP code of that center pixel. By statistically analyzing the frequency distribution of the LBP codes of all pixels in the image, a texture histogram can be formed. This histogram can reflect the texture features of the peanut seed surface, such as roughness, smoothness, cracks, or spots, and is effective in distinguishing surface defects.

[0089] In this embodiment, for a single image in the initial image set, the outline of the seed is determined by edge detection. Based on the outline, the aspect ratio and area duty cycle of its circumscribed rectangle are calculated to generate shape feature data. Edge detection algorithms (such as Canny and Sobel) can accurately delineate the boundaries of peanut seeds. Once the seed outline is obtained, its geometric properties can be calculated. For example, the smallest circumscribed rectangle surrounding the outline can be found, and the aspect ratio of this rectangle can be calculated to characterize the slenderness of the seed. Simultaneously, calculating the ratio of the outline area to the area of ​​the circumscribed rectangle (i.e., the area duty cycle) can reflect the fullness of the seed or whether there are defects. These shape features have a direct indicative role in identifying broken, deformed, or poorly developed peanut seeds.

[0090] In this embodiment, the generated color distribution feature data, texture feature data, and shape feature data are then concatenated to form the multi-dimensional visual features of the seed, thus obtaining the first feature vector. By concatenating and combining these feature vectors of different dimensions, a more comprehensive and information-rich integrated feature vector can be formed. This vector can describe the quality characteristics of a single peanut seed from multiple perspectives, such as color, texture, and shape. The first feature vector set is obtained by collecting the first feature vectors from all seeds.

[0091] In this embodiment, by converting the color space and calculating the pixel value histogram, the color distribution characteristics of peanut seeds can be effectively captured, which is crucial for identifying moldy, diseased, or differently mature seeds. Simultaneously, the use of a local binary mode operator to extract texture features can finely describe the microstructure of the seed surface, effectively distinguishing surface damage, cracks, or foreign matter attachment. Furthermore, by calculating shape features through edge detection and contour analysis, the geometric morphology of the seeds can be quantified, aiding in the identification of broken, deformed, or abnormally sized seeds. These multi-dimensional features are concatenated to form a comprehensive and highly discriminative first feature vector, enriching the characterization of peanut seed quality characteristics. This allows the subsequent initial sorting model to be trained based on more accurate and comprehensive data, thereby improving the model's initial performance and the accuracy of peanut seed quality identification, laying the foundation for the stable operation and accuracy of the entire online sorting system.

[0092] In one feasible implementation, the step of calculating the difference between the first benchmark distribution data and the current feature distribution data to generate feature drift index data includes: parsing a first benchmark mean vector and a first benchmark covariance matrix from the first benchmark distribution data; parsing a current mean vector and a current covariance matrix from the current feature distribution data; calculating the inverse matrix of the first benchmark covariance matrix to generate first inverse matrix data; and calculating the feature drift index data based on the first benchmark mean vector, the current mean vector, the first inverse matrix data, and the current covariance matrix.

[0093] In this embodiment, obtaining the first benchmark mean vector and the first benchmark covariance matrix from the first benchmark distribution data, and obtaining the current mean vector and the current covariance matrix from the current feature distribution data, refers to performing statistical analysis on the multidimensional feature vector set to extract its core statistical characteristics. The mean vector represents the center position of the data points in the feature space, and each component corresponds to the average value of the corresponding feature dimension. The covariance matrix describes the degree of variation and interrelationships between feature dimensions; the diagonal elements represent the variance of each feature, and the off-diagonal elements represent the covariance between different features. These statistical parameters are the basis for quantifying the data distribution characteristics and can be directly obtained from the feature vector set using standard statistical calculation methods.

[0094] Based on this, the inverse matrix of the first benchmark covariance matrix is ​​calculated to generate the first inverse matrix data. The inverse matrix of the covariance matrix plays a crucial role in multivariate statistical analysis, especially in defining statistical distances. It can transform the feature space, eliminating or weakening the correlation between features, thus making the contributions of different feature dimensions to the distance more independent and balanced in the transformed space. The inverse matrix is ​​typically calculated using numerical methods such as Gaussian elimination or LU decomposition in linear algebra. To ensure the stability and existence of the inverse matrix, the covariance matrix is ​​usually required to be a positive definite matrix. In practical applications, if a singular or ill-conditioned matrix is ​​encountered, regularization techniques (e.g., adding a small positive value on the diagonal) can be used to improve its invertibility.

[0095] In this embodiment, the feature drift index is finally calculated based on the first benchmark mean vector, the current mean vector, the first inverse matrix data, and the current covariance matrix. This step aims to quantify the statistical difference between the first benchmark distribution and the current feature distribution. By combining the difference in the mean vector and the information from the covariance matrix, a comprehensive statistical distance or divergence index can be constructed. For example, the generalized Mahalanobis distance or its variants can be used, which not only considers the shift of the mean vector but also weights the correlation between feature dimensions through the first inverse matrix data, making the distance calculation more consistent with the statistical structure of the data itself. Simultaneously, the introduction of the current covariance matrix allows the index to further reflect changes in the shape and direction of the current data distribution, rather than just the movement of the center position. This calculation method provides a single, statistically significant value for measuring the degree of drift in the feature distribution.

[0096] Through the above technical solution, this application provides a more accurate and robust method for calculating feature drift index data. By comprehensively considering the mean and covariance information of multidimensional feature distributions and effectively weighting the feature space using the inverse of the covariance matrix, it can more accurately capture subtle changes in data distribution. This allows the feature drift index data to sensitively reflect the true changes in data distribution, avoiding misjudgments caused by simple statistical fluctuations, thereby improving the accuracy of model update decisions. By accurately quantifying feature drift, the system can promptly detect and respond to changes in data distribution, ensuring the continuous high performance and high accuracy of the online sorting model in dynamic production environments, effectively improving the stability and reliability of online peanut seed quality sorting.

[0097] In one feasible implementation, the step of performing a filtering process based on the current time-period feature set and the corresponding predicted confidence data to generate a high-confidence feature subset and corresponding predicted quality label data includes: constructing a pre-trained filtering model based on the statistical characteristics of the current time-period feature set in the current feature distribution data; inputting online feature vectors from the current time-period feature set into the pre-trained filtering model to generate a membership score corresponding to each online feature vector; comparing the membership score with the predicted confidence data of the corresponding online feature vector, retaining online feature vectors whose membership score is higher than a first filtering threshold and whose predicted confidence data is higher than a second filtering threshold to form a preliminary filtering set; and attaching the corresponding real-time quality prediction result as a predicted quality label for each online feature vector retained in the preliminary filtering set, thereby obtaining the high-confidence feature subset and corresponding predicted quality label data.

[0098] In this embodiment, a pre-trained screening model is first constructed based on the statistical characteristics of the feature set for the current time period in the current feature distribution data. This screening model aims to evaluate the "normality" or "abnormality" of each online feature vector in the current time period feature set, i.e., its degree of matching with the current feature distribution. The pre-trained screening model can be implemented using various unsupervised or semi-supervised learning methods, such as density-based clustering algorithms, distance-based anomaly detection algorithms, or ensemble learning-based anomaly detection algorithms. Its core lies in learning the inherent structure and distribution patterns of the current feature set to identify samples that do not conform to the mainstream data patterns.

[0099] In this embodiment, the online feature vectors from the current time-period feature set are then input into the pre-trained screening model to generate a membership score for each online feature vector. The membership score is a quantitative indicator used to represent the degree of matching or anomalousness between the online feature vector and the current feature distribution. For example, in a density-based screening model, the membership score can reflect the density of data points surrounding the feature vector; in a distance-based screening model, it can reflect its distance to its nearest neighbor. Generally, a higher membership score indicates that the feature vector better conforms to the normal pattern of the current feature distribution, while a lower score indicates that it is an anomaly or outlier.

[0100] Furthermore, the membership scores are compared with the predicted confidence data of the corresponding online feature vectors. Online feature vectors with membership scores higher than a first screening threshold and predicted confidence data higher than a second screening threshold are retained, forming a preliminary screening set. This step ensures the quality of data used for model updates through a dual screening mechanism. The membership score screening aims to exclude samples that behave abnormally in the feature space or do not conform to the current data distribution, thereby avoiding the negative impact of noise and outliers on model updates. The predicted confidence data screening ensures that only samples for which the current sorting model has a high degree of confidence in their prediction results are included, which helps reduce the cumulative error caused by the model's own prediction errors. By setting appropriate thresholds, the strictness of the screening can be flexibly controlled, balancing data volume and data quality.

[0101] In this embodiment, finally, for each online feature vector retained in the initial screening set, its corresponding real-time quality prediction result is appended as a predicted quality label for that online feature vector, thereby obtaining the high-confidence feature subset and its corresponding predicted quality label data. Since it is usually impossible to obtain manually labeled true quality labels in real time during the online sorting process, using the real-time quality prediction results corresponding to the high-confidence online feature vectors after double screening as their "pseudo-labels" or "predicted quality labels" is key to achieving adaptive model updates. Although these predicted quality labels are not manually labeled true labels, because their corresponding feature vectors have high membership scores and high prediction confidence, these pseudo-labels have high reliability and can be effectively used for subsequent model parameter fine-tuning and baseline distribution updates.

[0102] In this embodiment, through the above technical solution, this application introduces a refined data screening mechanism in the model update process. First, by constructing a pre-trained screening model and generating membership scores, outliers and noisy data in the current time period feature set can be effectively identified and excluded, ensuring that the data used for model update has good representativeness and stability in the feature space. Second, by combining the model with the prediction confidence data of online feature vectors for secondary screening, it is further ensured that the selected data is not only "normal" in feature distribution, but also that its corresponding prediction results have high reliability. This dual screening strategy works synergistically, resulting in higher purity and accuracy of the final high-confidence feature subset and its prediction quality label data. Therefore, when updating the baseline distribution and fine-tuning the model parameters based on this high-quality data, the effectiveness and robustness of the model update can be improved, avoiding bias introduced by low-quality data, thereby enabling the sorting model to adapt to feature drift more accurately and stably, and continuously maintain high-precision online sorting performance.

[0103] In one feasible implementation, the step of inputting online feature vectors from the current time period feature set into the pre-trained screening model to generate a membership score corresponding to each online feature vector includes: using the current time period feature set as input data, randomly extracting a portion of the feature subspace; recursively and randomly selecting features and their segmentation values ​​in the extracted feature subspace to construct multiple binary tree structures; for any online feature vector in the current time period feature set, calculating the path length it takes from the root node to the leaf node in each binary tree structure; and mapping its corresponding membership score based on the average path length of the online feature vector in all binary tree structures.

[0104] In this embodiment, when processing high-dimensional feature data, directly operating on the entire feature space may lead to problems such as high computational complexity and the curse of dimensionality. By randomly extracting a subset of feature subspaces, the training and inference costs of the model can be effectively reduced, while increasing the model's generalization ability and robustness. A preset proportion or a fixed number of feature dimensions can be randomly selected from all feature dimensions of the current time-period feature set to form a smaller feature subset. This randomness helps to construct diverse decision trees, thereby better capturing abnormal patterns in the data. Within each extracted feature subspace, a binary tree is constructed recursively. Specifically, first, a feature dimension is randomly selected in the subspace; second, within the data range of the selected feature dimension, a splitting value is randomly selected. Based on this splitting value, the data points are divided into left and right subsets. The above process is repeated for each subset until a preset stopping condition is met, such as reaching the maximum depth, the number of data points contained in a node being less than a certain threshold, or all data points being identical in the current feature dimension. By constructing multiple such binary tree structures, the data can be divided from different perspectives, thereby more comprehensively evaluating the isolation degree of data points. For any online feature vector in the current time period's feature set, it is input into each of the constructed binary tree structures. Starting from the root node, based on the comparison between the value of the selected feature dimension of the online feature vector at each node and the splitting value, it is determined whether to enter the left or right subtree, until a leaf node is reached. The number of nodes traversed from the root node to the leaf node is the path length of the online feature vector in the binary tree structure. The shorter the path length, the more likely the data point is to be isolated, i.e., the lower the surrounding data density, and the more likely it is to be an outlier. Since a single binary tree structure may have randomness, to obtain a more stable and accurate evaluation, the path lengths of an online feature vector calculated in all constructed binary tree structures are averaged. This average path length reflects the average isolation degree of the online feature vector in the entire feature space. Subsequently, a predefined mapping function is used to convert the average path length into a membership score between 0 and 1. The shorter the path length, the lower the membership score obtained by mapping, indicating that the data point is more likely to be an outlier or located in a low-density area; conversely, the longer the path length, the higher the membership score, indicating that the data point is more likely to be a normal point or located in a high-density area.

[0105] In this embodiment, an anomaly detection method based on random forests is used to generate membership scores for online feature vectors. This method randomly extracts feature subspaces and recursively constructs multiple binary tree structures, ensuring that the path length of each online feature vector within these trees effectively reflects its isolation level in the feature space. Specifically, online feature vectors with shorter path lengths are more likely to be isolated, meaning their region has lower data density and is more likely to be an anomaly or located on the edge of the data distribution. By calculating the average path length and mapping it to membership scores, abnormal data points or low-confidence regions in the current time period's feature set can be identified efficiently and robustly. This method avoids strong assumptions about the data distribution and has computational efficiency advantages in high-dimensional data processing. This allows for more accurate selection of online feature vectors with high membership scores and high prediction confidence, providing high-quality training samples for subsequent model parameter fine-tuning, effectively improving the accuracy and stability of model updates, and ensuring the long-term performance of the online peanut seed quality sorting system.

[0106] In one feasible implementation, the step of updating the first benchmark distribution data to generate the second benchmark distribution data includes: calculating the mean of all online feature vectors within the high-confidence feature subset to generate a candidate mean vector; calculating its covariance to generate a candidate covariance matrix; reading the first benchmark mean vector and the first benchmark covariance matrix from the first benchmark distribution data; performing a weighted summation of the first benchmark mean vector and the candidate mean vector, wherein the weight of the candidate mean vector is a preset learning rate, and the weight of the first benchmark mean vector is one minus the learning rate, and the summation result is the second benchmark mean vector; performing a weighted fusion of the first benchmark covariance matrix and the candidate covariance matrix according to the same weighting strategy to obtain the second benchmark covariance matrix; and combining the second benchmark mean vector and the second benchmark covariance matrix to generate the second benchmark distribution data.

[0107] In this embodiment, the steps of calculating the mean of all online feature vectors within the high-confidence feature subset to generate a candidate mean vector and calculating its covariance to generate a candidate covariance matrix aim to extract core statistical features from the new data currently considered reliable. The high-confidence feature subset represents samples whose model predictions have high confidence in the current time period. By calculating the mean of these samples, a candidate mean vector reflecting the current data center trend can be obtained. Similarly, by calculating the covariance of these samples, a candidate covariance matrix reflecting the current data dispersion and the correlation between features can be obtained. These statistics are key inputs for updating the baseline distribution.

[0108] In this embodiment, the step of reading the first benchmark mean vector and the first benchmark covariance matrix from the first benchmark distribution data is to obtain the benchmark feature distribution determined after the initial establishment of the system or the last successful update. This distribution contains the system's initial or historically stable understanding of peanut seed characteristics. Reading the first benchmark mean vector and the first benchmark covariance matrix from this data is to enable a smooth and stable update process by combining historical information with current new information.

[0109] In this embodiment, the first baseline mean vector and the candidate mean vector are weighted and summed, where the weight of the candidate mean vector is a preset learning rate, and the weight of the first baseline mean vector is one minus the learning rate. The step of obtaining the second baseline mean vector by summing the results is the core of achieving smooth updates to the baseline mean. By introducing a preset learning rate, the system can control the degree of influence of new data on the baseline mean. The learning rate is a value between 0 and 1, which determines the proportion of new data (candidate mean vector) in the update process. When the learning rate is small, the system tends to retain the stability of the historical baseline; when the learning rate is large, the system can adapt to changes in new data more quickly. This weighted summation method allows the updated second baseline mean vector to absorb the trend of current high-confidence data without completely abandoning the stability accumulated historically, thereby avoiding drastic changes in the baseline due to short-term data fluctuations.

[0110] In this embodiment, the step of weighting and fusing the first benchmark covariance matrix and the candidate covariance matrix using the same weighting strategy to obtain the second benchmark covariance matrix is ​​similar to the update of the mean vector; the update of the covariance matrix also adopts a weighted fusion method. The covariance matrix reflects the correlation between features and the dispersion of data. By weighting and fusing the first benchmark covariance matrix (the dispersion of historical data distribution) with the candidate covariance matrix (the dispersion of current high-confidence data distribution), a more comprehensive and stable second benchmark covariance matrix can be obtained. This fusion strategy ensures that the benchmark distribution reflects changes in data center trends while also smoothly adapting to changes in data dispersion and correlation structure.

[0111] In this embodiment, the step of combining the second benchmark mean vector and the second benchmark covariance matrix to generate the second benchmark distribution data ultimately combines the weighted updated second benchmark mean vector and the second benchmark covariance matrix to form a new second benchmark distribution data. This new benchmark distribution data will be used for subsequent feature drift detection. It integrates historical stability with the effective information of current high-confidence data, providing a more accurate and adaptive reference benchmark for the online sorting system.

[0112] In this embodiment, the mean and covariance of the high-confidence feature subset are calculated as candidate update values, and then weighted and summed or fused with the original first benchmark mean vector and first benchmark covariance matrix. This allows the updated second benchmark distribution data to smoothly absorb the effective information of the current high-confidence data while preserving the stability of the historical benchmark, avoiding drastic impacts on the benchmark distribution caused by short-term data fluctuations or outliers. The preset learning rate mechanism allows the system to adjust its response speed to new data according to actual needs, thus ensuring a balance between the dynamic adaptability and long-term stability of the benchmark distribution. This provides a solid foundation for more accurate detection of feature drift and triggering of model updates, improving the robustness and accuracy of the online sorting system in complex and ever-changing environments.

[0113] In one feasible implementation, the step of fine-tuning the parameters of the current sorting model to generate a first updated sorting model based on the high-confidence feature subset and the corresponding predicted quality label data includes: inputting the high-confidence feature subset into the pre-trained current sorting model and performing a forward propagation to obtain the importance weight distribution data of each model parameter for correctly predicting the high-confidence feature subset; constructing a regularized constraint loss function based on the importance weight distribution data; using the high-confidence feature subset and its corresponding predicted quality label data as training data, and combining the regularized constraint loss function, generating the first updated sorting model through iterative updates of the model parameters.

[0114] In this embodiment, the high-confidence feature subset refers to the set of online feature vectors with high prediction confidence and high membership scores selected from the feature set of the current time period after the model has run continuously for a preset period. These feature vectors represent samples that the current model can predict relatively accurately, and therefore are a reliable data source for model fine-tuning. Inputting this high-confidence feature subset into the pre-trained current sorting model for forward propagation means passing these reliable input data through all layers of the model to calculate the model's output. During this process, the role of each parameter within the model in correctly predicting these high-confidence samples can be further analyzed.

[0115] In this embodiment, the importance weight distribution data of each model parameter for correctly predicting the high-confidence feature subset refers to the quantification of the importance of each trainable parameter (e.g., weights and biases) in accurately predicting the high-confidence feature subset. This importance can be evaluated in various ways. For example, it can be evaluated by calculating the gradient of the loss function with respect to the model parameters; a larger gradient value usually means that the parameter has a greater impact on the prediction result. In this way, it is possible to identify which parameters in the model are key to maintaining the current high-confidence prediction performance.

[0116] In this embodiment, constructing a regularized constraint loss function based on the importance weight distribution data means introducing an additional regularization term into the loss function used for model fine-tuning. The purpose of this regularization term is to constrain parameter changes during model parameter updates, particularly by applying differentiated constraints based on their importance weight distribution data. For example, stronger regularization constraints can be applied to parameters assessed as crucial for high-confidence predictions to limit significant changes, thereby preserving the model's existing key knowledge; while parameters with lower importance can be allowed greater adjustment space to adapt to new data features. This regularization strategy helps balance the model's adaptability to new data with the preservation of existing knowledge.

[0117] In this embodiment, the high-confidence feature subset and its corresponding predicted quality label data are used as training data. Combined with the regularized loss function, the first updated sorting model is generated through iterative updates of the model parameters. This involves using an optimization algorithm (such as gradient descent and its variants) to minimize the loss function containing the regularization term. During this iteration, the model parameters are gradually adjusted according to the gradient direction of the loss function. In this way, the model not only learns the new data distribution represented by the high-confidence feature subset, but also, due to the presence of regularization constraints, the updating of model parameters is guided, avoiding over-adjustment of unimportant parameters, thereby generating a first updated sorting model that can adapt to the new environment while maintaining stability.

[0118] In this embodiment, by evaluating the importance of each model parameter to high-confidence predictions and constructing a regularized constraint loss function based on this, the model can selectively adjust parameters during the update process. For parameters crucial to the current high-confidence predictions, their updates are subject to stronger constraints, effectively preventing the model from forgetting key knowledge or overfitting when adapting to new data distributions. This ensures the model can stably adapt to environmental changes during continuous operation, improving the accuracy and reliability of online peanut seed quality sorting while reducing the risks associated with model updates.

[0119] In one feasible implementation, the step of inputting the high-confidence feature subset into the pre-trained current sorting model to perform a forward propagation and obtain the importance weight distribution data of each model parameter for correctly predicting the high-confidence feature subset includes: for each online feature vector in the high-confidence feature subset, calculating the gradient of the loss function of the model output layer on the online feature vector after it passes through the current sorting model; based on the gradient of the online feature vector, calculating the expected value of the squared gradient of all online feature vectors corresponding to each model parameter to obtain the importance estimate of the model parameter; and normalizing the importance estimates of all model parameters to obtain the importance weight distribution data.

[0120] In this embodiment, for each online feature vector in the high-confidence feature subset, it is necessary to calculate the gradient of the loss function of the model's output layer on that online feature vector after it has passed through the current sorting model. This is typically achieved using a backpropagation algorithm. When an online feature vector is input into the current sorting model for forward propagation, the model produces a prediction result. By comparing this prediction result with the corresponding prediction quality label data, the loss function value can be calculated. Subsequently, through backpropagation, the partial derivatives of the loss function with respect to each parameter in the model, i.e., the gradient, can be calculated. This gradient value reflects how the loss function changes when the parameter undergoes a small change, thus quantifying the importance or sensitivity of that parameter in correctly predicting the current online feature vector.

[0121] Based on this, the expected value of the squared gradient of all online feature vectors corresponding to each model parameter is calculated using the gradient of the online feature vectors to obtain an importance estimate of the model parameter. Specifically, for each parameter in the current sorting model, the gradient of the parameter is calculated after backpropagation of all online feature vectors in the high-confidence feature subset. Then, these gradient values ​​are squared, and their average value (i.e., the expected value) is calculated. Using the squared gradient instead of the gradient itself eliminates the directionality of the gradient, focusing only on its magnitude, i.e., the absolute strength of the parameter's influence on the loss function. The expected value provides a statistically stable measure, effectively aggregating information from multiple high-confidence samples, reducing the impact of individual sample noise on importance estimation, and thus more accurately reflecting the importance of the parameter in the overall high-confidence data.

[0122] Furthermore, the importance estimates of all model parameters are normalized to obtain the importance weight distribution data. Normalization is the process of transforming data of different dimensions or ranges to a uniform scale. Here, the importance estimates of all model parameters can be linearly scaled, for example, by mapping all estimates to the interval between 0 and 1, or by converting them into a probability distribution using the Softmax function, so that the sum of all weights is 1. Through normalization, the importance estimates of different parameters can be compared, forming a clear weight distribution that intuitively represents the relative contribution of each parameter to the overall model prediction of high-confidence data, providing standardized input for the subsequent construction of the regularized constraint loss function.

[0123] In this embodiment, through the above technical solution, this application can accurately quantify the importance of each parameter in the current sorting model for correctly predicting the high-confidence feature subset. Specifically, by calculating the gradient of each online feature vector with respect to the parameters after passing through the model's loss function, the sensitivity of the parameter to the prediction of a single sample can be obtained. Furthermore, by calculating the expected value of the squared gradients of all online feature vectors, the overall importance of each model parameter on the entire high-confidence dataset can be statistically stably evaluated, effectively avoiding interference from single samples or noise on the importance assessment. Finally, these importance estimates are normalized to generate clear and comparable importance weight distribution data. This refined weight distribution data provides a solid foundation for subsequent regularization constraints on the loss function, enabling the model to apply different constraint strengths to parameters of different importance during parameter fine-tuning. For example, for key parameters that contribute significantly to the prediction of high-confidence data, weaker regularization can be applied to retain their learned effective features; while for parameters that contribute less, stronger regularization can be applied to prevent overfitting or learning noise. This not only improves the efficiency and stability of model fine-tuning, but also enhances the model's adaptability to concept drift, ensuring that the online sorting system can maintain high accuracy and robustness in long-term operation.

[0124] In one feasible implementation, the step of generating sorting control instructions based on real-time quality prediction results to control the sorting actuator to perform corresponding actions includes: when the real-time quality prediction result is lower than a preset threshold, parsing out the shape size data and surface smoothness estimation data from the online feature vector corresponding to the peanut to be sorted; dynamically calculating the pressure value and jet duration adjustment amount of the high-speed airflow based on the pre-stored empirical correspondence and the shape size data and the surface smoothness estimation data; and generating the sorting control instructions containing specific action parameters based on the calculated pressure value and jet duration adjustment amount.

[0125] In this embodiment, when the real-time quality prediction result is lower than a preset threshold, it indicates that the peanuts to be sorted may have quality problems and need to be removed or specially processed. At this time, the system will further parse specific data related to the physical characteristics of the peanut from the online feature vector already extracted for the peanut, such as shape and size data and surface smoothness estimation data. Shape and size data can include geometric parameters such as the length, width, height, area, and perimeter of the peanut seed. These parameters are usually extracted from the image and encoded into the online feature vector during the image processing stage through methods such as contour detection and region analysis. Surface smoothness estimation data reflects the roughness or defects of the peanut seed surface. It can be calculated from the online image through image processing techniques such as texture analysis and grayscale gradient changes, and is also included in the online feature vector. The parsing of this data aims to provide a more refined physical basis for subsequent sorting actions.

[0126] Based on this, the pre-stored empirical correspondence refers to the mapping relationship between the shape and size of peanut seeds and high-speed airflow sorting parameters (such as pressure value and spray duration) established through the accumulation of a large amount of experimental data and the summary of expert experience before the system is put into use. This relationship can be expressed in the form of lookup tables, regression models, fuzzy rule sets, etc. For example, for peanuts with larger size and more severe surface defects, a higher airflow pressure and a longer spray time are required for effective rejection; while for peanuts with smaller size and minor surface defects, only a lower airflow pressure and a shorter spray time are needed. The system queries or calculates this empirical correspondence in real time based on the currently parsed shape and size data and surface smoothness estimation data, thereby dynamically determining the adjustment amount of the high-speed airflow pressure value and spray duration. This dynamic calculation ensures the accuracy and adaptability of the sorting action.

[0127] In this embodiment, the final sorting control command is a command used to guide the sorting actuator (such as a valve, nozzle, etc.) to perform specific sorting actions. This command not only includes basic "reject" or "retain" signals, but also encapsulates specific action parameters based on dynamically calculated pressure values ​​and spray duration adjustments. For example, the command includes detailed information such as "valve opening pressure" and "valve opening time." These specific action parameters precisely control the sorting actuator, enabling it to spray with the most suitable airflow intensity and duration according to the actual physical characteristics of the peanut seeds, thereby achieving accurate rejection of defective peanut seeds while avoiding unnecessary impact or waste on qualified peanuts.

[0128] In this embodiment, using the above technical solution, when the real-time quality prediction result of peanut seeds is lower than a preset threshold, the system no longer simply performs a uniform rejection action. Instead, it can parse the peanut's external dimensions and surface smoothness estimation data from the online feature vector. Based on pre-stored empirical correspondences, the system can dynamically calculate the pressure value and spray duration adjustment of the high-speed airflow and generate sorting control instructions containing these specific action parameters. This refined sorting control allows the sorting actuator to adjust the intensity and duration of the airflow spray according to peanut seeds with different defect levels and physical characteristics. For example, for larger peanuts with obvious defects, a stronger airflow can be applied to ensure effective rejection; while for smaller peanuts with minor defects, a weaker airflow can be used, thereby reducing accidental damage to qualified products or unnecessary energy consumption. This improves the accuracy and efficiency of sorting, reduces the false rejection rate and missed rejection rate, optimizes resource utilization, and ultimately improves the overall quality and economic benefits of peanut seed sorting.

[0129] In the embodiments of this application, the online peanut seed quality sorting method proposed in this application solves the problem of decreased sorting accuracy caused by feature drift by detecting feature drift online and automatically updating the model. It has adaptive feature drift detection and model update capabilities, automatically maintains sorting accuracy in continuous production, reduces downtime maintenance time, and improves production efficiency.

[0130] It should be noted that the above examples are only for understanding this application and do not constitute a limitation on the online sorting method for peanut seed quality of this application. Any simple modifications based on this technical concept are within the protection scope of this application.

[0131] This application also provides an online peanut seed quality sorting system, for reference... Figure 2 The online peanut seed quality sorting system includes: a memory 10, a processor 20, and an online peanut seed quality sorting program stored on the memory 10 and executable on the processor 20. The online peanut seed quality sorting program is configured to implement the steps of the online peanut seed quality sorting method.

[0132] The online peanut seed quality sorting system provided in this application, employing the online peanut seed quality sorting method described in the above embodiments, can reduce downtime maintenance and improve production efficiency. Compared with the prior art, the beneficial effects of the online peanut seed quality sorting system provided in this application are the same as those of the online peanut seed quality sorting method provided in the above embodiments, and other technical features of the online peanut seed quality sorting system are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.

[0133] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.

[0134] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. All equivalent structural transformations made under the technical concept of this application using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included within the scope of patent protection of this application.

Claims

1. A method for online sorting of peanut seed quality, characterized in that, The method includes: An initial image set of peanut seeds is obtained; feature extraction processing is performed on the initial image set to generate a first feature vector set; and statistical parameters of the first feature vector set are calculated to generate first baseline distribution data; manually labeled quality label data corresponding to the first feature vector set is obtained; and an initial sorting model is trained based on the first feature vector set and the quality label data. Collect online images of peanuts to be sorted, perform feature extraction processing on the online images, and generate online feature vectors; The online feature vector is input into the current sorting model for prediction processing to generate real-time quality prediction results and corresponding prediction confidence data; based on the real-time quality prediction results, sorting control commands are generated to control the sorting execution mechanism to perform corresponding actions; After running continuously for a preset period of time, the online feature vectors corresponding to all sorted peanuts within the preset period of time are obtained, and they are summarized and processed to construct the feature set of the current period of time. The statistical parameters of the feature set of the current period of time are calculated to generate the current feature distribution data. Calculate the difference between the first baseline distribution data and the current feature distribution data to generate feature drift index data; The feature drift index data is compared with a preset drift threshold. If the feature drift index data exceeds the drift threshold, a model update process is triggered. The model update process includes: Based on the current time period feature set and the corresponding prediction confidence data, a filtering process is performed to generate a high-confidence feature subset and corresponding prediction quality label data; Based on the high-confidence feature subset, the first baseline distribution data is updated to generate the second baseline distribution data; Based on the high-confidence feature subset and the corresponding predicted quality label data, the parameters of the current sorting model are fine-tuned to generate the first updated sorting model. The second baseline distribution data and the first updated sorting model are then applied to the subsequent real-time sorting process. The steps for generating a high-confidence feature subset and corresponding prediction quality label data based on the current time period feature set and the corresponding prediction confidence data include: Based on the statistical characteristics of the feature set of the current time period in the current feature distribution data, a pre-trained screening model is constructed; the online feature vectors in the feature set of the current time period are input into the pre-trained screening model to generate the membership score corresponding to each online feature vector; The membership score is compared with the predicted confidence data of the corresponding online feature vector, and online feature vectors with membership scores higher than the first screening threshold and predicted confidence data higher than the second screening threshold are retained to form a preliminary screening set; For each online feature vector retained in the initial screening set, its corresponding real-time quality prediction result is appended as the predicted quality label of the online feature vector, thereby obtaining the high-confidence feature subset and the corresponding predicted quality label data; The steps of inputting the online feature vectors from the current time period feature set into the pre-trained screening model to generate the membership score corresponding to each online feature vector include: Using the current time period feature set as input data, a portion of the feature subspace is randomly extracted. In the extracted feature subspace, features and their segmentation values ​​are recursively and randomly selected to construct multiple binary tree structures; For any online feature vector in the feature set of the current time period, calculate the path length from the root node to the leaf node in each binary tree structure; Based on the average path length of the online feature vector across all binary tree structures, the corresponding membership score is obtained through mapping.

2. The online peanut seed quality sorting method as described in claim 1, characterized in that, The steps of performing feature extraction processing on the initial image set to generate a first feature vector set include: For a single image in the initial image set, its color space is converted, and a histogram of pixel values ​​on the target color channel is calculated to generate color distribution feature data. For a single image in the initial image set, a local binary mode operator is used to traverse the pixels and their neighborhoods in the image. A binary mode is generated by comparing the gray values ​​of the neighboring pixels with the center pixel. The binary mode histogram of all pixels is then calculated to generate texture feature data. For a single image in the initial image set, the outline of the seed is determined by edge detection, and the aspect ratio and area duty cycle of its bounding rectangle are calculated based on the outline to generate shape feature data. The color distribution feature data, the texture feature data, and the shape feature data are concatenated to form the multi-dimensional visual features of the seed, resulting in the first feature vector; the first feature vectors of all seeds are then collected to obtain the first feature vector set.

3. The online peanut seed quality sorting method as described in claim 1, characterized in that, The steps for calculating the difference between the first baseline distribution data and the current feature distribution data, and generating feature drift index data, include: The first benchmark mean vector and the first benchmark covariance matrix are obtained by parsing from the first benchmark distribution data; the current mean vector and the current covariance matrix are obtained by parsing from the current feature distribution data; Based on the first benchmark covariance matrix, its inverse matrix is ​​calculated to generate the first inverse matrix data; The feature drift index data is calculated based on the first baseline mean vector, the current mean vector, the first inverse matrix data, and the current covariance matrix.

4. The online peanut seed quality sorting method as described in claim 1, characterized in that, The steps for updating the first baseline distribution data to generate the second baseline distribution data based on the high-confidence feature subset include: Calculate the mean of all online feature vectors within the high-confidence feature subset to generate candidate mean vectors; calculate their covariance to generate candidate covariance matrices. Read the first benchmark mean vector and the first benchmark covariance matrix from the first benchmark distribution data; The first baseline mean vector and the candidate mean vector are weighted and summed, wherein the weight of the candidate mean vector is a preset learning rate, and the weight of the first baseline mean vector is one minus the learning rate. The summation result is the second baseline mean vector. The first benchmark covariance matrix and the candidate covariance matrix are weighted and fused using the same weighting strategy to obtain the second benchmark covariance matrix. The second benchmark mean vector is combined with the second benchmark covariance matrix to generate the second benchmark distribution data.

5. The online peanut seed quality sorting method as described in claim 1, characterized in that, The steps for fine-tuning the parameters of the current sorting model to generate a first updated sorting model based on the high-confidence feature subset and the corresponding predicted quality label data include: The high-confidence feature subset is input into the pre-trained current sorting model to perform a forward propagation, and the importance weight distribution data of each model parameter for correctly predicting the high-confidence feature subset is obtained. Based on the importance weight distribution data, a regularized constraint loss function is constructed; The high-confidence feature subset and its corresponding predicted quality label data are used as training data. Combined with the regularized constraint loss function, the first updated sorting model is generated by iteratively updating the model parameters.

6. The online peanut seed quality sorting method as described in claim 5, characterized in that, The steps of inputting the high-confidence feature subset into the pre-trained current sorting model to perform one forward propagation, and obtaining the importance weight distribution data of each model parameter for correctly predicting the high-confidence feature subset, include: For each online feature vector in the high-confidence feature subset, calculate the gradient of the loss function of the model output layer on that online feature vector after it passes through the current sorting model; Based on the gradient of the online feature vector, the expected value of the squared gradient of all online feature vectors corresponding to each model parameter is calculated to obtain the importance estimate of the model parameter; The importance estimates of all model parameters are normalized to obtain the importance weight distribution data.

7. The online peanut seed quality sorting method as described in claim 1, characterized in that, The steps for generating sorting control commands based on real-time quality prediction results to control the sorting actuator to perform corresponding actions include: When the real-time quality prediction result is lower than the preset threshold, the external size data and surface smoothness estimation data are obtained by parsing the online feature vector corresponding to the peanut to be sorted. Based on pre-stored empirical correspondences, the pressure value of the high-speed airflow and the adjustment amount of the injection duration are dynamically calculated according to the external dimension data and the surface smoothness estimation data. Based on the calculated pressure value and the adjustment amount of the injection duration, the sorting control command containing specific action parameters is generated.

8. An online peanut seed quality sorting system, characterized in that, The online peanut seed quality sorting system includes: a memory, a processor, and an online peanut seed quality sorting program stored in the memory and executable on the processor, wherein the online peanut seed quality sorting program is configured to implement the steps of the online peanut seed quality sorting method as described in any one of claims 1 to 7.