Cross-hyperspectral equipment detection model migration method and device

Through the multi-task learning framework and the migration method of cross-hyperspectral device detection models, the hardware differences between different devices were solved, efficient and low-cost detection model migration was achieved, the detection accuracy and robustness were improved, and the large-scale application of hyperspectral technology in multiple fields was promoted.

CN120654772APending Publication Date: 2025-09-16INST OF INTELLIGENT MFG GUANGDONG ACAD OF SCI
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510973925.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-15
Publication Date
2025-09-16

AI Technical Summary

Technical Problem

The differences in hardware parameters between different hyperspectral devices make it difficult to reuse trained models across devices, resulting in a conflict between high engineering deployment costs and detection needs.

Method used

A multi-task learning framework is adopted to obtain the Master and Slave hyperspectral device datasets, perform correction processing and construct a multi-task loss objective function, build a cross-hyperspectral device detection model, and evaluate the success of the model migration through measured data.

Benefits of technology

It enhances the adaptability and detection accuracy of the model on different devices, reduces engineering deployment costs, and promotes the large-scale application of hyperspectral technology in industrial scenarios such as agricultural product testing, drug quality control, and semiconductor device defect detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120654772A_ABST
    Figure CN120654772A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of hyperspectral data analysis, in particular to a cross-hyperspectral equipment detection model migration method and device. Constructing a multi-task loss objective function based on the corrected hyperspectral equipment data set, a preset spectral encoder, a preset spectral decoder and a preset first proportion; training the primary detection network model according to the corrected hyperspectral equipment data set and the multi-task loss objective function; performing anomaly detection on the test set based on a cross-hyperspectral equipment detection model, and calculating to obtain an index according to actual measurement data and an anomaly detection result; when the index is smaller than a precision threshold value, a model migration success evaluation result is generated; by correcting a hyperspectral equipment data set and a multi-task learning framework, the adaptability of a cross-hyperspectral equipment detection model to different hyperspectral equipment data is enhanced, the cross-equipment detection precision and robustness are improved, the modeling cost is reduced, the detection quality and efficiency are guaranteed, and the engineering deployment efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of hyperspectral data analysis, and in particular to a method and apparatus for migrating detection models across hyperspectral devices. Background Art

[0002] Hyperspectral technology, as an advanced sensing method, combined with artificial intelligence, can achieve non-contact and accurate detection of agricultural product ingredients, drug quality, semiconductor device defects and other fields. Spectral feature analysis can be used to analyze complex tasks such as sample anomaly identification, component quantitative detection, and solid solution content prediction. However, the large-scale application of hyperspectral technology in industrial scenarios still faces a key bottleneck: hardware parameter differences between different equipment manufacturers (such as inter-device deviation and band alignment errors) make it difficult to reuse trained models across devices. If full-process modeling is implemented for each new device, it will incur high engineering deployment costs, which is in conflict with the rapidly growing demand for large-scale hyperspectral industrial testing. To address this problem, the present invention innovatively introduces a multi-task learning framework to construct a migration model with device generalization capabilities. Summary of the Invention

[0003] In order to address the above shortcomings in the prior art, the present invention proposes a method for migrating detection models across hyperspectral devices.

[0004] In order to solve the above technical problems, the technical solutions adopted by the present invention are as follows: A cross-hyperspectral device detection model migration method includes: obtaining a master hyperspectral device dataset and a slave hyperspectral device dataset; performing correction processing on the master hyperspectral device dataset and the slave hyperspectral device dataset to obtain a corrected hyperspectral device dataset; constructing a multi-task loss objective function based on the corrected hyperspectral device dataset, a preset spectral encoder, a preset spectral decoder and a preset first ratio; constructing a primary detection network model according to a preset network architecture; training the primary detection network model according to the corrected hyperspectral device dataset and the multi-task loss objective function to obtain a cross-hyperspectral device detection model; obtaining a test set from the corrected hyperspectral device dataset according to a preset second ratio; performing anomaly detection on the test set based on the cross-hyperspectral device detection model to obtain an anomaly detection result; obtaining measured data, and calculating an indicator based on the measured data and the anomaly detection result; judging whether the indicator is less than a preset accuracy threshold; and generating a model migration success evaluation result when the indicator is less than the accuracy threshold.

[0005] Furthermore, the correction processing of the Master hyperspectral device dataset and the Slave hyperspectral device dataset to obtain a corrected hyperspectral device dataset includes: generating a first combined dataset based on the Master hyperspectral device dataset and the Slave hyperspectral device dataset; obtaining the true value labels of the data in the first combined dataset to obtain a sample true value label set; segmenting the first combined dataset based on a preset deep model to obtain a segmentation mask set and an instance segmentation dataset; correcting the instance segmentation dataset to obtain an anomaly filtering dataset; and generating a corrected hyperspectral device dataset based on the sample true value label set, the anomaly filtering dataset, and the segmentation mask set.

[0006] Furthermore, the correction processing of the instance segmentation dataset to obtain the abnormality filtered dataset includes: obtaining three-channel bands from the instance segmentation dataset; generating a pseudo image based on the three-channel bands; performing denoising processing on the instance segmentation dataset based on the pseudo image to obtain a denoised dataset; obtaining white frame data and black frame data; performing black and white correction on the denoised dataset based on the white frame data and the black frame data to obtain a black and white corrected dataset; and performing abnormality filtering processing on the black and white corrected dataset to obtain an abnormality filtered dataset.

