Nondestructive detection method for aflatoxin content in corn feed based on deep learning

By combining hyperspectral image correction and deep learning models, the accuracy and precision issues of non-destructive testing of aflatoxin in corn feed in existing technologies have been resolved, enabling accurate detection of early and internal contamination and improving the stability and reliability of the detection.

CN121207884AInactive Publication Date: 2025-12-26BAOTOU VOCATIONAL & TECHN COLLEGE

Patent Information

Application Number
CN202511400722.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-28
Publication Date
2025-12-26
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing technologies that rely on visible surface features cannot accurately detect early or internal contamination of aflatoxin in corn feed, resulting in low precision and accuracy of non-destructive testing.

Method used

By acquiring hyperspectral images of corn feed, and correcting them based on white and dark reference standards, regions of interest are extracted, spectral data preprocessing is performed, and the data is input into a deep learning model. The light source intensity and model parameters are adjusted, and the model hyperparameters are optimized to ensure the quality of image and spectral data and improve detection accuracy.

Benefits of technology

It effectively eliminates noise and errors, improves image clarity and the reliability of spectral data, ensures that the model learns real features, enhances the stability and accuracy of detection, adapts to various sample conditions, prevents overfitting, and improves the accuracy of non-destructive detection of aflatoxin content.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121207884A_ABST
    Figure CN121207884A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of nondestructive testing, in particular to a corn feed aflatoxin content nondestructive testing method based on deep learning, which comprises the following steps: acquiring a hyperspectral image of a corn feed sample; correcting the hyperspectral image; taking the center of the corrected hyperspectral image as a base point, and extracting a plurality of regions of interest; determining whether the working state of the hyperspectral imaging system is stable based on the confidence coefficient fluctuation value, and adjusting the light source intensity of the hyperspectral image according to the ratio; determining the accuracy of the aflatoxin content predicted value based on the detection accuracy rate, and adjusting the weight attenuation coefficient of the deep learning model according to the difference value; and determining whether the stability of the aflatoxin content detection process is qualified or not based on the detection accuracy fluctuation value, and optimizing the deep learning model hyper-parameters according to the relative difference between the qualification rate fluctuation value and a preset qualification rate fluctuation value. The nondestructive detection accuracy of the aflatoxin content of the corn feed is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of nondestructive testing technology, and in particular to a nondestructive testing method for aflatoxin content in corn feed based on deep learning. Background Technology

[0002] Aflatoxin, primarily produced by Aspergillus flavus and Aspergillus parasiticus, is a class of fungal toxins with strong carcinogenicity and toxicity. During processing and storage, corn feed is highly susceptible to the growth of these molds due to improper humidity and temperature control, leading to aflatoxin contamination. Rapid and accurate detection of aflatoxin content in corn feed is crucial for ensuring feed safety and the healthy development of animal husbandry. Currently, standard detection methods for aflatoxin mainly rely on chromatographic techniques, such as high-performance liquid chromatography combined with fluorescence or mass spectrometry. While these methods offer high accuracy, they are destructive, requiring complex pretreatment processes such as crushing, extraction, purification, and derivatization of the sample. This process is cumbersome and time-consuming, with the detection cycle for a single sample potentially reaching several hours or even days. Furthermore, they rely on expensive large-scale instruments and specialized operators, resulting in high detection costs and making it difficult to meet the needs of on-site, real-time, and large-scale screening. Non-destructive testing techniques such as near-infrared spectroscopy and hyperspectral imaging have been extensively studied. These techniques can rapidly capture the physical and chemical information of samples without requiring complex sample pretreatment. In particular, hyperspectral technology can simultaneously acquire spatial information and continuous spectral information of samples, providing rich data dimensions for qualitative and quantitative analysis.

[0003] Chinese Patent Application Publication No. CN113506242A discloses a YOLO-based method for detecting aflatoxin in corn, comprising: S1, building a machine vision inspection platform, with a computer-controlled ultraviolet light source and an industrial camera asynchronously triggered to acquire color RGB images of corn in real time; S2, performing image processing and segmentation on the acquired corn images; S3, establishing a YOLO deep learning neural network detection model; and S4, identifying whether the segmented images are infected with aflatoxin in real time, obtaining the identification result, and outputting the identification result.

[0004] However, the existing technology has the following problems: it relies on visible surface features and cannot detect toxin contamination in its early stages or when the contamination occurs inside the corn kernels, resulting in missed detections. This leads to low accuracy in non-destructive testing of aflatoxin content in corn feed. Summary of the Invention

[0005] To address this issue, the present invention provides a non-destructive testing method for aflatoxin content in corn feed based on deep learning. This method overcomes the problem that existing technologies rely on visible surface features, which cannot detect toxin contamination in its early stages or when contamination occurs inside the corn kernels, leading to missed detections and low accuracy in non-destructive testing of aflatoxin content in corn feed.

[0006] To achieve the above objectives, this invention provides a non-destructive detection method for aflatoxin content in corn feed based on deep learning, comprising:

[0007] Obtain hyperspectral images of corn feed samples;

[0008] Hyperspectral images are corrected based on white and dark references, and the need for secondary correction is determined based on the contrast of the corrected hyperspectral images.

[0009] Using the center of the corrected hyperspectral image as the base point, several regions of interest are extracted;

[0010] The average spectral data of several regions of interest are preprocessed, and the quality of the average spectral data preprocessing is determined based on the signal-to-noise ratio of the spectral features of the regions of interest after preprocessing.

[0011] The preprocessed average spectral data is input into a deep learning model to obtain the predicted aflatoxin content and the prediction confidence level.

[0012] The confidence fluctuation value is determined based on the prediction confidence of corn feed samples to determine whether the working state of the hyperspectral imaging system is stable, and the light source intensity of the hyperspectral image is adjusted according to the ratio of the confidence fluctuation value to the preset confidence fluctuation value.

