Agricultural product detection method and system

Through the edge-cloud collaboration digital twin simulation enhancement and two-way distillation feedback mechanism, the adaptive problem of agricultural product detection system under multimodal feature drift is solved, and efficient and stable detection effects and low-cost model updates are achieved.

CN120314519BActive Publication Date: 2025-08-26YONGCHUN COUNTY AGRICULTURAL SCIENCE RESEARCH INSTITUTE (YONGCHUN COUNTY AGRICULTURAL INSPECTION CENTER YONGCHUN COUNTY CROP BREED FARM)
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510784279.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-06-12
Publication Date
2025-08-26
Estimated Expiration
2045-06-12

AI Technical Summary

Technical Problem

The existing agricultural product detection system lacks an adaptive enhancement mechanism when facing multimodal feature drift, resulting in large fluctuations in detection accuracy, high cost of cloud updates, lagging response, and poor independence of edge devices.

Method used

The edge-cloud collaboration digital twin simulation enhancement and bidirectional distillation feedback mechanism are adopted, and the model is quickly adapted and closed-loop evolution through real-time edge detection, cloud-end difference monitoring and digital twin model optimization, combined with multimodal feature processing and knowledge distillation.

Benefits of technology

It improves the accuracy and stability of agricultural product testing, ensures edge autonomy capabilities and cloud-edge consistency, adapts to scenario changes, and reduces communication costs and response delays.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120314519B_ABST
    Figure CN120314519B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of agricultural product testing technology and discloses an agricultural product testing method and system, comprising: obtaining test data of the agricultural product to be tested, performing feature extraction on the test data in an edge device to obtain a fused feature vector, and using an edge-end model to perform real-time testing of the agricultural product based on the fused feature vector; uploading the test results and the fused feature vector to the cloud, constructing a digital twin model in the cloud, generating a reference distribution, and performing difference monitoring; performing digital twin simulation based on the difference monitoring results, and achieving collaborative optimization through a two-way knowledge distillation mechanism, driving sorting equipment to complete agricultural product grading operations based on the test results. The proposed method and system can quickly adapt to scenario changes without requiring large-scale data backhaul, improving detection accuracy and stability, while ensuring the system's edge autonomy and cloud-edge consistency, and possessing high deployment practical value and promotion potential.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of agricultural product detection, and in particular to an agricultural product detection method and system. Background Art

[0002] Current agricultural product testing systems still face numerous challenges in multimodal feature processing, adapting to diverse environments, and real-time edge deployment. Frequent changes in production locations, seasons, and environmental conditions cause the distribution of test samples to continuously drift, rendering traditional static training models ineffective in practical applications and making it difficult to adapt to drifting characteristics. Furthermore, while cloud-based model updates can be used to address these changes, such approaches rely heavily on communication bandwidth and data backhaul, resulting in delayed model responses, high update costs, and poor edge device independence.

[0003] Existing technologies often deploy lightweight models at the edge using methods such as static model compression and one-way distillation. This makes it difficult to form a closed-loop collaborative evolution of cloud-edge models, and also lacks an adaptive enhancement mechanism based on changes in detection tasks. This results in the system's lack of judgment and intervention capabilities in the early stages of drift, leading to large fluctuations in detection accuracy. To address these issues, the present invention proposes an agricultural product detection method that integrates distributed drift monitoring, digital twin simulation enhancement, and a two-way distillation feedback mechanism to achieve rapid adaptation and closed-loop evolution of detection models in an edge-cloud collaborative environment. Summary of the Invention

[0004] In view of the above-mentioned problems, the present invention is proposed.

[0005] Therefore, the technical problem solved by the present invention is that the existing technology does not provide an adaptive enhancement mechanism based on changes in detection tasks, the system lacks the ability to judge and intervene in the early stage of drift, and the detection accuracy fluctuates greatly.

[0006] To solve the above technical problems, the present invention provides the following technical solutions: a method for detecting agricultural products, comprising: obtaining detection data of the agricultural products to be detected, performing feature extraction on the detection data in an edge device to obtain a fused feature vector, and performing real-time detection of the agricultural products using an edge model based on the fused feature vector;

[0007] Upload the detection results and fused feature vectors to the cloud, build a digital twin model in the cloud, generate a reference distribution, and perform difference monitoring;

[0008] Based on the difference monitoring results, digital twin simulation is performed, and collaborative optimization is achieved through a two-way knowledge distillation mechanism. The sorting equipment is driven according to the detection results to complete the agricultural product grading operation.

[0009] As a preferred solution of the agricultural product detection method described in the present invention, the detection data includes near-infrared reflectance spectrum, deep ultraviolet fluorescence image, dielectric parameters, visible-SWIR image and auxiliary data.