[0007] Furthermore, the multi-task loss objective function is constructed based on the corrected hyperspectral device dataset, the preset spectral encoder, the preset spectral decoder and the preset first ratio, including: calculating the training set data volume according to the preset first acquisition quantity, the corrected hyperspectral device dataset and the preset third ratio; constructing the source device reconstruction loss function based on the preset fourth ratio, the training set data volume, the corrected hyperspectral device dataset, the spectral encoder and the spectral decoder; obtaining the small sample Master hyperspectral device dataset and the small sample Slave hyperspectral device dataset from the corrected hyperspectral device dataset according to the preset second acquisition quantity; constructing the cross-device reconstruction loss function based on the small sample Master hyperspectral device dataset, the small sample Slave hyperspectral device dataset, the spectral encoder and the spectral decoder; constructing the anomaly recognition cross entropy loss function based on the spectral encoder, the preset exponential function and the preset anomaly detection decoder; constructing the multi-task loss objective function based on the first ratio, the source device reconstruction loss function, the cross-device reconstruction loss function and the anomaly recognition cross entropy loss function.

[0008] Furthermore, the calculation of the training set data volume based on the preset first acquisition quantity, the calibrated hyperspectral device data set and the preset third ratio includes: generating a second combined data set based on the small sample Master hyperspectral device data set and the small sample Slave hyperspectral device data set; obtaining a small sample ratio data set from the second combined data set according to the third ratio; obtaining a large sample Master hyperspectral device data set from the calibrated hyperspectral device data set according to the first acquisition quantity; generating a training set based on the small sample ratio data set and the large sample Master hyperspectral device data set; and performing data statistics on the training set to obtain the training set data volume.

[0009] Furthermore, the source device reconstruction loss function is constructed based on the preset fourth ratio, the training set data volume, the corrected hyperspectral device data set, the spectral encoder and the spectral decoder, including: obtaining the corrected Master hyperspectral device data set from the corrected hyperspectral device data set according to the fourth ratio; reconstructing the corrected Master hyperspectral device data set based on the spectral encoder and the spectral decoder to obtain a reconstructed Master hyperspectral device data set; and constructing the source device reconstruction loss function based on the corrected Master hyperspectral device data set, the reconstructed Master hyperspectral device data set and the training set data volume.

[0010] Furthermore, the cross-device reconstruction loss function is constructed based on the small-sample Master hyperspectral device dataset, the small-sample Slave hyperspectral device dataset, the spectral encoder and the spectral decoder, including: reconstructing the small-sample Slave hyperspectral device dataset based on the spectral encoder and the spectral decoder to obtain a reconstructed Slave hyperspectral device dataset; performing data statistics on the small-sample ratio dataset to obtain the data volume of the small-sample ratio dataset; and constructing a cross-device reconstruction loss function according to the data volume of the small-sample Master hyperspectral device dataset, the reconstructed Slave hyperspectral device dataset and the small-sample ratio dataset.

[0011] Furthermore, the anomaly recognition cross entropy loss function is constructed based on the spectral encoder, the preset exponential function and the preset anomaly detection decoder, including: analyzing the corrected Master hyperspectral device data set to obtain a category one-hot encoding set; and constructing the anomaly recognition cross entropy loss function based on the exponential function, the corrected Master hyperspectral device data set, the spectral encoder, the anomaly detection decoder, the preset anomaly category coefficient, the training set data volume and the category one-hot encoding set. Furthermore, the multi-task loss objective function is constructed based on the first ratio, the source device reconstruction loss function, the cross-device reconstruction loss function and the anomaly recognition cross-entropy loss function, including: dividing the second combined data set based on the first ratio to obtain a validation set; adjusting the preset first hyperparameter, the preset second hyperparameter and the preset third hyperparameter according to the validation set to obtain a model hyperparameter set; and constructing a multi-task loss objective function based on the model hyperparameter set, the source device reconstruction loss function, the cross-device reconstruction loss function and the anomaly recognition cross-entropy loss function.

[0012] Furthermore, a device for migrating a cross-hyperspectral device detection model includes: a first data acquisition module for acquiring a Master hyperspectral device dataset and a Slave hyperspectral device dataset; a data processing module for performing correction processing on the Master hyperspectral device dataset and the Slave hyperspectral device dataset to obtain a corrected hyperspectral device dataset; a function construction module for constructing a multi-task loss objective function based on the corrected hyperspectral device dataset, a preset spectral encoder, a preset spectral decoder and a preset first ratio; a model construction module for constructing a primary detection network model according to a preset network architecture; and a model training module. Used to train the primary detection network model according to the calibrated hyperspectral device dataset and the multi-task loss objective function to obtain a cross-hyperspectral device detection model; the second data acquisition module is used to obtain a test set from the calibrated hyperspectral device dataset according to a preset second ratio; the anomaly detection module is used to perform anomaly detection on the test set based on the cross-hyperspectral device detection model to obtain anomaly detection results; the indicator calculation module is used to obtain measured data and calculate the indicator based on the measured data and the anomaly detection results; the judgment module is used to judge whether the indicator is less than a preset accuracy threshold; the result evaluation module is used to generate a model migration success evaluation result when the indicator is less than the accuracy threshold.