[0013] Chemical experiments were used to obtain the measured values ​​of aflatoxin content in multiple corn feed samples from the same batch. Based on the measured values ​​of aflatoxin content, the detection accuracy of aflatoxin content was determined to determine the accuracy of the predicted value of aflatoxin content. The weight decay coefficient of the deep learning model was adjusted according to the difference between the detection accuracy and the preset detection accuracy.

[0014] The detection accuracy of aflatoxin content in multiple consecutive batches is obtained to determine the fluctuation value of the detection accuracy, so as to determine whether the stability of the aflatoxin content detection process is qualified, and the hyperparameters of the deep learning model are optimized based on the relative difference between the qualified rate fluctuation value and the preset qualified rate fluctuation value.

[0015] Furthermore, the requirement for secondary correction is determined based on the comparison results where the contrast is less than or equal to a preset contrast, wherein,

[0016] The contrast ratio is determined based on the standard deviation and average value of the grayscale values ​​of the corrected hyperspectral image.

[0017] Furthermore, the process of extracting several regions of interest includes: using the center of the corrected hyperspectral image as the base point, dividing the hyperspectral image into several regions to be extracted, and determining the regions to be extracted as regions of interest based on the comparison results where the spectral similarity of the regions to be extracted is greater than a preset spectral similarity.

[0018] Furthermore, the determination of unqualified average spectral data preprocessing is based on the comparison results of spectral feature signal-to-noise ratios greater than preset spectral feature signal-to-noise ratios, wherein,

[0019] The spectral characteristic signal-to-noise ratio is determined based on the reflectance values ​​of the characteristic valleys, the reflectance values ​​at the characteristic peaks, and the noise standard deviation.

[0020] Furthermore, the determination that the spectral data quality stability status is unqualified is based on the comparison result of the confidence fluctuation value being greater than a preset confidence fluctuation value, wherein,

[0021] The confidence level fluctuation value is determined based on the standard deviation and mean of the predicted confidence level.

[0022] Furthermore, the process of adjusting the light source intensity of the hyperspectral image includes:

[0023] Calculate the ratio of the preset confidence fluctuation value to the confidence fluctuation value under the condition that the stability of spectral data quality is unqualified;

[0024] Based on the comparison results where the ratio is less than or equal to a preset ratio, the light source intensity is increased by a first preset intensity adjustment coefficient.

[0025] Based on the comparison results where the ratio is greater than a preset ratio, the light source intensity is increased by a second preset intensity adjustment coefficient.

[0026] Furthermore, the determination of whether the accuracy of the predicted aflatoxin content is unqualified is based on the comparison results of the detection accuracy rate being less than or equal to the preset detection accuracy rate, wherein,

[0027] The detection accuracy is determined based on the predicted aflatoxin content and the measured aflatoxin content.

[0028] Furthermore, the process of adjusting the weight decay coefficient of the deep learning model includes:

[0029] The difference between the accuracy of the predicted aflatoxin content and the preset accuracy under unqualified conditions;

[0030] Based on the comparison results where the difference is less than or equal to a preset difference, the weight attenuation coefficient is reduced by a first preset weight adjustment coefficient.

[0031] Based on the comparison results where the difference is greater than a preset difference, the weight attenuation coefficient is reduced by a second preset weight adjustment coefficient.

[0032] Furthermore, the determination of unsatisfactory detection process stability is based on a comparison result where the detection accuracy fluctuation value exceeds a preset detection accuracy fluctuation value, wherein,

[0033] The fluctuation value of the detection accuracy is determined based on the standard deviation and average value of the detection accuracy.

[0034] Furthermore, the process of optimizing the hyperparameters of the deep learning model includes:

[0035] Calculate the relative difference between the fluctuation value of the detection accuracy under the condition of unqualified detection process stability and the preset fluctuation value of the detection accuracy.

[0036] Based on the comparison results where the relative difference is less than or equal to a preset relative difference, the number of deep learning model training iterations is increased by a preset number adjustment coefficient.

[0037] Based on the comparison results where the relative difference is greater than the preset relative difference, the initial learning rate of the deep learning model is reduced by adjusting the preset learning rate coefficient.

[0038] Compared with existing technologies, the beneficial effects of this invention are as follows: This invention acquires and corrects hyperspectral images of corn feed samples, determines whether secondary correction is needed, extracts the region of interest (ROI), preprocesses the average spectral data of the ROI, judges its quality, and inputs it into a deep learning model to obtain the predicted value and confidence level of aflatoxin content. Then, based on the predicted confidence level, the light source intensity is adjusted; the detection accuracy is determined based on the measured values ​​from chemical experiments, and the model weight attenuation coefficient is adjusted; finally, the model hyperparameters are optimized based on the fluctuation values ​​of the detection accuracy across multiple batches. Hyperspectral image correction based on white and dark benchmarks effectively eliminates noise and errors caused by instrument-specific and external environmental factors during image acquisition, improving image contrast and clarity. Determining whether secondary correction is needed through contrast ensures that image quality remains at a high level, providing a reliable foundation for accurate ROI extraction and spectral analysis. High-quality images more accurately reflect the true characteristics of corn feed, avoiding deviations in subsequent analysis due to image distortion. Preprocessing the average spectral data of the ROI and judging its quality based on the spectral feature signal-to-noise ratio removes interference information from the spectral data, enhances useful signals, and improves the quality and reliability of the spectral data. Only with qualified spectral data input into the deep learning model can the model learn real and effective features, thereby obtaining accurate aflatoxin content predictions. This is because spectral data with a high signal-to-noise ratio can more clearly present the aflatoxin-related features in corn feed. Prediction confidence reflects the reliability of the model's prediction results. When the confidence fluctuates greatly, it indicates that the imaging system may be affected by factors such as unstable light sources. Adjusting the light source intensity can restore the system to stability, ensuring the stability of subsequently acquired images and spectral data. This is because a stable light source is one of the key factors for obtaining high-quality hyperspectral images and spectral data. Adjusting the model weight attenuation coefficient based on the detection accuracy and optimizing the model hyperparameters based on the detection accuracy fluctuation can continuously improve the model's performance and stability. Detection accuracy reflects the accuracy of the model's prediction. Adjusting the weight attenuation coefficient can prevent the model from overfitting and improve the model's generalization ability. Detection accuracy fluctuation reflects the model's stability on different batches of samples. Optimizing hyperparameters can enable the model to better adapt to various sample conditions and more accurately predict the aflatoxin content in corn feed, thereby improving the accuracy of non-destructive detection of aflatoxin content in corn feed.