[0010] As a preferred embodiment of the agricultural product detection method of the present invention, the feature extraction includes performing targeted processing on different types of collected detection data to obtain multimodal features, and constructing an integrated coding network to fuse the multimodal features. The specific steps include:

[0011] Use convolutional neural network branches to extract low-order features of each modality;

[0012] In the encoding stage, a cross-modal attention mechanism is added to achieve information alignment and complementarity;

[0013] All modal features are concatenated into a fused feature vector.

[0014] As a preferred embodiment of the agricultural product detection method of the present invention, the steps of constructing a digital twin model in the cloud, generating a reference distribution, and performing difference monitoring include establishing a parameter space in the cloud based on historical detection data and industry prior knowledge;

[0015] Using a combination of simulation modeling and statistical sampling, simulated data equivalent to actual test data is generated from the parameter space;

[0016] Summarize and analyze the simulation data to obtain the reference distribution ;

[0017] The cloud statistics fusion feature vector distribution in the feature space to obtain the detection data distribution ;

[0018] Using distance metric comparison and The calculated drift intensity and set threshold For comparison, if Considered to have no significant drift;

[0019] like , marked as drift detection trigger, executing digital twin simulation.

[0020] As a preferred embodiment of the agricultural product detection method of the present invention, the execution of digital twin simulation based on the difference monitoring results includes setting a natural saturation value for sample generation based on the drift intensity using a Sigmoid mapping form, and determining the number of digital twin synthetic samples to be generated, which is expressed as:

[0021] ;

[0022] in, represents the number of twin synthetic samples; Indicates the number of recent real samples; Indicates the maximum sample amplification factor; represents the exponential function; Indicates the slope of the control curve; Indicates drift intensity; represents the drift intensity threshold;

[0023] The digital twin model is called in the cloud to generate Simulation test data, and the latest The real detection data are spliced ​​into an incremental training data set, and the edge model is updated according to the incremental training data set;

[0024] Recalculate the drift strength of the edge model after the update If any of the following conditions is met, the closed-loop enhancement process is terminated and the model is considered to have adapted to the drift:

[0025] Less than the minimum threshold of the descent rate and continuously satisfied times, indicating that the drift decrease rate slows down;

[0026] and There is no significant decrease, indicating that the generated samples are saturated but the effect is marginally attenuated;

[0027] The maximum number of iterations has been reached.

[0028] As a preferred solution of the agricultural product detection method described in the present invention, the updating of the edge model according to the incremental training data set includes: loading the model weights after the most recent complete training round into the edge model, using the elastic weight retention algorithm, limiting the drastic update of important parameters by adding a retention regularization term, adopting a small batch training method, setting the upper limit of the number of training rounds and the training duration, training and updating the edge model, saving and synchronizing the updated edge model weights to the cloud, and immediately putting the updated model into real-time detection at the edge to realize online takeover of the new model.

[0029] As a preferred solution of the agricultural product detection method described in the present invention, wherein: the collaborative optimization achieved through the bidirectional knowledge distillation mechanism includes the cloud using the full-precision detection model to detect the data uploaded by the edge end. The full-precision detection model is the main model version deployed in the cloud, and the edge model is the student model obtained by distillation and compression of the full-precision detection model.

[0030] A dual loss is used at the edge, with cross entropy loss as the hard label and Kullback–Leibler divergence as the soft label for joint optimization, compressing the full cloud model knowledge into the edge model.

[0031] After the edge model is put into testing, the prediction error vector is recorded for each sample and compressed and cached;

[0032] The edge end regularly uploads the error hash table and high-weight samples. The cloud end uses the error hash table and high-weight samples as additional weights to fine-tune the full-precision detection model, so that the full-precision detection model can quickly absorb the latest drift characteristics on site and achieve two-way optimization between the cloud and the edge end.

[0033] An agricultural product detection system using any of the methods described in the present invention, wherein: a detection module obtains detection data of the agricultural product to be detected, performs feature extraction on the detection data in an edge device to obtain a fused feature vector, and performs real-time detection of the agricultural product using an edge model based on the fused feature vector;

[0034] The difference monitoring module uploads the detection results and fused feature vectors to the cloud, builds a digital twin model in the cloud, generates a reference distribution, and performs difference monitoring;

[0035] The optimization module performs digital twin simulation based on the difference monitoring results, realizes collaborative optimization through a two-way knowledge distillation mechanism, and drives the sorting equipment to complete the agricultural product grading operation based on the detection results.