[0013] The beneficial effects of the cross-hyperspectral device detection model migration method of the present invention are: At the data level, data sets are obtained from two hyperspectral devices with different detection ranges, and data sets of Master and Slave devices are obtained specifically, so that the model can fully learn the commonalities and differences of data from different devices, thereby enhancing its adaptability to data from various types of devices; in terms of model construction, the network architecture is combined with a multi-task learning framework to improve the model's ability to extract latent spatial information from different devices, breaking through the model reuse barriers caused by device differences, thereby enhancing the model's detection accuracy and robustness across hyperspectral devices; in the evaluation link, indicators are calculated based on measured data and anomaly detection results, and a rigorous evaluation mechanism is constructed to ensure the accuracy and reliability of the model after migration; this solution avoids the tedious and high cost of full-process modeling for each new device, reduces engineering deployment costs, and at the same time ensures detection quality and efficiency, effectively promoting the large-scale application of hyperspectral technology in industrial scenarios such as agricultural product testing, drug quality control, and semiconductor device defect detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] The above and / or additional aspects and advantages of the present invention will become apparent and readily understood from the following description of the embodiments with reference to the accompanying drawings, in which: Figure 1 A first flow chart of a method for migrating detection models across hyperspectral devices provided by an embodiment of the present invention; Figure 2 A second flow chart of a method for migrating detection models across hyperspectral devices provided by an embodiment of the present invention; Figure 3 A third flow chart of a method for migrating detection models across hyperspectral devices provided in an embodiment of the present invention; Figure 4 A fourth flow chart of a method for migrating detection models across hyperspectral devices provided in an embodiment of the present invention; Figure 5 A fifth flow chart of a method for migrating detection models across hyperspectral devices provided by an embodiment of the present invention; Figure 6 A sixth flow chart of a method for migrating detection models across hyperspectral devices provided in an embodiment of the present invention; Figure 7 A seventh flow chart of a method for migrating detection models across hyperspectral devices provided in an embodiment of the present invention; Figure 8 An eighth flow chart of a method for migrating a detection model across hyperspectral devices provided by an embodiment of the present invention; Figure 9 A ninth flow chart of a method for migrating detection models across hyperspectral devices provided in an embodiment of the present invention; Figure 10A schematic diagram of the structure of a device for migrating detection models across hyperspectral devices provided by an embodiment of the present invention; Figure 11 A detection model training diagram for a method for migrating detection models across hyperspectral devices provided by an embodiment of the present invention; Figure 12 A detection model inference diagram for a method for migrating detection models across hyperspectral devices provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0015] The technical solution of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the embodiments described are only some embodiments of the present invention, not all embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.

[0016] The terms "first," "second," "third," "fourth," and so on (if any) in the description and claims of the present invention and in the accompanying drawings are used to distinguish similar objects and are not necessarily used to describe a particular order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate, so that the embodiments described herein can be implemented in an order other than that shown or described herein. In addition, the terms "including" or "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or apparatus that includes a series of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, product, or apparatus.

[0017] For ease of understanding, the specific process of the embodiment of the present invention is described below. Figure 1 An embodiment of a method for migrating a detection model across hyperspectral devices according to an embodiment of the present invention includes: 101. Obtain the Master hyperspectral device dataset and the Slave hyperspectral device dataset; In this embodiment, a large amount of inspected sample data for model building is obtained through the Master hyperspectral device, and a small amount of inspected sample data for calibration migration and model building is obtained through the Master hyperspectral device and the Slave hyperspectral device, wherein the near-infrared shortwave detection range of the Master hyperspectral device is 885nm-1733nm, and the near-infrared shortwave detection range of the Slave hyperspectral device is 900nm-1700nm; and the sample data used for calibration migration must meet the requirement that the same sample is obtained on both the Master and Slave devices at the same time; in this embodiment, sample data of 1098 inspected blueberries are collected through the Master hyperspectral device, and sample data of 18 inspected blueberries are collected simultaneously through the Master hyperspectral device and the Slave hyperspectral device; sample data of 375 inspected blueberries for testing are collected through the Slave hyperspectral device; 102. Correct the Master hyperspectral device dataset and the Slave hyperspectral device dataset to obtain a corrected hyperspectral device dataset. 103. Constructing a multi-task loss objective function based on the calibrated hyperspectral device dataset, a preset spectral encoder, a preset spectral decoder, and a preset first ratio; In this embodiment, the spectral encoder is a spectral Transformer encoder, which learns to effectively reconstruct the input spectrum and extract features of anomaly identification information through the attention mechanism; the spectral decoder is a spectral Transformer decoder, which learns to map information back to the Master hyperspectral data feature space based on wavelength through the attention mechanism; a multi-task learning task of hyperspectral device data latent space sharing and anomaly detection is constructed by calibrating the hyperspectral device dataset, a preset spectral encoder, and a preset spectral decoder; 104. Constructing a primary detection network model according to a preset network architecture; 105. Train the primary detection network model based on the calibrated hyperspectral device dataset and the multi-task loss objective function to obtain a cross-hyperspectral device detection model; In this embodiment, the construction of the cross-hyperspectral device detection model utilizes a multi-task learning network architecture, which can integrate the feature information of data from different devices and learn common feature representations between devices, so that the model has the ability to migrate between different devices, solving the problem that the trained model is difficult to reuse across devices due to device differences; the network architecture is a Transformer network architecture, which consists of a fully connected layer, a batch normalization layer, a nonlinear operation layer, an embedding layer, a position encoder, a self-attention layer, a multi-head attention layer, a normalization layer, a residual connection layer, and an output layer; 106. Obtain a test set from the calibrated hyperspectral device data set according to a preset second ratio; 107. Perform anomaly detection on the test set based on the cross-hyperspectral device detection model to obtain anomaly detection results; 108. Obtain measured data and calculate indicators based on the measured data and anomaly detection results; 109. Determine whether the indicator is less than the preset accuracy threshold; 110. When the indicator is less than the accuracy threshold, the model migration success evaluation result is generated; In this example, 254 normal blueberry samples and 121 blueberry samples with insect infestations, totaling 375 blueberries, were collected to form a single blueberry anomaly detection slave hyperspectral device sample set (i.e., a test set). This was used to verify the detection accuracy of the cross-hyperspectral device detection model on the slave device, thereby evaluating whether the model could be successfully migrated. The accuracy threshold was 2%. This series of operations established a comprehensive model evaluation mechanism, which used quantitative indicators to judge the detection effect of the model on the new device, ensuring the accuracy and reliability of the model after migration, avoiding the need to implement full-process modeling for each new device and reducing project deployment costs. In this embodiment, at the data level, data sets are obtained from two hyperspectral devices with different detection ranges, and the master and slave device data sets are obtained specifically, so that the model can fully learn the commonalities and differences of data from different devices, thereby enhancing its adaptability to data from various types of devices; in terms of model construction, a network architecture combined with a multi-task learning framework is adopted to improve the model's ability to extract latent spatial information from different devices, breaking through the model reuse barriers caused by device differences, thereby enhancing the model's detection accuracy and robustness across hyperspectral devices; in the evaluation link, indicators are calculated based on measured data and anomaly detection results, and a rigorous evaluation mechanism is constructed to ensure the accuracy and reliability of the model after migration; this solution avoids the tedious and high cost of full-process modeling for each new device, reduces engineering deployment costs, and at the same time ensures detection quality and efficiency, effectively promoting the large-scale application of hyperspectral technology in industrial scenarios such as agricultural product testing, drug quality control, and semiconductor device defect detection.