[0039] Furthermore, this invention effectively eliminates noise introduced by the instrument itself and the external environment during hyperspectral image acquisition through the correction of white and dark reference images. The white reference image provides an ideal high reflectivity reference, while the dark reference image provides the background noise level under no illumination. The correction formula can accurately remove these interfering factors, making the image more realistically reflect the spectral characteristics of corn feed. Contrast, as a key feature value for determining whether secondary correction is needed, reflects the degree of dispersion of gray values ​​in the image. When the contrast is less than or equal to the preset contrast, it indicates that the gray distribution of the image is relatively concentrated, and there may be problems such as image blurring and unclear details. This may be due to incomplete correction or the introduction of new interference factors during the acquisition process. At this time, secondary correction is necessary. The spectral-spatial joint analysis method is used to comprehensively analyze image problems from both spectral and spatial dimensions. By analyzing the spectral deviation of each band, the abnormality of data in which bands is accurately located is determined. The spatial distribution non-uniformity analysis can discover problems such as illumination differences in different areas of the image. After adjusting the integration time and light source intensity, the image is re-acquired, improving the image quality and clarity.

[0040] Furthermore, this invention determines the region of interest based on spectral similarity, effectively avoiding the influence of edge effects and outliers. Edge regions may have inaccurate spectral information due to factors such as uneven illumination and imaging distortion, while outliers may be caused by noise or interference during the acquisition process. Compared with the spectrum of the central region of the image, regions with high spectral similarity are more representative and can accurately reflect the spectral characteristics of different parts of corn feed, such as straw, stems and leaves, and corn kernels, ensuring that the extracted spectral data is authentic and reliable. Multiple preprocessing methods combined with specific parameters can comprehensively remove noise and interference from the spectral data, improving the accuracy of model prediction. The confidence level fluctuation value reflects the stability of model prediction. When the confidence level fluctuation value is large, it indicates that the model's prediction results vary greatly on different samples, which may indicate model instability or data anomalies. By monitoring the confidence level fluctuation value, problems with the model can be identified and adjusted in a timely manner, ensuring that the model can provide reliable prediction results under different conditions, thus improving the stability and reliability of the detection.

[0041] Furthermore, this invention uses prediction confidence to reflect the reliability of the deep learning model's prediction results for aflatoxin content. The adjustment method is determined based on the ratio of a preset confidence fluctuation value to the confidence fluctuation value. When this ratio is less than or equal to the preset ratio, it indicates that the current confidence fluctuation value is relatively large, but the deviation is within a certain range. Slightly increasing the light source intensity can gradually improve the spectral data quality while avoiding excessive changes in light source intensity that could impact the imaging system, ensuring system stability. When the ratio is greater than the preset ratio, it indicates that the current confidence fluctuation value deviates significantly from the preset confidence fluctuation value, and the spectral data quality stability problem is more serious. Significantly increasing the light source intensity can more quickly improve spectral acquisition conditions, allowing the spectral data quality to reach a stable state as soon as possible, thereby improving the accuracy of subsequent model predictions.

[0042] Furthermore, this invention, by comparing the detection accuracy with the preset detection accuracy, intuitively judges the reliability of the deep learning model's prediction results, which helps ensure feed quality and safety. The weight decay coefficient is an important parameter in deep learning models used to prevent overfitting. It improves the model's generalization ability by limiting the size of the model parameters. When the detection accuracy is unqualified and the difference is less than or equal to the preset difference, it indicates that the model's overfitting degree is relatively mild. At this time, slightly reducing the weight decay coefficient can appropriately relax the restrictions on the model parameters while maintaining a certain generalization ability of the model, allowing the model to better learn the features in the data and improve prediction accuracy. When the difference is greater than the preset difference, it indicates that the model's overfitting problem is more serious. Significantly reducing the weight decay coefficient can more effectively suppress the overfitting phenomenon, which can not only effectively improve the model's prediction performance, but also ensure that the model has good generalization ability, thereby improving the stability and reliability of the entire aflatoxin content detection.

[0043] Furthermore, this invention reflects the accuracy of the deep learning model's prediction of aflatoxin content through detection accuracy, which helps to detect abnormal feed quality in a timely manner. Increasing the number of training iterations allows the model more opportunities to learn features and patterns in the data, optimize model parameters, improve the model's generalization ability and prediction accuracy, thereby improving the stability of the detection process. Reducing the initial learning rate allows the model to update parameters more smoothly during training, which helps the model find a better solution and improves the model's prediction consistency across different batches of data, thus enhancing the stability of the detection process. Attached Figure Description

[0044] Figure 1 This is a flowchart of a non-destructive detection method for aflatoxin content in corn feed based on deep learning, as described in an embodiment of the present invention.

[0045] Figure 2 This is a flowchart illustrating how to determine whether a secondary correction of the hyperspectral image is needed, as described in an embodiment of the present invention.

[0046] Figure 3 This is a flowchart for determining whether the average spectral data preprocessing is qualified according to an embodiment of the present invention;

[0047] Figure 4 This is a flowchart for determining whether the stability of spectral data quality is acceptable in an embodiment of the present invention. Detailed Implementation

[0048] To make the objectives and advantages of the present invention clearer, the present invention will be further described below with reference to embodiments; it should be understood that the specific embodiments described herein are merely for explaining the present invention and are not intended to limit the present invention.

[0049] Preferred embodiments of the present invention will now be described with reference to the accompanying drawings. Those skilled in the art should understand that these embodiments are merely illustrative of the technical principles of the present invention and are not intended to limit the scope of protection of the present invention.