[0036] The beneficial effects of this invention: By constructing a closed-loop mechanism of "drift triggering → simulation enhancement → distillation feedback → model collaborative compression," this invention achieves, for the first time, bidirectional knowledge flow and synchronous evolution between edge detection models and full cloud models in drift scenarios. The innovative introduction of a drift intensity-driven synthetic sample control mechanism and an edge-to-cloud error distillation strategy enables the model to rapidly adapt to scenario changes without requiring large-scale data backhaul, improving detection accuracy and stability while ensuring the system's edge autonomy and cloud-edge consistency. This approach offers high deployment value and potential for widespread adoption. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. Those skilled in the art can also derive other drawings based on these drawings without inventive efforts.

[0038] Figure 1 This is an overall flow chart of a method for detecting agricultural products provided by one embodiment of the present invention. DETAILED DESCRIPTION

[0039] To make the above-mentioned objects, features, and advantages of the present invention more clearly understood, the following detailed description of the specific embodiments of the present invention is given in conjunction with the accompanying drawings. It is obvious that the described embodiments are only part of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary persons in this field without creative work should fall within the scope of protection of the present invention.

[0040] Example 1, reference Figure 1 , as an embodiment of the present invention, provides a method for detecting agricultural products, comprising:

[0041] S1: Obtain the test data of the agricultural products to be tested, perform feature extraction on the test data in the edge device to obtain a fused feature vector, and use the edge model to perform real-time detection of the agricultural products based on the fused feature vector.

[0042] Furthermore, the agricultural products to be tested are sequentially introduced into a detection channel via a conveyor device (e.g., a roller-type or belt-type conveyor structure). The detection channel is equipped with a photoelectric sensor assembly, which includes a laser beam sensor or an infrared light curtain device, for identifying whether the sample has entered a predetermined detection position.

[0043] When the sample enters the detection area and triggers the photoelectric sensor, the controller sends a synchronous acquisition instruction to multiple sensor modules, including:

[0044] Control the tunable near-infrared spectrometer to perform integral reflection acquisition in the range of 780nm–2500nm;

[0045] Controlling the deep ultraviolet fluorescence excitation light source to emit excitation pulses and enabling the fluorescence imaging device to collect fluorescence reflection images;

[0046] Start the X-band microwave resonance sensor to perform frequency scanning and collect the dielectric response characteristics of the sample;

[0047] The visible-SWIR image acquisition module is synchronously triggered to acquire the sample surface texture image.

[0048] Preferably, the conveying device is further equipped with a speed feedback encoder for detecting the conveying speed, so that the image acquisition module can adjust the exposure time according to the speed signal to avoid motion blur of the sample.

[0049] Furthermore, the aforementioned sensor components are spatially coordinated. The near-infrared spectrometer and fluorescence imaging module are non-coaxially arranged, projecting light diagonally downward from above and receiving reflected signals. Microwave sensors are located below or on either side of the transport path, non-contactly measuring the electromagnetic response characteristics within the sample.

[0050] Through the above methods, the present invention can complete synchronous, non-destructive, and full-dimensional data acquisition during the continuous sample transportation process, providing a data basis for subsequent multimodal fusion analysis.

[0051] It should be noted that, in addition to the above data, auxiliary data of the agricultural products to be tested are also obtained, including data such as variety, origin, season / harvest time, storage or processing environment parameters, etc.

[0052] Furthermore, all types of detection data will be pre-processed at the edge after collection to improve data quality and modeling accuracy. Specifically:

[0053] For near-infrared spectral data, standard normal variation (SNV) is used to normalize them to reduce interference caused by light scattering. Subsequently, a first-order derivative transformation (such as Savitzky-Golay filtering) is used to highlight subtle differences in absorption bands and improve feature sensitivity.

[0054] For deep ultraviolet fluorescence images, the system first performs dark field image correction and white board reflection correction to eliminate background signals and the influence of non-uniform illumination; then the corrected image is expanded into a multi-dimensional spectrum-space data matrix according to the excitation wavelength and spatial pixels for processing by the encoding network.

[0055] For the dielectric spectrum data collected by microwave resonance, the system combines it with the real-time collected ambient temperature and humidity data to perform temperature compensation and dielectric normalization processing to improve stability under different working conditions.

[0056] For visible-SWIR image data, the system first completes color space conversion (such as RGB to Lab) and extracts key texture features (such as local binary pattern LBP and gray-level co-occurrence matrix GLCM) for subsequent analysis.

[0057] After this preprocessing, the multimodal data is fed into a fusion encoder network deployed at the edge. This network, comprised of multiple parallel convolutional neural network branches, extracts underlying features from each modality and uses a cross-modal attention mechanism to align and enhance information between modalities. Ultimately, features from all modalities are concatenated and fused to form a unified feature vector, which is then used by the inference model to output detection results.