[0018] See also Figure 2 A second embodiment of a method for migrating a detection model across hyperspectral devices according to an embodiment of the present invention includes: 201. Generate a first combined dataset based on the Master hyperspectral device dataset and the Slave hyperspectral device dataset; In this embodiment, the first combined dataset provides comprehensive and accurate data support for model training, verification, and testing, enabling the model to simultaneously learn data features, actual labels, and sample instance relationships, thereby optimizing model training results. 202. Obtain true value labels of data in the first combined dataset to obtain a sample true value label set; In this example, the true value label is an accurate annotation of the actual state of the sample, such as the ingredient content of agricultural products, the quality grade of pharmaceuticals, and whether semiconductor devices are defective. Obtaining this label set provides an accurate reference standard for subsequent model training and evaluation, enabling model learning and detection results to be compared with actual conditions, ensuring the accuracy and reliability of model training. 203. Segment the first combined dataset based on a preset depth model to obtain a segmentation mask set and an instance segmentation dataset; In this embodiment, the deep learning model YOLO is used to segment each blueberry region in the first combined dataset, thereby obtaining a mask (i.e., a segmentation mask) that filters out background, non-blueberry regions, and individual blueberry regions. The segmentation mask set can clearly distinguish different samples, allowing the model to analyze individual samples in subsequent training and testing, thereby improving the accuracy and specificity of detection. 204. Perform correction processing on the instance segmentation dataset to obtain an abnormality filtering dataset; 205. Generate a calibrated hyperspectral device dataset based on the sample true value label set, the anomaly filtering dataset, and the segmentation mask set; In this embodiment, a true value label set of samples is obtained to provide a reference for model training and evaluation, ensuring that the detection results are in line with reality and laying a solid foundation for accuracy and reliability; instance segmentation is performed with the help of a deep model to distinguish sample areas such as blueberries, avoid background interference, improve detection accuracy and pertinence, and preprocess the data set to effectively eliminate hardware parameter differences between devices, unify data format and feature distribution, and provide high-quality data for model learning; the final integrated calibrated hyperspectral device data set integrates data features, true value labels and instance division information, helping the model to comprehensively learn the intrinsic relationship of the data, optimize training effects, reduce repeated training costs and failure risks, and provide strong support for the large-scale application of hyperspectral technology in the field of industrial detection.

[0019] See also Figure 3 A third embodiment of a method for migrating a detection model across hyperspectral devices according to an embodiment of the present invention includes: 301. Obtain three channel bands from the instance segmentation dataset; 302. Generate a pseudo image based on the three-channel bands; 303. Performing denoising on the instance segmentation dataset according to the pseudo image to obtain a denoised dataset; In this embodiment, three-channel bands, i.e., three different wavelengths, are used to form a pseudo-RGB image as a segmentation image. Gaussian smoothing and noise reduction processing is performed on the instance segmentation dataset using the pseudo-RGB image, which can effectively suppress random noise in the data, reduce data fluctuations, and make the spectral signal smoother and more stable. 304. Acquire white frame data and black frame data; 305. Performing black-and-white correction on the noise reduction dataset according to the white frame data and the black frame data to obtain a black-and-white corrected dataset; In this embodiment, the formula for performing black and white frame correction on the noise reduction dataset is as follows: , where W is white frame data, D is black frame data, is the data in the denoised dataset, is the data in the black and white correction dataset; 306. Perform anomaly filtering on the black and white corrected data set to obtain an anomaly filtered data set; In this embodiment, the corrected black and white correction data set is further filtered for overexposed pixels, abnormal peaks or troughs such as sudden drops in spectral lines, and pixels without energy, thereby removing interference factors such as abnormal spectra, abnormal pixels, and dead pixels; In this embodiment, the selected three-channel bands are generated into a pseudo-image form that is convenient for data processing. The pseudo-image is used to perform Gaussian smoothing and denoising on the instance segmentation dataset, which can effectively suppress random noise in the data, reduce data fluctuations, and make the spectral signal smoother and more stable; black and white correction is performed with the help of white frame data and black frame data, and the device's own offset and gain errors are reduced through formula calculations, the data benchmarks of different devices are unified, and the data deviation caused by hardware differences is reduced; finally, the black and white corrected data are anomaly filtered to remove interference factors such as overexposed pixels and abnormal spectral peaks, so as to avoid misleading model training and detection results caused by noise data; after this processing, the dataset can not only truly reflect the spectral characteristics of the sample, but also significantly reduce the interference components in the data, providing high-quality data for the application of hyperspectral technology in agricultural product component analysis, drug quality testing, semiconductor defect detection and other fields, improving model training accuracy and reliability of detection results, reducing the risk of misjudgment due to data quality problems, and effectively promoting the efficient application of hyperspectral technology in industrial detection.