[0050] It should be noted that the data in this embodiment are all derived from a comprehensive analysis and evaluation of historical test data and corresponding historical test results from the three months prior to this test. Those skilled in the art will understand that the determination of the above-mentioned parameters for any single item in this invention can be achieved by selecting the value with the highest percentage based on the data distribution as the preset standard parameter, using weighted summation to obtain the value as the preset standard parameter, substituting each historical data point into a specific formula and using the value obtained from that formula as the preset standard parameter, or other selection methods, as long as the invention can clearly define different specific situations in the single-item judgment process through the obtained values.

[0051] Please see Figure 1 The diagram shows a flowchart of a non-destructive detection method for aflatoxin content in corn feed based on deep learning, according to an embodiment of the present invention.

[0052] This invention provides a non-destructive detection method for aflatoxin content in corn feed based on deep learning, comprising:

[0053] Step S1: Obtain hyperspectral images of corn feed samples;

[0054] Step S2: Correct the hyperspectral image based on the white and dark references, and determine whether a secondary correction is needed based on the contrast of the corrected hyperspectral image.

[0055] Step S3: Using the center of the corrected hyperspectral image as the base point, extract several regions of interest;

[0056] Step S4: Preprocess the average spectral data of several regions of interest, and determine whether the average spectral data preprocessing is qualified based on the spectral signal-to-noise ratio of the regions of interest after preprocessing.

[0057] Step S5: Input the preprocessed average spectral data into the deep learning model to obtain the predicted value of aflatoxin content and the prediction confidence level.

[0058] Step S6: Determine the confidence fluctuation value based on the prediction confidence of the corn feed sample to determine whether the working state of the hyperspectral imaging system is stable, and adjust the light source intensity of the hyperspectral image according to the ratio of the confidence fluctuation value to the preset confidence fluctuation value.

[0059] Step S7: Obtain the measured values ​​of aflatoxin content in multiple corn feed samples from the same batch using chemical experiments. Determine the detection accuracy of aflatoxin content based on the measured values ​​of aflatoxin content to determine the accuracy of the predicted values ​​of aflatoxin content. Adjust the weight decay coefficient of the deep learning model according to the difference between the detection accuracy and the preset detection accuracy.

[0060] Step S8: Obtain the detection accuracy of aflatoxin content in multiple consecutive batches, determine the fluctuation value of the detection accuracy, and determine whether the stability of the aflatoxin content detection process is qualified. Optimize the hyperparameters of the deep learning model based on the relative difference between the qualified rate fluctuation value and the preset qualified rate fluctuation value.

[0061] Specifically, this invention acquires and corrects hyperspectral images of corn feed samples, determines whether secondary correction is needed, extracts the region of interest (ROI), preprocesses the average spectral data of the ROI, and inputs it into a deep learning model to obtain predicted values ​​and confidence levels for aflatoxin content. Then, the light source intensity is adjusted based on the predicted confidence level, the detection accuracy is determined based on measured values ​​from chemical experiments, and the model weight attenuation coefficient is adjusted. Finally, the model hyperparameters are optimized based on the fluctuation values ​​of detection accuracy across multiple batches. Hyperspectral image correction based on white and dark benchmarks effectively eliminates noise and errors caused by instrument limitations and external environmental factors during image acquisition, improving image contrast and clarity. The contrast-based determination of secondary correction ensures consistently high image quality, providing a reliable foundation for accurate ROI extraction and spectral analysis. High-quality images more accurately reflect the true characteristics of corn feed, avoiding deviations in subsequent analysis due to image distortion. Preprocessing the average spectral data of the ROI, and determining its quality based on the spectral signal-to-noise ratio, removes interference information from the spectral data, enhances useful signals, and improves the quality and reliability of the spectral data. Only qualified images... Spectral data must be input into the deep learning model to ensure that the model learns real and effective features, thereby obtaining accurate aflatoxin content predictions. This is because spectral data with a high signal-to-noise ratio can more clearly present the aflatoxin-related features in corn feed. Prediction confidence reflects the reliability of the model's prediction results. When the confidence fluctuates greatly, it indicates that the imaging system may be affected by factors such as unstable light sources. Adjusting the light source intensity can restore the system to stability, ensuring the stability of subsequently acquired images and spectral data. This is because a stable light source is one of the key factors for obtaining high-quality hyperspectral images and spectral data. Adjusting the model weight attenuation coefficient based on the detection accuracy and optimizing the model hyperparameters based on the fluctuation value of the detection accuracy can continuously improve the model's performance and stability. Detection accuracy reflects the accuracy of the model's prediction. Adjusting the weight attenuation coefficient can prevent the model from overfitting and improve the model's generalization ability. The fluctuation value of the detection accuracy reflects the model's stability on different batches of samples. Optimizing the hyperparameters can enable the model to better adapt to various sample conditions and more accurately predict the aflatoxin content in corn feed, thereby improving the accuracy of non-destructive detection of aflatoxin content in corn feed.

[0062] In this embodiment of the invention, the corn feed used is corn silage.

[0063] In this embodiment of the invention, the hyperspectral image is obtained by a pushbroom hyperspectral imager, and the light source is two 500W halogen lamps, which are symmetrically installed on both sides of the sample at a 45° angle, and the light source intensity is set to 80% of the maximum power.

[0064] Specifically, after acquiring the hyperspectral image, this embodiment of the invention corrects the hyperspectral image based on a white reference and a dark reference, using the following correction formula:

[0065]

[0066] Where R is the corrected hyperspectral image, R raw It is the original hyperspectral image, R white It is a white reference image, obtained through white Teflon, R dark It is a dark reference image, obtained by turning off the light source and completely covering the lens with a black cap.

[0067] Understandably, in order to reduce noise from the background and dark current in the camera, the near-infrared spectrometer system was calibrated according to the formula using a standard white board and lens cap before acquiring hyperspectral imaging data of corn feed.

[0068] Please see Figure 2 As shown, it is a flowchart for determining whether a secondary correction of the hyperspectral image is needed according to an embodiment of the present invention.