[0058] Preferably, all preprocessing and feature encoding operations are completed on the edge computing device. The edge device integrates an ARM processor and a low-power GPU or NPU unit, which can quickly complete data processing and modeling reasoning without relying on cloud computing resources, effectively ensuring real-time detection and data security.

[0059] It should be noted that during data acquisition, the four sensor hardware runs in parallel, the fluorescence excitation pulse width is ≤100µs, and the microwave frequency sweep adopts three-point resonance demodulation (instead of full-frequency sweep). The acquisition port → FPGA → NPU forms a pipeline. While the previous sample is being inferred, the next one is already in the acquisition preprocessing.

[0060] Any high-bit original frame is only retained locally for a short time. Cloud-based training only requires the fusion of vectors and a small amount of original data. Digital twins and incremental learning are only started after drift is triggered. The simulation is completed entirely on the cloud. Therefore, multimodal acquisition + exclusive preprocessing will not slow down detection or cause waste of resources, fully meeting the actual needs of agricultural product testing.

[0061] Furthermore, the fused feature vector after multimodal feature fusion is input into a lightweight detection model deployed at the edge for preliminary inference and output. This edge detection model is a student model compressed from the full-precision cloud-based detection model through knowledge distillation, enabling fast inference and efficient deployment. This model structure undergoes parameter pruning, network quantization, and channel compression, making it suitable for edge computing platforms (such as NPUs and embedded GPUs), ensuring inference efficiency while maintaining high discrimination accuracy.

[0062] During inference, the edge model receives the fused feature vector as input and outputs corresponding detection result information, including but not limited to: the agricultural product's quality grade, safety status classification, and the corresponding confidence distribution for each category. Preferably, this model has been jointly trained with a cloud-based teacher model using soft labels, achieving representation transfer across multimodal feature spaces and supporting subsequent online fine-tuning and incremental training.

[0063] To enhance the system's real-time performance, real-time agricultural product testing is performed entirely locally on the edge, without relying on cloud communication. Test results can be directly used to drive real-time control of downstream equipment (such as sorting equipment). The system also synchronously uploads metadata, including output test labels, confidence levels, sample feature summaries, and the current model version number, to the cloud for subsequent drift monitoring, model consistency verification, and digital twin simulation comparisons.

[0064] The technical solution of the present invention not only ensures the detection system's discrimination ability and response speed in different scenarios, but also, through distillation collaboration with the full-precision model on the cloud, enables the edge model to have evolutionary capabilities and knowledge inheritance mechanisms while compressing the structure, providing basic support for the long-term deployment and closed-loop adaptive updates of the model.

[0065] S2: Upload the detection results and fused feature vectors to the cloud, build a digital twin model in the cloud, generate a reference distribution and perform difference monitoring.

[0066] Furthermore, in order to achieve the adaptability of the detection model to different agricultural product varieties, origins and production environments, the system builds a digital twin simulation model in the cloud and periodically generates feature reference data that matches the current detection task.

[0067] Specifically, the system first constructs a multidimensional parameter space based on historical detection data and prior industry knowledge. This parameter space includes at least information such as the agricultural product's variety, origin, harvesting season, storage environment, and processing conditions. Based on this parameter space, the system uses a combination of simulation modeling and statistical sampling to generate multimodal synthetic data corresponding to actual detection characteristics, including:

[0068] Near-infrared spectral characteristics that reflect the sugar-acid ratio and water structure within agricultural products;

[0069] Deep ultraviolet fluorescence spectrum reflecting surface pesticide residues or mildew signals;

[0070] Resonance spectrum characteristics that characterize the dielectric properties of the sample;

[0071] Statistical features of visible-shortwave infrared images characterizing surface texture changes of samples.

[0072] It should be noted that there are complete and mature existing technologies for generating multimodal synthetic data, such as NIR spectral synthesis models, fluorescence spectrum simulation models, and dielectric spectrum simulation models. A joint parameter sampling space is constructed based on the parameter label distribution of the currently tested product. Stratified random sampling is used to select sample points from the parameter space. For each sample point, the corresponding simulation model is called to generate a corresponding multimodal feature sample. All generated samples are uniformly normalized and labeled to form a synthetic sample set.

[0073] After the synthetic samples are aggregated and analyzed, a multimodal feature reference distribution is formed under the current category, environment, and parameter conditions, which is recorded as the digital twin baseline distribution. This distribution will serve as the basis for subsequent drift detection and adaptive model updates.