[0020] See also Figure 4 A fourth embodiment of a method for migrating a detection model across hyperspectral devices according to an embodiment of the present invention includes: 401. Calculate the training set data volume according to a preset first acquisition quantity, a calibration hyperspectral device data set, and a preset third ratio; 402. Constructing a source device reconstruction loss function based on a preset fourth ratio, a training set data volume, a calibration hyperspectral device data set, a spectral encoder, and a spectral decoder; In this embodiment, the spectral encoder maps the calibrated hyperspectral device dataset into a feature space, and the spectral decoder reconstructs it. The loss function measures the reconstruction error, prompting the model to learn the essential characteristics of the Master device data and provide a basic representation for subsequent cross-device migration. 403. Acquire a small sample Master hyperspectral device dataset and a small sample Slave hyperspectral device dataset from the calibrated hyperspectral device dataset according to a preset second acquisition quantity; In this embodiment, by synchronously collecting a small sample Master hyperspectral device dataset and a small sample Slave hyperspectral device dataset, we ensure that the spectral data of the same sample on different devices have temporal and spatial consistency, solve the problem of cross-device data alignment in small sample scenarios, and provide a direct basis for the model to learn the mapping relationship between devices; 404. A cross-device reconstruction loss function is constructed based on the small sample Master hyperspectral device dataset, the small sample Slave hyperspectral device dataset, the spectral encoder, and the spectral decoder. In this embodiment, the cross-device reconstruction loss function constrains the consistency of data from different devices in the feature space, reduces the feature distribution shift caused by hardware differences, and improves the model's adaptability to new devices. 405. Constructing an anomaly recognition cross entropy loss function based on the spectral encoder, the preset exponential function, and the preset anomaly detection decoder; In this embodiment, the anomaly detection decoder is a Transformer anomaly recognition decoder. The Transformer anomaly recognition decoder learns and combines spectral latent features to predict blueberry insect infestation. The anomaly recognition cross-entropy loss function optimizes anomaly recognition capabilities, and the exponential function enhances sensitivity to rare anomaly samples, improving detection accuracy. 406. Construct a multi-task loss objective function based on the first ratio, the source device reconstruction loss function, the cross-device reconstruction loss function, and the anomaly recognition cross entropy loss function; In this embodiment, the expression of the multi-task loss objective function is: , where is the first hyperparameter, is the second hyperparameter, This is the third hyperparameter. By weightedly balancing the reconstruction task (source device (Master device) and cross-device) and the anomaly detection task, the model learns the common features between devices while retaining the ability to discriminate abnormal patterns, achieving multi-objective optimization. In this embodiment, the source device reconstruction loss function uses a spectral encoder and a spectral decoder to capture the essential characteristics of the source device data, laying a solid foundation for cross-device migration; the cross-device reconstruction loss function constrains the consistency of data from different devices in the feature space, reduces the feature distribution offset caused by hardware differences, improves the model's adaptability to new devices, and significantly reduces the performance degradation caused by hardware differences; the anomaly recognition cross-entropy loss function combines the anomaly detection decoder and the exponential function, which can not only predict anomalies such as blueberry insect infestation based on spectral features, but also enhance the sensitivity to rare anomalies, greatly improving detection accuracy; finally, the multi-task loss objective function scientifically balances data reconstruction and anomaly detection tasks through hyperparameter weighting, so that the model can synchronously learn device commonalities and abnormal patterns, avoiding the limitations of single-task training. This solution effectively reduces the cost of new equipment modeling, promotes the large-scale implementation of hyperspectral technology in the field of industrial detection, and provides reliable guarantees for accurate detection in complex scenarios.

[0021] See also Figure 5 A fifth embodiment of a method for migrating a detection model across hyperspectral devices according to an embodiment of the present invention includes: 501. Generate a second combined dataset based on the small sample Master hyperspectral device dataset and the small sample Slave hyperspectral device dataset; 502. Obtain a small sample ratio dataset from the second combined dataset according to the third ratio; 503. Obtain a large-sample Master hyperspectral device dataset from the calibrated hyperspectral device dataset according to the first acquisition quantity; 504. Generate a training set based on the small sample ratio dataset and the large sample Master hyperspectral device dataset; In this embodiment, a small amount of sample data of 18 inspected blueberries is collected simultaneously by the Master and Slave hyperspectral devices for modeling and calibration migration (i.e., the second combined dataset). The third ratio is 80%, or it can be 80%, etc., depending on the specific detection situation. The first collection quantity is 1098. The large-sample Master hyperspectral device dataset is a large number of inspected sample datasets used for model building. The collected sample data of 18*80% inspected blueberries + 1098 inspected blueberries are used as the training set. This combination of "a small amount of cross-device data + a large amount of single-device data" not only preserves the calibration information between devices, but also enhances the model's ability to learn the mainstream data distribution through the large sample. 505. Perform data statistics on the training set to obtain the data volume of the training set; In this embodiment, a second combined dataset of small samples collected synchronously by the master and slave devices ensures spatiotemporal consistency of spectral data from the same sample across different devices, providing a precise alignment basis for model learning of inter-device mapping relationships and building a cross-device calibration "bridge" at a very low cost. A small-sample-ratio dataset is extracted from the combined data using the third ratio and fused with the large-sample master hyperspectral device dataset to generate a training set. This creates an optimized combination of "small cross-device data + large single-device data." This small sample preserves inter-device calibration information, guiding the model to learn common features, while the large sample strengthens learning of the mainstream data distribution, improving the model's ability to capture the fundamental characteristics of both normal and abnormal samples. This solution eliminates the need for large-scale, repeated data collection and annotation, saving significant manpower and resources. It is particularly suitable for scenarios where samples are scarce or device deployment costs are high. The processed training set enables the model to quickly adapt to new device hardware differences, enhancing cross-device migration capabilities and reducing model reuse barriers caused by device differences. This provides an economical and reliable solution for the efficient application of hyperspectral technology in multi-device scenarios such as agricultural product testing.