[0069] Specifically, in this embodiment of the invention, it is determined whether a second correction of the hyperspectral image is needed based on the comparison result between the contrast of the corrected hyperspectral image and the preset contrast.

[0070] When the contrast ratio is less than or equal to the preset contrast ratio, it is determined that the hyperspectral image needs to be corrected a second time.

[0071] When the contrast ratio is greater than the preset contrast ratio, it is determined that no secondary correction is needed for the hyperspectral image.

[0072] In this embodiment of the invention, the preset contrast ratio is 60. The preset contrast ratio is obtained by taking the minimum contrast ratio of several historical cases where secondary correction of hyperspectral images is not required. However, the above value is not limited to this, and those skilled in the art can adjust the value according to actual needs.

[0073] In this embodiment of the invention, the contrast ratio is the ratio of the standard deviation to the average value of the grayscale values ​​of the corrected hyperspectral image.

[0074] In this embodiment of the invention, the secondary correction method adopts a spectral-spatial joint analysis method. By analyzing the spectral deviation and spatial distribution non-uniformity of each band, the integration time and light source intensity are adjusted in a targeted manner before the image is re-acquired.

[0075] Specifically, this invention effectively eliminates noise introduced by the instrument itself and the external environment during hyperspectral image acquisition through the correction of white and dark reference images. The white reference image provides an ideal high reflectivity reference, while the dark reference image provides the background noise level under no illumination. The correction formula can accurately remove these interfering factors, making the image more realistically reflect the spectral characteristics of corn feed. Contrast, as a key feature value for determining whether secondary correction is needed, reflects the degree of dispersion of gray values ​​in the image. When the contrast is less than or equal to the preset contrast, it indicates that the gray distribution of the image is relatively concentrated, and there may be problems such as image blurring and unclear details. This may be due to incomplete correction or the introduction of new interference factors during the acquisition process. At this time, secondary correction is necessary. The spectral-spatial joint analysis method is used to comprehensively analyze image problems from both spectral and spatial dimensions. By analyzing the spectral deviation of each band, the data of which bands are abnormal can be accurately located. The spatial distribution non-uniformity analysis can find problems such as illumination differences in different areas of the image. After adjusting the integration time and light source intensity, the image is re-acquired, improving the image quality and clarity.

[0076] Specifically, the present invention uses the center of the corrected hyperspectral image as the base point to divide the hyperspectral image into several regions to be extracted, and determines whether the region to be extracted is a region of interest based on the comparison result of the spectral similarity of the region to be extracted with the preset spectral similarity.

[0077] When the spectral similarity is less than or equal to the preset spectral similarity, it is determined that the region to be extracted is not a region of interest.

[0078] When the spectral similarity is greater than the preset spectral similarity, the region to be extracted is determined to be a region of interest.

[0079] In this embodiment of the invention, the preset spectral similarity value is 0.85, but the above value is not limited to this, and those skilled in the art can adjust the value according to actual needs.

[0080] In this embodiment of the invention, the spectral similarity is 1 / (1 + Euclidean distance between the average spectrum of the region to be extracted and the reference spectrum), wherein the reference spectrum is the spectrum of the central region of the hyperspectral image.

[0081] In this embodiment of the invention, several regions of interest (ROIs) are extracted to avoid the influence of edge effects and outliers, ensure the representativeness of the extracted spectra, and obtain average spectral data including straw, stems and leaves, corn kernels, corn cobs and background.

[0082] Specifically, in this embodiment of the invention, the average spectral data of several regions of interest are preprocessed. The preprocessing includes Savitzky-Golay smoothing, multivariate scattering correction, standard normal variable transformation, and first or second derivative. The data preprocessing parameters include a Savitzky-Golay smoothing window size of 7 points, a polynomial order of 2, Z-score normalization, and a multivariate scattering correction reference wavelength of 1100 nm.

[0083] Please see Figure 3 As shown, it is a flowchart for determining whether the average spectral data preprocessing is qualified according to an embodiment of the present invention.

[0084] Specifically, in this embodiment of the invention, the preprocessing of average spectral data is determined to be qualified based on the signal-to-noise ratio of the spectral features of the region of interest after preprocessing.

[0085] When the spectral feature signal-to-noise ratio is less than or equal to the preset spectral feature signal-to-noise ratio, the average spectral data preprocessing is deemed qualified.

[0086] If the signal-to-noise ratio of the spectral features is greater than the preset signal-to-noise ratio of the spectral features, then the average spectral data preprocessing is determined to be unqualified.

[0087] In this embodiment of the invention, the preset spectral feature signal-to-noise ratio is 5, but the above value is not limited to this, and those skilled in the art can adjust the value according to actual needs.

[0088] In this embodiment of the invention, the process of obtaining the spectral characteristic signal-to-noise ratio is as follows: based on the characteristic absorption bands of aflatoxin in corn feed, a key band range is determined as the analysis interval, wherein the key band range is 1200-1300 nm; within the selected band range, the zero point of the first derivative and the extreme point of the second derivative are determined to locate the characteristic absorption peaks and adjacent characteristic valleys; in the flat band region without characteristic absorption, wherein the flat band region is 1050-1150 nm, the standard deviation of the spectral reflectance values ​​is calculated as the noise level assessment value; the spectral characteristic signal-to-noise ratio is the ratio of the absolute value of the difference between the reflectance value at the characteristic valley and the reflectance value at the characteristic peak to the noise standard deviation.

[0089] Specifically, in this embodiment of the invention, the preprocessed average spectral data is input into a pre-trained deep learning model. This deep learning model employs a convolutional neural network architecture, comprising 6 convolutional layers, 3 pooling layers, and 5 normalization layers. Each convolutional layer uses the ReLU activation function to enhance the model's nonlinearity. Finally, a fully connected layer outputs the prediction result. The model is trained using a mean squared error loss function and the Adam optimizer. After 100 training iterations, the predicted aflatoxin content and the prediction confidence of the model output are obtained. The deep learning model architecture parameters include: a 3×3 kernel size, a 1×1 stride, max pooling, a 2×2 pooling window, batch normalization, and a fully connected layer output dimension of 128. The training hyperparameters include an initial learning rate of 0.001, a batch size of 32, 100 training iterations, a mean squared error loss function, a weight decay coefficient of 0.0001, and a momentum parameter of 0.9.