[0074] Preferably, the digital twin simulation model has the ability of dynamic adaptation and continuous optimization. It can automatically adjust the simulation parameter set according to the agricultural product variety type, origin, environmental status and real-time uploaded historical test result data involved in the current detection task, and switch or incrementally update the simulation model to ensure that the generated multimodal synthetic features are always highly consistent with the actual features of the current batch of samples.

[0075] Specifically, the system maintains a twin model library containing multiple simulation sub-models in the cloud. Each sub-model corresponds to a specific variety and environment combination, and records its applicable conditions and simulation accuracy indicators. When the detection system identifies that the variety category, origin label or temperature and humidity status of the current task has changed, the system will automatically select the most matching twin sub-model and activate the application. If there is a significant deviation between the current detection data distribution and the existing simulation results, the system can also automatically trigger the incremental fine-tuning process of the simulation parameters, and perform simulation distribution correction based on the latest uploaded sample features, thereby realizing the online adaptive evolution of the twin model.

[0076] In addition, to reduce the edge's real-time dependence on cloud communications, the system supports synchronizing the generated simulation sample feature distribution (i.e., reference distribution) and its corresponding simulation model version information to the edge device in a compressed format. After receiving this synchronized data, the edge device can use it as a local reference benchmark to independently complete drift monitoring and model self-calibration pre-judgment during subsequent operation. For example, the edge can regularly compare the real-time detection feature distribution with the reference distribution to determine whether there is data drift. If the drift exceeds the set threshold, it is marked as an incremental training event to be triggered.

[0077] This mechanism ensures that even when cloud connectivity is interrupted or network delays occur, edge devices can still maintain autonomous analysis and feedback capabilities, effectively improving the system's overall detection response speed, stability, and independent operation capabilities. It is suitable for scenarios in actual agricultural product production lines that have high requirements for speed and network robustness.

[0078] Furthermore, in order to maintain the accuracy and adaptive adjustment of the model during long-term operation, the system has designed a drift monitoring mechanism based on distribution comparison to identify whether there is statistical deviation in the characteristics of the current detection sample.

[0079] Specifically, the system generates a fusion feature vector for each test sample at the edge, and regularly collects feature vectors of multiple samples and uploads them to the cloud server. After the cloud receives the batch of data, it constructs a feature distribution model of the current test data, which is recorded as .

[0080] The system then extracts the reference distribution model that matches the current task conditions from the digital twin simulation module, which is recorded as , the reference distribution represents the standard distribution state of agricultural products in the multimodal feature space under the target variety, environment and historical data parameters.

[0081] To evaluate whether the current sample deviates from the reference state, the system uses probability distribution difference measurement methods, such as EarthMover's Distance (EMD) or Maximum Mean Difference (MMD), to calculate the distribution difference between the current test data and the reference simulation data in the feature space. .

[0082] When the difference index Exceeds the threshold set by the system , the system determines that the current detection sample has statistical drift, that is, the training distribution based on the current detection model is inconsistent with the actual characteristics. At this time, the system will automatically mark it as a drift trigger event and trigger subsequent modules such as digital twin simulation enhancement, synthetic sample generation, and model incremental training, thereby achieving adaptive updates of the model on the detection line.

[0083] The drift monitoring mechanism can effectively prevent the model's performance degradation due to factors such as variety changes, seasonal changes, origin differences, or equipment aging, ensuring that the model continues to maintain high-precision and high-robustness detection capabilities in actual production environments.

[0084] S3: Based on the difference monitoring results, digital twin simulation is performed, and collaborative optimization is achieved through a two-way knowledge distillation mechanism. The sorting equipment is driven according to the detection results to complete the agricultural product grading operation.

[0085] Furthermore, in order to achieve adaptive updating of the model under different varieties, batches, and environmental changes, the system designed a drift-triggered twin-enhanced closed-loop mechanism to dynamically adjust the amount of training sample generation according to the degree of data drift and control the closed-loop convergence.

[0086] Specifically, the system first calculates the distance between the multimodal feature distribution of the current detection sample and the pre-built digital twin reference distribution through the drift detection module, and uses EMD as the drift intensity indicator, which is recorded as When detected , triggering the closed-loop process.

[0087] In this closed loop, the system uses an improved saturation sample generation function to determine the number of digital twin synthetic samples to be generated based on the drift intensity. This function uses a Sigmoid mapping form to set a natural saturation value for the sample generation amount, as follows:

[0088] ;

[0089] in, represents the number of twin synthetic samples; Indicates the number of recent real samples; Indicates the maximum sample amplification factor; represents the exponential function; Indicates the slope of the control curve; Indicates drift intensity; Indicates the drift intensity threshold.