[0022] See also Figure 6 A sixth embodiment of a method for migrating a detection model across hyperspectral devices according to an embodiment of the present invention includes: 601. Obtain a calibrated Master hyperspectral device dataset from the calibrated hyperspectral device dataset according to a fourth ratio; In this embodiment, the correction Master hyperspectral device dataset is composed of all Master hyperspectral device data in the correction hyperspectral device dataset; 602. Reconstruct the corrected Master hyperspectral device dataset based on the spectral encoder and the spectral decoder to obtain a reconstructed Master hyperspectral device dataset; In this embodiment, the spectral encoder uses its powerful feature extraction capabilities to map the Master hyperspectral device data in the Master hyperspectral device dataset to the feature space and extract the core features of the data. The spectral decoder then converts the data in the feature space back into spectral data to complete data reconstruction. This allows the reconstructed data to better reflect the true spectral characteristics of the sample, providing higher-quality data for subsequent analysis. 603. Construct a source device reconstruction loss function based on the data set of the corrected Master hyperspectral device, the data set of the reconstructed Master hyperspectral device, and the data volume of the training set; In this embodiment, the source device reconstruction loss function is expressed as: , where is the spectral Transformer encoder, is the spectral Transformer decoder, It is the i-th training data in the correction Master hyperspectral device dataset, where M represents the Master hyperspectral device. It is the reconstructed Master hyperspectral device dataset in the reconstructed Master hyperspectral device dataset. is the amount of training set data. The source device reconstruction loss function is used to measure the performance of the model in reconstructing source device data, providing clear goals and directions for model training and optimization. In this embodiment, the source device reconstruction loss function constructed based on the corrected Master hyperspectral device dataset and the reconstructed Master hyperspectral device dataset quantifies the difference between the two and indicates the optimization direction for model training. Under its guidance, the model continuously adjusts parameters to improve data reconstruction capabilities, which not only deepens the learning of the Master device data characteristics, but also enhances the generalization performance, thereby reducing false positives and missed detections, significantly improving the accuracy and reliability of hyperspectral technology in detection in multiple fields, and effectively promoting the development of industrial applications.

[0023] See also Figure 7 A seventh embodiment of a method for migrating a detection model across hyperspectral devices according to an embodiment of the present invention includes: 701. Reconstruct the small sample Slave hyperspectral device dataset based on the spectral encoder and the spectral decoder to obtain a reconstructed Slave hyperspectral device dataset; In this embodiment, the spectral encoder uses the self-attention mechanism of the Transformer architecture to capture key features in spectral data (such as changes in spectral absorption peaks caused by insect infestation in blueberries). The reconstruction process removes device noise, enhances spectral features related to sample characteristics, and improves data quality. 702. Perform data statistics on the small sample ratio data set to obtain the data volume of the small sample ratio data set; 703. A cross-device reconstruction loss function is constructed based on the data volume of the small sample Master hyperspectral device dataset, the reconstructed Slave hyperspectral device dataset, and the small sample ratio dataset; In this embodiment, the expression of the cross-device reconstruction loss function is: , where It is a small amount of data used by the Master hyperspectral device for calibration migration (i.e., the small sample Master hyperspectral device data in the small sample Master hyperspectral device dataset). Cal stands for calibration. It is a small amount of data used by the slave hyperspectral device for calibration migration (i.e., the small sample slave hyperspectral device data in the small sample slave hyperspectral device dataset). It is the data reconstructed into the Master hyperspectral device space (i.e., the reconstructed Slave hyperspectral device data in the Slave hyperspectral device dataset). The cross-device reconstruction loss function forces the model to learn the common features of data from different devices, significantly improving the model's adaptability on new devices. In this embodiment, a cross-device reconstruction loss function is constructed based on the data volume of a small-sample Master hyperspectral device dataset, a small-sample Slave hyperspectral device dataset, and a small-sample ratio dataset. In this way, the model can mine common features between devices in a quantitative manner, significantly enhancing the adaptability of the model on new devices. In a small-sample scenario, there is no need to collect and process a large amount of data. Only a small amount of data collected synchronously by Master and Slave devices (such as 18 blueberry samples) can be used to complete data reconstruction and loss function construction, saving manpower, material resources, and time costs. This solution reduces the cost and time of repeated modeling for new devices (Slave devices), improves detection accuracy and reliability, and provides strong support for the large-scale application of hyperspectral technology in multiple fields.

[0024] See also Figure 8 An eighth embodiment of a method for migrating a detection model across hyperspectral devices according to an embodiment of the present invention includes: 801. Analyze the calibrated Master hyperspectral device dataset to obtain a category one-hot encoding set; 802. Constructing an anomaly recognition cross entropy loss function based on the exponential function, the calibrated Master hyperspectral device dataset, the spectral encoder, the anomaly detection decoder, the preset anomaly category coefficient, the training set data volume, and the category one-hot encoding set; In this embodiment, the expression of the anomaly identification cross entropy loss function is: , where is an exponential function, is the Transformer anomaly detection decoder, is the abnormal category coefficient, It is the first in the calibration of the Master hyperspectral equipment dataset. training samples, k is the index of all categories, It is Correction of Master hyperspectral equipment dataset Categorical one-hot encoding; In this embodiment, the calibrated Master hyperspectral device dataset is converted into a one-hot encoding set, and the unstructured information is converted into a binary numerical matrix, so that the data meets the requirements of the cross-hyperspectral device detection model for numerical input, avoiding model training errors caused by incompatible data types. The cross-entropy loss function constructed based on the exponential function, spectral encoder and anomaly detection decoder, combined with the anomaly category coefficient and the amount of training set data, can not only extract deep spectral features through the spectral encoder, but also use the exponential function to enhance the sensitivity to rare anomaly categories, avoiding detection bias caused by sample imbalance. One-hot encoding ensures accurate mapping of category information, so that the model can more clearly distinguish normal and abnormal samples. This solution optimizes the model's ability to discriminate complex spectral data, improves the accuracy of anomaly detection, and reduces the cost caused by missed detection or false detection in industrial scenarios, providing reliable technical support for the accurate detection of scenarios such as agricultural product pests and drug defects.