[0090] Specifically, in this embodiment of the invention, the confidence fluctuation value is obtained based on the prediction confidence of multiple consecutive corn feed samples. The confidence fluctuation value is the ratio of the standard deviation to the mean of the prediction confidence.

[0091] Specifically, this invention determines the region of interest based on spectral similarity, effectively avoiding the influence of edge effects and outliers. Edge regions may have inaccurate spectral information due to factors such as uneven illumination and imaging distortion, while outliers may be caused by noise or interference during the acquisition process. Compared with the spectrum of the central region of the image, regions with high spectral similarity are more representative and can accurately reflect the spectral characteristics of different parts of corn feed, such as straw, stems and leaves, and corn kernels, ensuring that the extracted spectral data is authentic and reliable. Multiple preprocessing methods combined with specific parameters can comprehensively remove noise and interference from the spectral data, improving the accuracy of model prediction. The confidence level fluctuation value reflects the stability of the model prediction. When the confidence level fluctuation value is large, it indicates that the model's prediction results vary greatly on different samples, which may indicate model instability or data anomalies. By monitoring the confidence level fluctuation value, problems with the model can be identified and adjusted in a timely manner, ensuring that the model can provide reliable prediction results under different conditions, thus improving the stability and reliability of the detection.

[0092] Please see Figure 4 As shown, it is a flowchart for determining whether the stability status of spectral data quality is qualified according to an embodiment of the present invention.

[0093] Specifically, in this embodiment of the invention, the stability of spectral data quality is determined to be qualified based on the comparison result between the confidence fluctuation value and the preset confidence fluctuation value.

[0094] When the confidence fluctuation value is less than or equal to the preset confidence fluctuation value, the spectral data quality stability is determined to be qualified.

[0095] When the confidence fluctuation value is greater than the preset confidence fluctuation value, the spectral data quality stability is determined to be unqualified.

[0096] In this embodiment of the invention, the preset confidence fluctuation value is 0.08. The preset confidence fluctuation value is obtained by averaging the confidence fluctuation values ​​of several historical spectral data with acceptable quality stability. However, the above value is not limited to this, and those skilled in the art can adjust the value according to actual needs.

[0097] In this embodiment of the invention, the confidence level fluctuation value is the ratio of the standard deviation to the mean of the predicted confidence level.

[0098] Specifically, in the embodiments of the present invention, when the stability of spectral data quality is unqualified, the light source intensity of the hyperspectral image is adjusted based on the comparison result of the ratio of the preset confidence fluctuation value to the confidence fluctuation value and the preset ratio.

[0099] When the ratio is less than or equal to the preset ratio, it is determined that the light source intensity will be increased to the corresponding value by the first preset intensity adjustment coefficient;

[0100] When the ratio is greater than the preset ratio, it is determined that the light source intensity will be increased to the corresponding value by the second preset intensity adjustment coefficient;

[0101] The ratio is the ratio of the preset confidence level fluctuation value to the confidence level fluctuation value.

[0102] In this embodiment of the invention, the preset ratio is 0.8, but the above value is not limited to this, and those skilled in the art can adjust the value according to actual needs.

[0103] In this embodiment of the invention, the increased light source intensity is the product of the light source intensity and a preset intensity adjustment coefficient. The preset intensity adjustment coefficient includes a first preset intensity adjustment coefficient with a value of 1.05 and a second preset intensity adjustment coefficient with a value of 1.1. To ensure that the adjusted light source intensity is within the safe range of the equipment, the adjustment range should not be too large; therefore, an adjustment coefficient is set to control the adjustment range.

[0104] Specifically, this invention uses prediction confidence to reflect the reliability of the deep learning model's prediction results for aflatoxin content. The adjustment method is determined based on the ratio of a preset confidence fluctuation value to the confidence fluctuation value. When this ratio is less than or equal to the preset ratio, it indicates that the current confidence fluctuation value is relatively large, but the deviation is within a certain range. Slightly increasing the light source intensity can gradually improve the spectral data quality while avoiding the impact on the imaging system caused by excessive changes in light source intensity, thus ensuring system stability. When the ratio is greater than the preset ratio, it indicates that the current confidence fluctuation value deviates significantly from the preset confidence fluctuation value, and the spectral data quality stability problem is more serious. Significantly increasing the light source intensity can more quickly improve the spectral acquisition conditions, allowing the spectral data quality to reach a stable state as soon as possible, thereby improving the accuracy of subsequent model predictions.

[0105] Specifically, in this embodiment of the invention, high-performance liquid chromatography (HPLC) is used to obtain the measured values ​​of aflatoxin content in multiple corn feed samples from the same batch. The chemical detection process includes: weighing 5.00±0.05g of the prepared corn feed sample, adding 25mL of methanol-water solution with a volume ratio of 7:3, vortexing for 3 minutes, and ultrasonic extraction for 15 minutes; passing 5mL of the extract through an immunoaffinity column at a flow rate of 1 drop per second, washing the column with 10mL of ultrapure water, drying, and then... Elute with 0.5 mL of methanol; take 1 mL of eluent, add 1 mL of n-hexane and 0.5 mL of trifluoroacetic acid, vortex for 30 seconds, and react in a 40℃ water bath for 15 minutes; use a C18 column, with a mobile phase of water-methanol-acetonitrile (6:3:1, flow rate 1.0 mL / min), column temperature 30℃, and fluorescence detector; use the external standard method to plot a standard curve with a series of aflatoxin B1 standard solutions, and calculate the aflatoxin B1 content in the sample to obtain the measured aflatoxin content.