[0090] The system then calls the twin simulation model to generate synthetic samples that match the current detection scenario and mixes them with real samples to form an incremental training set. On the edge device side, the Online-EWC algorithm is used to quickly fine-tune the model.

[0091] In order to prevent unlimited iteration and resource redundancy, the present invention proposes a self-suppressing closed-loop convergence mechanism to determine whether the model has adapted to the current data distribution. Recalculate the drift strength of the edge model after the update If any of the following conditions is met, the closed-loop enhancement process is terminated and the model is considered to have adapted to the drift:

[0092] Less than the minimum threshold of the descent rate and continuously satisfied times, indicating that the drift decrease rate slows down;

[0093] and There is no significant decrease, indicating that the generated samples are saturated but the effect is marginally attenuated;

[0094] The maximum number of iterations has been reached.

[0095] It should be pointed out that in order to make the above closed-loop control process have higher stability and resource efficiency in the actual deployment environment, the present invention introduces two optimization designs in the key technical links to effectively deal with common problems in high-frequency agricultural product detection tasks.

[0096] First, to address the problem that traditional linear sample mapping methods are prone to causing an explosion in the number of synthetic samples and overloading training resources in scenarios with large drift, this paper proposes a design concept for a saturated sample generation function. By introducing a nonlinear mapping function in the form of a Sigmoid curve, the number of generated samples increases first and then slows down as the drift intensity increases, thereby achieving dynamic and controllable adjustment of the number of samples. This design can flexibly expand the training set according to different degrees of drift, and automatically tends to the upper limit when the drift is severe, avoiding resource exhaustion or sample redundancy during the model training phase, thereby significantly improving the system's response speed and training efficiency. It is particularly suitable for detection tasks with limited computing power or high real-time requirements on edge devices.

[0097] Secondly, in response to the problems of training oscillation, excessive updating or non-convergence determination that may occur in conventional closed-loop update strategies under continuous drift conditions, the present invention designs a self-suppressing closed-loop convergence mechanism. This mechanism dynamically determines whether the current model update has reached a convergence state by monitoring the change in the rate of decrease of the drift intensity and whether the number of synthetic samples has reached saturation. If any of the conditions is met, the update is actively terminated. This strategy can effectively avoid the model overfitting phenomenon caused by "overcompensation" and ensure that the system has stability and convergence while adapting quickly. Especially in actual scenarios with weak drift, boundary drift or irreversible structural offset, this mechanism can significantly reduce unnecessary repeated training cycles.

[0098] Through the above mechanism, the present invention realizes an integrated processing flow of drift detection, adaptive simulation sample generation, edge incremental training and closed-loop convergence control, which has the comprehensive advantages of high responsiveness, computing resource friendliness and strong adaptability.

[0099] Furthermore, to ensure that edge detection models maintain lightweight reasoning capabilities while maintaining the same discrimination accuracy and knowledge update capabilities as cloud models, the present invention preferably introduces a bidirectional knowledge distillation and collaborative compression mechanism to establish a continuous migration and feedback loop of model knowledge between the cloud and edge. This mechanism includes a knowledge distillation process from the cloud to the edge, and an error feedback distillation process from the edge to the cloud, thereby achieving continuous optimization of the detection model and model version consistency control under cloud-edge collaborative conditions.

[0100] Specifically, during the cloud-to-edge distillation process, the system first uses the full-precision deep model deployed on the cloud as the teacher model, freezing its current parameters. This teacher model then performs inference on uploaded real or synthetic samples, outputting knowledge information including classification probability distributions (soft labels) and intermediate layer embedding features. This knowledge information, along with the hard labels, is sent to the edge. The edge then loads its currently deployed lightweight model (the student model) and performs distillation training using a combination of soft and hard label supervision, preferably using a cross-entropy loss and Kullback–Leibler divergence optimization. This allows the edge model to rapidly absorb cloud knowledge and achieve behavioral alignment, even with limited computing power.

[0101] In the edge-to-cloud distillation feedback process, the present invention innovatively proposes to use the detection error information generated during the actual operation of the edge to perform reverse distillation optimization on the cloud model. Specifically, the edge records the prediction error characteristics of each sample during the inference process, such as the output offset vector, the hidden layer cosine deviation, etc., and compresses it into a structured error summary (for example, through Bloom filter hashing or compressed indexing) and regularly uploads it to the cloud. After receiving the error summary, the cloud introduces error distillation weights when training the full model to fine-tune the gradient influence of important samples in the cloud, thereby improving the cloud model's adaptability to real business drift samples.