[0025] See also Figure 9 A ninth embodiment of a method for migrating a detection model across hyperspectral devices according to an embodiment of the present invention includes: 901. Divide the second combined dataset based on the first ratio to obtain a validation set; In this embodiment, the first ratio is 20%, and may also be 21%, etc., depending on the specific detection situation. The validation set is used to adjust the model hyperparameters; 902. Adjust a preset first hyperparameter, a preset second hyperparameter, and a preset third hyperparameter according to the validation set to obtain a model hyperparameter set; In this embodiment, hyperparameters directly affect the weight distribution of each subtask (source device reconstruction, cross-device reconstruction, and anomaly detection) in the multi-task loss function. Based on performance indicators (such as detection accuracy and reconstruction error) fed back from the validation set, hyperparameters are dynamically optimized to achieve an optimal balance between the model's device generalization capability and anomaly detection accuracy. 903. Construct a multi-task loss objective function based on the model hyperparameter set, the source device reconstruction loss function, the cross-device reconstruction loss function, and the anomaly identification cross entropy loss function; In this embodiment, the model can be controlled by a set of model hyperparameters to adjust the learned representations. The multi-task loss objective function can guide the model to more efficiently learn common features and abnormal patterns between devices, preventing a single task from overly dominating the training process and improving the overall performance of the model. In this embodiment, based on the detection accuracy, reconstruction error and other indicators fed back from the validation set, the hyperparameters are adjusted and the weights of each subtask in the multi-task loss function are optimized, so as to promote the model to strike a balance between device generalization and anomaly detection; the multi-task loss objective function finally constructed guides the model to efficiently learn the common and abnormal characteristics of devices, avoids single-task-dominated training, enhances the model's adaptability to different devices and detection accuracy, reduces industrial deployment costs, and provides reliable guarantees for the large-scale application of hyperspectral technology.

[0026] The above describes a method for migrating a detection model across hyperspectral devices in an embodiment of the present invention. The following describes an apparatus for migrating a detection model across hyperspectral devices in an embodiment of the present invention. Figure 10 In one embodiment of the present invention, a device for migrating a detection model across hyperspectral devices includes: The first data acquisition module 1 is used to acquire the Master hyperspectral device dataset and the Slave hyperspectral device dataset; The data processing module 2 is used to perform correction processing on the Master hyperspectral device dataset and the Slave hyperspectral device dataset to obtain a corrected hyperspectral device dataset; A function construction module 3 is used to construct a multi-task loss objective function based on the calibrated hyperspectral device dataset, a preset spectral encoder, a preset spectral decoder and a preset first ratio; Model building module 4, used to build a primary detection network model according to a preset network architecture; A model training module 5 is used to train the primary detection network model according to the calibrated hyperspectral device dataset and the multi-task loss objective function to obtain a cross-hyperspectral device detection model; A second data acquisition module 6 is configured to acquire a test set from the calibrated hyperspectral device data set according to a preset second ratio; Anomaly detection module 7, used to perform anomaly detection on the test set based on the cross-hyperspectral device detection model to obtain anomaly detection results; The indicator calculation module 8 is used to obtain the measured data and calculate the indicators based on the measured data and the anomaly detection results; A judgment module 9 is used to judge whether the indicator is less than a preset accuracy threshold; A result evaluation module 10 is used to generate a model migration success evaluation result when the indicator is less than the accuracy threshold; In this embodiment, at the data level, data sets are obtained from two hyperspectral devices with different detection ranges, and the master and slave device data sets are obtained specifically, so that the model can fully learn the commonalities and differences of data from different devices, thereby enhancing its adaptability to data from various types of devices; in terms of model construction, a network architecture combined with a multi-task learning framework is adopted to improve the model's ability to extract latent spatial information from different devices, breaking through the model reuse barriers caused by device differences, thereby enhancing the model's detection accuracy and robustness across hyperspectral devices; in the evaluation link, indicators are calculated based on measured data and anomaly detection results, and a rigorous evaluation mechanism is constructed to ensure the accuracy and reliability of the model after migration; this solution avoids the tedious and high cost of full-process modeling for each new device, reduces engineering deployment costs, and at the same time ensures detection quality and efficiency, effectively promoting the large-scale application of hyperspectral technology in industrial scenarios such as agricultural product testing, drug quality control, and semiconductor device defect detection.

[0027] The present invention and its embodiments are described above. This description is not restrictive. What is shown in the accompanying drawings is only one of the embodiments of the present invention, and the actual content is not limited to this. In short, if ordinary technicians in this field are inspired by it and do not depart from the purpose of the invention, they can creatively design structural methods and embodiments similar to the technical solution, which should all fall within the scope of protection of the present invention.

Claims

1. A method for migrating detection models across hyperspectral devices, characterized in that: include: Obtain the Master hyperspectral device dataset and the Slave hyperspectral device dataset; Correcting the Master hyperspectral device dataset and the Slave hyperspectral device dataset to obtain a corrected hyperspectral device dataset; A multi-task loss objective function is constructed based on a calibrated hyperspectral device dataset, a preset spectral encoder, a preset spectral decoder, and a preset first ratio; A primary detection network model is constructed according to the preset network architecture; The primary detection network model is trained based on the calibrated hyperspectral device dataset and the multi-task loss objective function to obtain a cross-hyperspectral device detection model. Obtaining a test set from the calibrated hyperspectral device dataset according to a preset second ratio; Perform anomaly detection on the test set based on the cross-hyperspectral device detection model to obtain anomaly detection results; Obtain measured data and calculate indicators based on the measured data and anomaly detection results; Determine whether the indicator is less than the preset accuracy threshold; When the indicator is less than the accuracy threshold, a model migration success evaluation result is generated.

2. The method for migrating detection models across hyperspectral devices according to claim 1, wherein: The correction processing of the Master hyperspectral device dataset and the Slave hyperspectral device dataset to obtain a corrected hyperspectral device dataset includes: Generate a first combined dataset according to the Master hyperspectral device dataset and the Slave hyperspectral device dataset; Obtaining the true value labels of the data in the first combined data set to obtain a sample true value label set; Segmenting the first combined dataset based on a preset deep model to obtain a segmentation mask set and an instance segmentation dataset; Correcting the instance segmentation dataset to obtain an abnormality filtered dataset; A calibrated hyperspectral device dataset is generated based on the sample ground truth label set, the anomaly filtering dataset, and the segmentation mask set.