[0106] Specifically, in this embodiment of the invention, the detection accuracy is calculated based on the measured value of aflatoxin content and the predicted value of aflatoxin content. The detection accuracy is the ratio of (1 - the absolute value of the difference between the predicted value of aflatoxin content of the i-th sample and the measured value of aflatoxin content of the i-th sample to the measured value of aflatoxin content of the i-th sample) to the number of samples.

[0107] Specifically, in this embodiment of the invention, the accuracy of the predicted aflatoxin content is determined based on the comparison between the detection accuracy rate and the preset detection accuracy rate.

[0108] When the detection accuracy is less than or equal to the preset detection accuracy, the accuracy of the predicted aflatoxin content is determined to be unqualified.

[0109] When the detection accuracy rate is greater than the preset detection accuracy rate, the accuracy of the predicted aflatoxin content is determined to be qualified.

[0110] In this embodiment of the invention, the preset detection accuracy rate is 92%, but the above value is not limited to this, and those skilled in the art can adjust the value according to actual needs.

[0111] Specifically, in this embodiment of the invention, when the accuracy of the predicted value of aflatoxin content is determined to be unqualified, the weight attenuation coefficient of the deep learning model is determined based on the comparison result of the difference between the detection accuracy and the preset detection accuracy and the preset difference.

[0112] When the difference is less than or equal to the preset difference, it is determined that the weight attenuation coefficient will be reduced to the corresponding value by the first preset weight adjustment coefficient;

[0113] When the difference is greater than the preset difference, it is determined that the weight attenuation coefficient will be reduced to the corresponding value by the second preset weight adjustment coefficient.

[0114] The difference is the difference between the detection accuracy rate and the preset detection accuracy rate.

[0115] In this embodiment of the invention, the preset difference value is 5%, but the above value is not limited to this, and those skilled in the art can adjust the value according to actual needs.

[0116] In this embodiment of the invention, the reduced weight attenuation coefficient is the product of the weight attenuation coefficient and the preset weight adjustment coefficient. The preset weight adjustment coefficient includes a first preset weight adjustment coefficient with a value of 0.7 and a second preset weight adjustment coefficient with a value of 0.5. In order to ensure that the adjusted weight attenuation coefficient is within a reasonable range, the adjustment range should not be too large. Therefore, an adjustment coefficient is set to control the adjustment range.

[0117] Specifically, this invention directly assesses the reliability of deep learning model predictions by comparing the detection accuracy with a preset detection accuracy, which helps ensure feed quality and safety. The weight decay coefficient is an important parameter in deep learning models used to prevent overfitting. It improves the model's generalization ability by limiting the size of the model parameters. When the detection accuracy is unqualified and the difference is less than or equal to the preset difference, it indicates that the model's overfitting is relatively mild. In this case, slightly reducing the weight decay coefficient can appropriately relax the restrictions on the model parameters while maintaining a certain level of generalization ability, allowing the model to better learn the features in the data and improve prediction accuracy. When the difference is greater than the preset difference, it indicates that the model's overfitting problem is more serious. Significantly reducing the weight decay coefficient can more effectively suppress overfitting, effectively improving the model's prediction performance while ensuring that the model has good generalization ability, thus improving the stability and reliability of the entire aflatoxin content detection.

[0118] Specifically, in this embodiment of the invention, the detection accuracy of aflatoxin content in multiple consecutive batches is obtained, and the fluctuation value of the detection accuracy is calculated. Based on the comparison result of the fluctuation value of the detection accuracy with the preset fluctuation value of the detection accuracy, it is determined whether the stability of the aflatoxin content detection process is qualified.

[0119] When the detection accuracy fluctuation value is less than or equal to the preset detection accuracy fluctuation value, the stability of the detection process is determined to be qualified.

[0120] When the fluctuation value of the detection accuracy is greater than the preset fluctuation value of the detection accuracy, the stability of the detection process is determined to be unqualified.

[0121] In this embodiment of the invention, the preset detection accuracy fluctuation value is 0.1, but the above value is not limited to this, and those skilled in the art can adjust the value according to actual needs.

[0122] In this embodiment of the invention, the detection accuracy fluctuation value is the ratio of the standard deviation to the average value of the detection accuracy.

[0123] Specifically, in this embodiment of the invention, under the condition that the stability of the detection process is unqualified, the hyperparameters of the deep learning model are optimized based on the comparison results of the relative difference between the detection accuracy fluctuation value and the preset detection accuracy fluctuation value and the preset relative difference.

[0124] When the relative difference is less than or equal to the preset relative difference, it is determined that the number of training iterations of the deep learning model will be increased to the corresponding value by a preset number adjustment coefficient;

[0125] When the relative difference is greater than the preset relative difference, the initial learning rate of the deep learning model is reduced to the corresponding value by the preset learning rate adjustment coefficient;

[0126] The relative difference is the difference between the detection accuracy fluctuation value and the preset detection accuracy fluctuation value.

[0127] In this embodiment of the invention, the preset relative difference value is 0.4, but the above value is not limited to this, and those skilled in the art can adjust the value according to actual needs.

[0128] In this embodiment of the invention, the increased number of training iterations is the product of the initial number of training iterations and a preset adjustment coefficient, with the preset adjustment coefficient set to 1.15; the decreased learning rate is the product of the initial learning rate and a preset adjustment coefficient, with the preset adjustment coefficient set to 0.8. To ensure that the adjusted hyperparameters of the deep learning model are within a reasonable range, the adjustment range should not be too large; therefore, an adjustment coefficient is set to control the adjustment range.

[0129] Specifically, this invention uses detection accuracy to reflect the precision of a deep learning model in predicting aflatoxin content, which helps to detect abnormal feed quality in a timely manner. Increasing the number of training iterations allows the model more opportunities to learn features and patterns in the data, optimize model parameters, improve the model's generalization ability and prediction accuracy, thereby improving the stability of the detection process. Reducing the initial learning rate allows the model to update parameters more smoothly during training, which helps the model find better solutions and improves the model's prediction consistency across different batches of data, thus enhancing the stability of the detection process.