[0102] In addition, the present invention also has a cloud-edge model consistency control mechanism. After multiple rounds of online incremental updates to the edge model, the system will regularly compare the performance indicators of the full cloud model and the current edge model on a common sample set. When the cloud-edge difference falls below the set threshold, the system generates a new unified model version number and pushes it to all edge nodes. At the same time, this version information and corresponding performance indicators are written to the model traceability log to ensure that the model behavior of each node is consistent and the update is traceable.

[0103] Through the above-mentioned bidirectional knowledge distillation mechanism, the present invention effectively opens up the knowledge migration channel between cloud-edge models, realizes the coordinated evolution of model compression and update capabilities, avoids the drift failure problem of edge models caused by long-term offline deployment, and also significantly accelerates the cloud model's absorption speed of on-site changes. It has the advantages of simple structure, rapid convergence, and flexible deployment, and is suitable for high-frequency model optimization needs in large-scale, multi-environment, and multi-modal agricultural product detection systems.

[0104] It's important to note that when testing large quantities of agricultural products, edge devices typically run on power-constrained and storage-constrained embedded platforms, such as industrial camera edge boxes and ARM+NPU combination modules. These platforms struggle to directly run large models while also requiring rapid adaptation to data drift caused by seasonal changes and shifts in production locations. Traditional approaches either sacrifice accuracy for inference speed or rely on frequent cloud-based updates, which can lead to high latency, high communication costs, and unstable systems.

[0105] Compared with conventional knowledge distillation technology, the method of the present invention abandons the one-way knowledge distillation mode of static compression from the large cloud model to the small edge model, and replaces the fragmented, inconsistent and opaque deployment mode of cloud-edge models with the "bidirectional error distillation + version collaborative control" mechanism. At the same time, it no longer relies on full retraining of the complete data set, but instead completes cloud-side self-repair with the support of local high-value feedback samples + structural distillation.

[0106] Furthermore, after completing sample testing and model updates, the present invention pushes the quality grade, anomaly warning information, and corresponding model version number generated by the edge or cloud to the sorting control system via industrial protocols, enabling automated execution. Simultaneously, test results and model change records are written to the traceability blockchain in a standardized document format, ensuring the entire process is traceable and auditable, further enhancing the transparency and reliability of the system.

[0107] Example 2. In an exemplary embodiment, an agricultural product detection system is also provided, including a detection module, which obtains detection data of the agricultural products to be tested, performs feature extraction on the detection data in the edge device to obtain a fused feature vector, and uses the edge model to perform real-time detection of the agricultural products based on the fused feature vector.

[0108] The difference monitoring module uploads the detection results and fused feature vectors to the cloud, builds a digital twin model in the cloud, generates a reference distribution and performs difference monitoring.

[0109] The optimization module performs digital twin simulation based on the difference monitoring results, realizes collaborative optimization through a two-way knowledge distillation mechanism, and drives the sorting equipment to complete the agricultural product grading operation based on the detection results.

[0110] If the above functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the portion that contributes to the prior art, or the portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes various media that can store program code, such as USB flash drives, mobile hard drives, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical disks.

[0111] The logic and / or steps represented in the flowcharts or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing the logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (e.g., a computer-based system, a system including a processor, or other system that can fetch and execute instructions from an instruction execution system, apparatus, or device). For purposes of this specification, a "computer-readable medium" can be any device that can contain, store, communicate, propagate, or transport a program for use by, or in conjunction with, an instruction execution system, apparatus, or device.

[0112] More specific examples (a non-exhaustive list) of computer-readable media include the following: an electrical connection with one or more wires (electronic devices), a portable computer disk cartridge (magnetic devices), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disc read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium, and then editing, interpreting, or processing in another suitable manner as necessary, and then storing it in a computer memory.

[0113] It should be understood that various components of the present invention may be implemented using hardware, software, firmware, or a combination thereof. In the above-described embodiments, multiple steps or methods may be implemented using software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented using hardware, as in another embodiment, any one of the following technologies known in the art or a combination thereof may be used: a discrete logic circuit having logic gate circuits for implementing logic functions on data signals, an application-specific integrated circuit having suitable combinational logic gate circuits, a programmable gate array (PGA), a field-programmable gate array (FPGA), etc.

[0114] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit the present invention. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention, which should all be included in the scope of the claims of the present invention.

Claims