3. The method for migrating a detection model across hyperspectral devices according to claim 2, wherein: The correction processing of the instance segmentation dataset to obtain the abnormality filtering dataset includes: Get three-channel bands from the instance segmentation dataset; Generate a pseudo image based on three-channel bands; Denoising the instance segmentation dataset according to the pseudo image to obtain a denoised dataset; Get white frame data and black frame data; Performing black-and-white correction on the noise reduction dataset according to the white frame data and the black frame data to obtain a black-and-white corrected dataset; Anomaly filtering is performed on the black and white corrected dataset to obtain an anomaly filtered dataset.

4. The method for migrating detection models across hyperspectral devices according to claim 1, wherein: The multi-task loss objective function is constructed based on the calibrated hyperspectral device dataset, the preset spectral encoder, the preset spectral decoder and the preset first ratio, including: The amount of training set data is calculated based on a preset first acquisition quantity, a calibration hyperspectral device data set, and a preset third ratio; A source device reconstruction loss function is constructed based on a preset fourth ratio, a training set data volume, a calibration hyperspectral device data set, a spectral encoder, and a spectral decoder; Acquire a small sample Master hyperspectral device dataset and a small sample Slave hyperspectral device dataset from the calibrated hyperspectral device dataset according to a preset second acquisition quantity; A cross-device reconstruction loss function is constructed based on a small-sample Master hyperspectral device dataset, a small-sample Slave hyperspectral device dataset, a spectral encoder, and a spectral decoder. Anomaly recognition cross entropy loss function is constructed based on the spectral encoder, the preset exponential function and the preset anomaly detection decoder; A multi-task loss objective function is constructed based on the first ratio, the source device reconstruction loss function, the cross-device reconstruction loss function and the anomaly recognition cross entropy loss function.

5. The method for migrating a detection model across hyperspectral devices according to claim 4, wherein: The method of calculating the training set data volume according to the preset first acquisition quantity, the calibration hyperspectral device data set, and the preset third ratio includes: Generate a second combined dataset based on the small sample Master hyperspectral device dataset and the small sample Slave hyperspectral device dataset; Obtaining a small sample ratio data set from the second combined data set according to the third ratio; Obtaining a large-sample Master hyperspectral device dataset from the calibrated hyperspectral device dataset according to the first acquisition quantity; Generate a training set based on the small sample ratio dataset and the large sample Master hyperspectral device dataset; Perform data statistics on the training set to obtain the data volume of the training set.

6. The method for migrating detection models across hyperspectral devices according to claim 4, wherein: The source device reconstruction loss function is constructed based on the preset fourth ratio, the training set data volume, the correction hyperspectral device data set, the spectral encoder and the spectral decoder, including: Obtaining a calibrated Master hyperspectral device dataset from the calibrated hyperspectral device dataset according to a fourth ratio; Reconstruct the corrected Master hyperspectral device dataset based on the spectral encoder and spectral decoder to obtain a reconstructed Master hyperspectral device dataset; The source device reconstruction loss function is constructed based on the amount of data of the corrected Master hyperspectral device dataset, the reconstructed Master hyperspectral device dataset and the training set.

7. The method for migrating detection models across hyperspectral devices according to claim 5, wherein: The cross-device reconstruction loss function is constructed based on the small sample Master hyperspectral device dataset, the small sample Slave hyperspectral device dataset, the spectral encoder, and the spectral decoder, including: The small sample Slave hyperspectral device dataset is reconstructed based on the spectral encoder and spectral decoder to obtain the reconstructed Slave hyperspectral device dataset; Perform data statistics on the small sample ratio data set to obtain the data volume of the small sample ratio data set; The cross-device reconstruction loss function is constructed based on the data volume of the small sample Master hyperspectral device dataset, the reconstructed Slave hyperspectral device dataset and the small sample ratio dataset.

8. The method for migrating detection models across hyperspectral devices according to claim 6, wherein: The anomaly recognition cross entropy loss function is constructed based on the spectral encoder, the preset exponential function and the preset anomaly detection decoder, including: Analyze the calibrated Master hyperspectral device dataset to obtain the category one-hot encoding set; The anomaly recognition cross entropy loss function is constructed based on the exponential function, the calibrated Master hyperspectral device dataset, the spectral encoder, the anomaly detection decoder, the preset anomaly category coefficient, the training set data volume and the category one-hot encoding set.

9. The method for migrating detection models across hyperspectral devices according to claim 5, wherein: The multi-task loss objective function is constructed based on the first ratio, the source device reconstruction loss function, the cross-device reconstruction loss function, and the anomaly recognition cross entropy loss function, including: Dividing the second combined dataset based on the first ratio to obtain a validation set; Adjusting a preset first hyperparameter, a preset second hyperparameter, and a preset third hyperparameter according to the validation set to obtain a model hyperparameter set; A multi-task loss objective function is constructed based on the model hyperparameter set, the source device reconstruction loss function, the cross-device reconstruction loss function, and the anomaly recognition cross-entropy loss function.

10. A device for migrating detection models across hyperspectral devices, characterized in that: include: The first data acquisition module is used to acquire the Master hyperspectral device dataset and the Slave hyperspectral device dataset; A data processing module is used to perform correction processing on the Master hyperspectral device dataset and the Slave hyperspectral device dataset to obtain a corrected hyperspectral device dataset; A function construction module, configured to construct a multi-task loss objective function based on a calibrated hyperspectral device dataset, a preset spectral encoder, a preset spectral decoder, and a preset first ratio; A model building module is used to build a primary detection network model based on a preset network architecture; A model training module is used to train the primary detection network model based on the calibrated hyperspectral device dataset and the multi-task loss objective function to obtain a cross-hyperspectral device detection model; A second data acquisition module is used to acquire a test set from the calibrated hyperspectral device data set according to a preset second ratio; Anomaly detection module, used to perform anomaly detection on the test set based on the cross-hyperspectral device detection model to obtain anomaly detection results; The indicator calculation module is used to obtain measured data and calculate indicators based on the measured data and anomaly detection results; A judgment module, used to judge whether the indicator is less than a preset accuracy threshold; The result evaluation module is used to generate a model migration success evaluation result when the indicator is less than the accuracy threshold.