[0130] The technical solution of the present invention has been described above with reference to the preferred embodiments shown in the accompanying drawings. However, it will be readily understood by those skilled in the art that the scope of protection of the present invention is obviously not limited to these specific embodiments. Without departing from the principles of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after these changes or substitutions will all fall within the scope of protection of the present invention.

Claims

1. A deep learning-based non-destructive detection method for aflatoxin content in corn feed, characterized by, The method comprises the following steps: acquiring a hyperspectral image of a corn feed sample; correcting the hyperspectral image based on a white reference and a dark reference to determine whether secondary correction is needed based on the contrast of the corrected hyperspectral image; extracting a plurality of regions of interest based on the center of the corrected hyperspectral image as a reference point; preprocessing the average spectral data of the plurality of regions of interest, and determining whether the average spectral data preprocessing is qualified based on the spectral feature signal-to-noise ratio of the preprocessed regions of interest; inputting the preprocessed average spectral data into a deep learning model to obtain an aflatoxin content prediction value and a prediction confidence; determining a confidence fluctuation value based on the prediction confidence of the corn feed sample to determine whether the working state of the hyperspectral imaging system is stable, and adjusting the light source intensity of the hyperspectral image according to the ratio of the confidence fluctuation value to the preset confidence fluctuation value; acquiring actual measurement values of the aflatoxin content of a plurality of corn feed samples of the same batch through chemical experiments, determining the detection accuracy of the aflatoxin content based on the actual measurement values of the aflatoxin content, to determine the accuracy of the aflatoxin content prediction value, and adjusting the weight decay coefficient of the deep learning model according to the difference between the detection accuracy and the preset detection accuracy; acquiring a detection accuracy fluctuation value by acquiring the detection accuracy of the aflatoxin content of a plurality of batches in succession to determine whether the stability of the aflatoxin content detection process is qualified, and optimizing the hyperparameters of the deep learning model according to the relative difference between the qualified rate fluctuation value and the preset qualified rate fluctuation value.

2. The deep learning-based nondestructive detection method for corn feed aflatoxin content according to claim 1, characterized in that, The need for secondary correction is determined based on the comparison result that the contrast is less than or equal to a preset contrast. The contrast is determined according to the standard deviation and the average value of the gray value of the corrected hyperspectral image.

3. The deep learning-based non-destructive detection method of corn feed aflatoxin content according to claim 2, characterized in that, The process of extracting a plurality of regions of interest includes: dividing the corrected hyperspectral image into a plurality of regions to be extracted based on the center of the corrected hyperspectral image as a reference point, and determining that the region to be extracted is a region of interest based on the comparison result that the spectral similarity of the region to be extracted is greater than a preset spectral similarity.

4. The deep learning-based non-destructive detection method of corn feed aflatoxin content according to claim 3, characterized in that, The unqualified average spectral data preprocessing is determined based on the comparison result that the spectral feature signal-to-noise ratio is greater than a preset spectral feature signal-to-noise ratio. The spectral feature signal-to-noise ratio is determined according to the reflectivity value of the characteristic valley, the reflectivity value at the characteristic peak, and the noise standard deviation.

5. The deep learning-based non-destructive detection method of corn feed aflatoxin content according to claim 4, characterized in that, The unqualified spectral data quality stability state is determined based on the comparison result that the confidence fluctuation value is greater than a preset confidence fluctuation value. The confidence fluctuation value is determined according to the standard deviation and the average value of the prediction confidence.

6. The deep learning-based non-destructive detection method of corn feed aflatoxin content according to claim 5, characterized in that, The process of adjusting the light source intensity of the hyperspectral image includes: calculating the ratio of the preset confidence fluctuation value to the confidence fluctuation value under the condition of unqualified spectral data quality stability state; determining to increase the light source intensity by a first preset intensity adjustment coefficient based on the comparison result that the ratio is less than or equal to a preset ratio; determining to increase the light source intensity by a second preset intensity adjustment coefficient based on the comparison result that the ratio is greater than the preset ratio.

7. The deep learning-based non-destructive detection method of corn feed aflatoxin content according to claim 6, characterized in that, The unqualified accuracy of the aflatoxin content prediction value is determined based on the comparison result that the detection accuracy is less than or equal to a preset detection accuracy. The detection accuracy is determined according to the predicted value of the aflatoxin content and the measured value of the aflatoxin content.

8. The deep learning-based non-destructive detection method of corn feed aflatoxin content according to claim 7, characterized in that, The process of adjusting the weight decay coefficient of the deep learning model comprises: calculating the difference between the detection accuracy under the condition that the accuracy of the predicted value of the aflatoxin content is unqualified and the preset detection accuracy; determining to reduce the weight decay coefficient by the first preset weight adjustment coefficient based on the comparison result that the difference is less than or equal to the preset difference; determining to reduce the weight decay coefficient by the second preset weight adjustment coefficient based on the comparison result that the difference is greater than the preset difference.

9. The deep learning-based non-destructive testing method for corn feed aflatoxin content according to claim 8, characterized in that, The detection process stability is unqualified based on the comparison result that the detection accuracy fluctuation value is greater than the preset detection accuracy fluctuation value, wherein, The detection accuracy fluctuation value is determined according to the standard deviation and the average value of the detection accuracy.

10. The deep learning-based non-destructive detection method of corn feed aflatoxin content according to claim 9, characterized in that, The process of optimizing the hyperparameters of the deep learning model comprises: calculating the relative difference between the detection accuracy fluctuation value under the condition that the detection process stability is unqualified and the preset detection accuracy fluctuation value; determining to increase the training iteration number of the deep learning model by the preset number of adjustment coefficients based on the comparison result that the relative difference is less than or equal to the preset relative difference; determining to reduce the initial learning rate of the deep learning model by the preset learning rate adjustment coefficient based on the comparison result that the relative difference is greater than the preset relative difference.

Citation Information

Patent Citations

  • Corn aflatoxin detection method based on YOLO

    CN113506242A

Cited By

  • Chemical intermediate purity detection method and system based on chromatographic characteristics

    CN121805484A