1. A method for detecting agricultural products, characterized in that: include: Obtain the test data of the agricultural products to be tested, perform feature extraction on the test data in the edge device to obtain a fused feature vector, and use the edge model to perform real-time detection of the agricultural products based on the fused feature vector; Upload the detection results and fused feature vectors to the cloud, build a digital twin model in the cloud, generate a reference distribution, and perform difference monitoring; Based on the difference monitoring results, digital twin simulation is performed, and collaborative optimization is achieved through a two-way knowledge distillation mechanism. The sorting equipment is driven according to the test results to complete the agricultural product grading operation; The said building of a digital twin model in the cloud, generating a reference distribution and performing difference monitoring includes establishing a parameter space in the cloud based on historical test data and industry prior knowledge; Using a combination of simulation modeling and statistical sampling, simulated data equivalent to actual test data is generated from the parameter space; Summarize and analyze the simulation data to obtain the reference distribution ; The cloud statistics fusion feature vector distribution in the feature space to obtain the detection data distribution ; Using distance metric comparison and The calculated drift intensity and set threshold For comparison, if Considered to have no significant drift; like , marked as drift detection trigger, executing digital twin simulation; The execution of digital twin simulation based on the difference monitoring results includes setting a natural saturation value for sample generation based on the drift intensity using a Sigmoid mapping form quantity, and determining the number of digital twin synthetic samples to be generated, which is expressed as: ; in, represents the number of twin synthetic samples; Indicates the number of recent real samples; Indicates the maximum sample amplification factor; represents the exponential function; Indicates the slope of the control curve; Indicates drift intensity; represents the drift intensity threshold; The digital twin model is called in the cloud to generate Simulation test data, and the latest The real detection data are spliced ​​into an incremental training data set, and the edge model is updated according to the incremental training data set; Recalculate the drift strength of the edge model after the update If any of the following conditions is met, the closed-loop enhancement process is terminated and the model is considered to have adapted to the drift: Less than the minimum threshold of the descent rate and continuously satisfied times, indicating that the drift decrease rate slows down; and There is no significant decrease, indicating that the generated samples are saturated but the effect is marginally attenuated; The maximum number of iterations has been reached.

2. The agricultural product detection method according to claim 1, wherein: The detection data includes near-infrared reflectance spectra, deep ultraviolet fluorescence images, dielectric parameters, visible-SWIR images and auxiliary data.

3. The agricultural product detection method according to claim 2, wherein: The feature extraction includes performing targeted processing on different types of collected detection data to obtain multimodal features, and constructing an integrated encoding network to fuse the multimodal features. The specific steps include: Use convolutional neural network branches to extract low-order features of each modality; In the encoding stage, a cross-modal attention mechanism is added to achieve information alignment and complementarity; All modal features are concatenated into a fused feature vector.

4. The agricultural product detection method according to claim 3, wherein: The updating of the edge model according to the incremental training data set includes: loading the model weights after the most recent complete training on the edge model, using an elastic weight retention algorithm, limiting the drastic update of important parameters by adding a retention regularization term, adopting a small batch training method, setting an upper limit on the number of training rounds and training duration, training and updating the edge model, saving and synchronizing the updated edge model weights to the cloud, and immediately putting the updated model into real-time detection on the edge to realize online takeover of the new model.

5. The agricultural product detection method according to claim 4, wherein: The collaborative optimization achieved through the bidirectional knowledge distillation mechanism includes: the cloud uses the full-precision detection model to detect the data uploaded by the edge. The full-precision detection model is the main model version deployed in the cloud, and the edge model is the student model obtained by distillation and compression of the full-precision detection model. A dual loss is used at the edge, with cross entropy loss as the hard label and Kullback–Leibler divergence as the soft label for joint optimization, compressing the full cloud model knowledge into the edge model. After the edge model is put into testing, the prediction error vector is recorded for each sample and compressed and cached; The edge end regularly uploads the error hash table and high-weight samples. The cloud end uses the error hash table and high-weight samples as additional weights to fine-tune the full-precision detection model, so that the full-precision detection model can quickly absorb the latest drift characteristics on site and achieve two-way optimization between the cloud and the edge end.

6. An agricultural product detection system, applied to an agricultural product detection method according to any one of claims 1 to 5, characterized in that: include, The detection module obtains the detection data of the agricultural products to be tested, extracts features from the detection data in the edge device, obtains a fused feature vector, and uses the edge model to perform real-time detection of the agricultural products based on the fused feature vector; The difference monitoring module uploads the detection results and fused feature vectors to the cloud, builds a digital twin model in the cloud, generates a reference distribution, and performs difference monitoring; The optimization module performs digital twin simulation based on the difference monitoring results, realizes collaborative optimization through a two-way knowledge distillation mechanism, and drives the sorting equipment to complete the agricultural product grading operation based on the detection results.

Citation Information

Patent Citations

  • Agricultural product quality detection platform

    CN111127238A

  • Agricultural product processing quality traceability monitoring method and system based on edge nodes

    CN119476730A