Aflatoxin pixel-level detection method based on multiverse optimization
By applying multiverse optimization algorithm to optimize the CNN-BiLSTM model in aflatoxin detection, the problems of low accuracy and low efficiency of existing detection methods are solved, and higher detection accuracy and efficiency are achieved.
Patent Information
- Application Number
- CN202411061829.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-05
- Publication Date
- 2025-03-04
- Estimated Expiration
- 2044-08-05
AI Technical Summary
The existing aflatoxin pixel-level detection methods have low accuracy and low efficiency, and cannot fully utilize the intrinsic characteristics of the data, resulting in low detection accuracy and low detection efficiency.
The CNN-BiLSTM model based on multiverse optimization is adopted, and the MVO-CNN-BiLSTM model is constructed through data preprocessing and model hyperparameter optimization, and fine-tuned it to obtain the aflatoxin pixel-level detection model.
It greatly improves the accuracy and efficiency of pixel-level detection of aflatoxin, solves the problems of low detection accuracy and low efficiency, and has practical industrial application value and market potential.
Smart Images

Figure CN118858182B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence detection of food safety, and more specifically, to a pixel-level detection method of aflatoxin based on multiverse optimization. Background Art
[0002] Aflatoxin is a type of secondary metabolite produced by the genus Aspergillus that is highly carcinogenic. It is very easy to contaminate oil crops such as peanuts and corn, which in turn causes aflatoxin residues in peanuts, corn and their processed products, posing a huge safety hazard to food. In 1993, aflatoxin B1 (AFB1) was classified as a Class I carcinogen by the International Cancer Research Organization (IARC) of the World Health Organization (WHO). Aflatoxin is a highly toxic carcinogen that is 10 times more toxic than potassium cyanide and 68 times more toxic than arsenic. In addition to causing cancer, AFB1 can also cause pain, diarrhea, hepatotoxicity, cancer, and even death, affecting the development of related industries such as peanuts and corn.
[0003] For a long time, biochemical methods such as high performance liquid chromatography (HPLC) and enzyme-linked immunosorbent assay (ELISA) have been used to detect aflatoxins in food. However, these methods can only extract small samples from a batch of samples for testing. It is impossible to test every grain, and the processing process requires professional personnel and sophisticated instruments. In addition, the grains tested during the test will be crushed and cannot be reused. With the development of machine learning, aflatoxin detection based on traditional machine learning has developed, but traditional machine learning methods require feature selection of data, which relies heavily on prior knowledge and is very subjective. Artificial intelligence aflatoxin detection methods are gradually emerging.
[0004] However, existing AI-based aflatoxin detection methods mostly use traditional unidirectional neural networks, which train time series from front to back, limiting their ability to fully utilize the intrinsic characteristics of the data and severely restricting the accuracy of the model. They have the defects of low detection accuracy and overly complex detection models, resulting in low detection efficiency.
[0005] Therefore, it is urgent to develop a pixel-level aflatoxin detection method based on multiverse optimization that overcomes the above-mentioned defects. Summary of the invention
[0006] The present invention provides a pixel-level aflatoxin detection method based on multiverse optimization, so as to at least solve the problems of low accuracy and low efficiency of the existing pixel-level aflatoxin detection method.
[0007] To achieve the above object, the present invention provides a pixel-level detection method of aflatoxin based on multiverse optimization, comprising the following steps:
[0008] Data collection and processing steps: acquiring first historical spectral data of sample grains and performing data preprocessing to obtain second historical spectral data;
[0009] Model construction and optimization steps: constructing a CNN-BiLSTM model, optimizing the CNN-BiLSTM model based on a multiverse algorithm, and training the optimized CNN-BiLSTM model with the second historical spectrum data to obtain an MVO-CNN-BiLSTM model; fine-tuning the MVO-CNN-BiLSTM model to obtain an aflatoxin pixel-level detection model;
[0010] Aflatoxin detection steps: Input the spectral data of the grain to be tested into the aflatoxin pixel-level detection model to obtain the aflatoxin pixel-level detection results.
[0011] Furthermore, the data collection and processing step includes:
[0012] Acquire hyperspectral image data of sample grain as first historical spectral data, and perform data preprocessing on the first historical spectral data to obtain second historical spectral data;
[0013] The data preprocessing includes:
[0014] Performing denoising and enhancement processing on the first historical spectral data;
[0015] Obtaining a hyperspectral image cube of a single grain based on the first historical spectral data after denoising and enhancement processing;
[0016] Acquire a single pixel spectral curve pixel by pixel based on the hyperspectral image cube of the single grain;
[0017] Based on the hyperspectral image cube of the single grain, a plurality of bands are selected and weighted to generate a pseudo-color image, and a category label of a single pixel spectral curve is obtained based on the pseudo-color image;
[0018] A normalization operation is performed on the single pixel spectrum curve to obtain normalized single pixel spectrum data as second historical spectrum data.
[0019] Furthermore, the model building training step specifically includes:
[0020] Preliminary model building steps: Build the CNN-BiLSTM model and define the number of network layers and structure;
[0021] Model hyperparameter optimization step: inputting the second historical spectral data and the category label of the single pixel spectral curve into the CNN-BiLSTM model, and obtaining the optimal hyperparameter combination based on the multiverse optimization algorithm;
[0022] Model training step: configuring the CNN-BiLSTM model parameters based on the optimal hyperparameter combination, training the CNN-BiLSTM model through the second historical spectral data and the category label of the single pixel spectral curve, and obtaining an MVO-CNN-BiLSTM model;
[0023] Model fine-tuning step: fine-tune the MVO-CNN-BiLSTM model based on aflatoxin spectral data of different concentrations to obtain an aflatoxin pixel-level detection model.
[0024] Furthermore, the preliminary model building steps include:
[0025] Construct a convolutional model with a fixed number of layers. Each convolutional layer is connected to a batch normalization layer and a ReLU activation function, and the initial values of the hyperparameters are set.
[0026] Connecting a one-dimensional global average pooling and a flattening layer after the convolutional model;
[0027] Constructing a bidirectional long short-term memory model, connecting the convolutional layer through the one-dimensional global average pooling and flattening layer;
[0028] A random dropout layer, a fully connected layer, and a Softmax layer are connected after the bidirectional long short-term memory model to complete the construction of the CNN-BiLSTM model.
[0029] Furthermore, the model hyperparameter optimization steps include:
[0030] Initialization and parameter setting: Initialize several universes, each universe contains optimization variables: learning rate, number of convolution kernels and number of hidden layer neurons; set the search boundaries of the optimization variables, the number of convolution kernels and the number of hidden layer neurons are always set to integers; set the maximum number of iterations;
[0031] Iterative update: simulate the expansion of the universe and the wormhole effect, dynamically adjust the probability of wormhole existence and the exploration distance, calculate the fitness value of each universe, select and update the optimal universe;
[0032] Termination condition and output: Iterate until the maximum number of iterations is met to obtain the optimal hyperparameter combination, including: optimal learning rate, optimal number of convolution kernels, and optimal number of hidden layer neurons.
[0033] Furthermore, the model training step includes:
[0034] Based on the optimal hyperparameter combination, configure the learning rate, number of convolution kernels, and number of hidden layer neurons of the CNN-BiLSTM model;
[0035] Inputting the second historical spectral data and the category label of the single pixel spectral curve into the configured CNN-BiLSTM model, and training the CNN-BiLSTM model based on the optimizer using a weight decay strategy;
[0036] The model accuracy is verified at the end of each iteration cycle. If the model accuracy does not improve for multiple consecutive iteration cycles, the training is terminated to obtain the MVO-CNN-BiLSTM model.
[0037] Furthermore, the model fine-tuning step includes:
[0038] The weights and biases of the MVO-CNN-BiLSTM model are fixed, the MVO-CNN-BiLSTM model is exported, the aflatoxin spectral data with the minimum detection limit concentration is input into the MVO-CNN-BiLSTM model for fine-tuning, the weights and biases are updated, and the aflatoxin pixel-level detection model is obtained.
[0039] Furthermore, the model hyperparameter optimization step further includes:
[0040] Set the initial universe value to:
[0041]
[0042] Among them, U is a set of universes of size m×n; n is the variable dimension; m is the number of universes set, i.e., candidate solutions;
[0043] In each iteration, the universe is sorted according to its expansion rate and a white hole is chosen via a roulette wheel mechanism:
[0044]
[0045] Among them, r i is a random number in the range [0,1]; is the jth parameter of the ith universe; N I (U i ) represents the i-th universe U i The normalized expansion rate of ; k is a number selected according to the roulette mechanism;
[0046] In order to increase the expansion rate of a particular universe, the universe is connected to the optimal entity through a wormhole, and the parameters in the optimal domain are updated as follows:
[0047]
[0048] Among them, r2, r3 and r4 are all random numbers in the interval [0,1]; x j is the value of the jth parameter of the current optimal universe; l j and uj are the maximum and minimum values of the jth parameter respectively; R is the moving distance; P WEP is the possibility coefficient of wormhole existence; TDR is the travel distance rate coefficient, and its solution formula is as follows:
[0049]
[0050] Among them, P WEPmax and P WEPmin P WEP The maximum and minimum values of , l is the current number of iterations, L is the maximum number of iterations, and p is the degree of exploration.
[0051] Furthermore, the present invention provides a pixel-level aflatoxin detection system based on multiverse optimization, and the pixel-level aflatoxin detection method based on multiverse optimization is applied, comprising:
[0052] Data acquisition and processing module: used for acquiring first historical spectral data of sample grains and performing data preprocessing to obtain second historical spectral data;
[0053] Model building and optimization module: used to build a CNN-BiLSTM model, optimize the CNN-BiLSTM model based on the multiverse algorithm, and train the optimized CNN-BiLSTM model through the second historical spectrum data to obtain the MVO-CNN-BiLSTM model; fine-tune the MVO-CNN-BiLSTM model to obtain a pixel-level aflatoxin detection model;
[0054] Aflatoxin detection module: used to input the spectral data of the grain to be tested into the aflatoxin pixel-level detection model to obtain the aflatoxin pixel-level detection results.
[0055] Furthermore, the model building training module includes:
[0056] Model preliminary construction unit: construct the CNN-BiLSTM model and define the number of network layers and structure;
[0057] Model hyperparameter optimization unit: inputting the second historical spectrum data into the CNN-BiLSTM model, and obtaining an optimal hyperparameter combination based on a multiverse optimization algorithm;
[0058] Model training unit: configuring the CNN-BiLSTM model based on the optimal hyperparameter combination, training the CNN-BiLSTM model through the second historical spectral data, and obtaining an MVO-CNN-BiLSTM model;
[0059] Model fine-tuning unit: fine-tuning the MVO-CNN-BiLSTM model based on aflatoxin spectral data of different concentrations to obtain an aflatoxin pixel-level detection model.
[0060] Compared with the prior art, the advantages and positive effects of the present invention are:
[0061] The present invention provides a method for detecting aflatoxin at the pixel level based on a multiverse algorithm, and by constructing an MVO-CNN-BiLSTM model, the accuracy and efficiency of aflatoxin pixel-level detection are greatly improved, which is beneficial to the development of aflatoxin sorting equipment and has practical industrial application value and market potential.
[0062] The present invention improves the traditional bidirectional long short-term memory network and applies it to the pixel-level detection of aflatoxin, and applies it to the field of non-destructive detection of agricultural products, thereby solving the problems of low accuracy of the existing pixel-level detection method of aflatoxin and overly complex detection models, and improving the application level of pixel-level detection of aflatoxin.
[0063] The present invention optimizes the model hyperparameter combination based on the multiverse optimization algorithm, thereby improving the performance of the model and the accuracy of the model's aflatoxin pixel-level detection. At the same time, the multiverse optimization algorithm reduces the time and computing resources required to find the optimal parameters through an intelligent search strategy, and enhances the model's generalization ability.
[0064] The present invention uses a high-concentration aflatoxin spectral curve for model training and a lower-concentration aflatoxin spectral curve for fine-tuning, which greatly reduces the training time of the multiverse optimization algorithm to find the optimal parameter combination, and at the same time improves the classification accuracy to a certain extent. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] Figure 1 This is a schematic diagram of the process of the pixel-level detection method of aflatoxin based on multiverse optimization of the present invention;
[0066] Figure 2 This is a schematic diagram of the overall process of the pixel-level detection model of aflatoxin of the present invention;
[0067] Figure 3 This is a schematic diagram of the CNN-BiLSTM model structure of the present invention;
[0068] Figure 4 It is a schematic diagram of the structure of the BiLSTM module of the present invention;
[0069] Figure 5 It is a schematic diagram of the overall structure of the multiverse optimization algorithm of the present invention;
[0070] Figure 6This is a graph showing experimental results comparing the pixel-level aflatoxin detection method optimized based on the multiverse with other detection methods of the present invention;
[0071] Figure 7 Schematic diagram of aflatoxin pixel-level detection system based on multiverse optimization of the present invention;
[0072] Figure 8 This is a visualization interface diagram of pixel-level detection of aflatoxin based on multiverse optimization of the present invention.
[0073] In the above picture:
[0074] 100. Data acquisition and processing module; 200. Model building and optimization module; 300. Aflatoxin detection module. DETAILED DESCRIPTION
[0075] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0076] In the description of the present application, it should be understood that the terms "center", "upper", "lower", "front", "back", "left", "right", "vertical", "liquid level", "top", "bottom", "inside", "outside", etc., indicating the orientation or positional relationship, are based on the orientation or positional relationship shown in the accompanying drawings, and are only for the convenience of describing the present application and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present application. The terms "first" and "second" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the present application, unless otherwise specified, "multiple" means two or more.
[0077] In the description of this application, it should be noted that, unless otherwise clearly specified and limited, the terms "installed", "connected" and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in this application can be understood according to specific circumstances.
[0078] Aflatoxin is a type of secondary metabolite produced by Aspergillus that is highly carcinogenic. It is very easy to contaminate peanuts, corn and other oil crops, resulting in the presence of aflatoxin residues in peanuts, corn and their processed products, posing a great safety hazard to food. Therefore, it is urgent to develop an efficient and accurate aflatoxin detection method to achieve accurate detection of aflatoxin.
[0079] Embodiment 1
[0080] like Figure 1 As shown, the present invention provides a pixel-level detection method of aflatoxin based on multiverse optimization, comprising the following steps:
[0081] Data collection and processing step S100: acquiring first historical spectrum data and performing data processing to obtain second historical spectrum data;
[0082] Model building optimization step S200: constructing a CNN-BiLSTM model, and obtaining an optimal hyperparameter combination based on a multiverse algorithm; configuring the CNN-BiLSTM model based on the optimal hyperparameter combination, and training the CNN-BiLSTM model through the second historical spectral data to obtain an MVO-CNN-BiLSTM model; fine-tuning the MVO-CNN-BiLSTM model to obtain an aflatoxin pixel-level detection model;
[0083] Aflatoxin detection step S300: inputting the spectral data to be tested into the aflatoxin pixel-level detection model to obtain the aflatoxin pixel-level detection result.
[0084] like Figure 2 As shown, preferably, the data collection and processing step S100 includes:
[0085] Acquire hyperspectral image data of sample grain as first historical spectral data, and perform data preprocessing on the first historical spectral data to obtain second historical spectral data;
[0086] Data preprocessing includes:
[0087] Performing denoising and enhancement processing on the first historical spectral data;
[0088] Obtaining a hyperspectral image cube of a single grain based on the first historical spectral data after denoising and enhancement processing;
[0089] Acquire a single pixel spectral curve pixel by pixel based on the hyperspectral image cube of the single grain;
[0090] Based on the hyperspectral image cube of the single grain, a plurality of bands are selected and weighted to generate a pseudo-color image, and a category label of a single pixel spectral curve is obtained based on the pseudo-color image;
[0091] A normalization operation is performed on the single pixel spectrum curve to obtain normalized single pixel spectrum data as second historical spectrum data.
[0092] Preferably, the model building training step S200 specifically includes:
[0093] Model preliminary construction step S210: construct a CNN-BiLSTM model and define the number of network layers and structure;
[0094] like Figure 3 As shown, preferably, the preliminary model building step S200 includes:
[0095] Construct a convolutional model with a fixed number of layers. Each convolutional layer is connected to a batch normalization layer and a ReLU activation function, and the initial values of the hyperparameters are set.
[0096] Connecting a one-dimensional global average pooling and a flattening layer after the convolutional model;
[0097] Constructing a bidirectional long short-term memory model, connecting the convolutional layer through the one-dimensional global average pooling and flattening layer;
[0098] A random dropout layer, a fully connected layer, and a Softmax layer are connected after the bidirectional long short-term memory model to complete the construction of the CNN-BiLSTM model.
[0099] like Figure 4 As shown in the figure, the traditional unidirectional neural network is trained from forward to backward propagation when training time series, which limits its ability to fully utilize the intrinsic characteristics of the data and seriously restricts the accuracy of the model. The BiLSTM network introduces a reverse loop layer, which enables the model to access the forward and backward time steps at the same time. This bidirectional method allows the network to better utilize local and global information in the time series, enhance the model's feature extraction ability, and thus improve its classification accuracy. The calculation formula of the BiLSTM network is as follows:
[0100] h t =f(ω1x t +ω2h t-1 )
[0101] r t =f(ω3x t +ω5r t+1 )
[0102] y t =g(ω4h t +ω6r t )
[0103] Among them, h t is the output vector of the forward layer at time t; r t is the output vector of the backward layer at time t; yt is the output vector of the output layer at time t; x t is the input vector at time t; f() is the activation function of the forward layer and the backward layer; ω1 and ω3 are the weights from the input layer to the forward layer and the backward layer; ω2 and ω5 are the weights from the output of the forward layer and the backward layer at the previous moment to the current moment; ω4 and ω6 are the weights from the output of the forward layer and the backward layer to the output layer.
[0104] Model hyperparameter optimization step S220: Input the category labels of the second historical spectral data and the single pixel spectral curve into the CNN-BiLSTM model, and obtain the optimal hyperparameter combination based on the multiverse optimization algorithm.
[0105] Preferably, the model hyperparameter optimization step S220 includes:
[0106] Initialization and parameter setting: Initialize several universes, each universe contains optimization variables: learning rate, number of convolution kernels and number of hidden layer neurons; set the search boundaries of the optimization variables, the number of convolution kernels and the number of hidden layer neurons are always set to integers; set the maximum number of iterations;
[0107] Iterative update: simulate the expansion of the universe and the wormhole effect, dynamically adjust the probability of wormhole existence and the exploration distance, calculate the fitness value of each universe, select and update the optimal universe;
[0108] Termination condition and output: Iterate until the maximum number of iterations is met to obtain the optimal hyperparameter combination, including: optimal learning rate, optimal number of convolution kernels, and optimal number of hidden layer neurons.
[0109] like Figure 5 As shown, preferably, the multiverse algorithm is specifically:
[0110] Set the initial universe value to:
[0111]
[0112] Among them, U is a set of universes of size m×n; n is the variable dimension; m is the number of universes set, i.e., candidate solutions;
[0113] In each iteration, the universe is sorted according to its expansion rate and a white hole is chosen via a roulette wheel mechanism:
[0114]
[0115] Among them, r i is a random number in the range [0,1]; is the jth parameter of the i-th universe; N I (U i ) represents the i-th universe Ui The normalized expansion rate of ; k is a number selected according to the roulette mechanism;
[0116] In order to increase the expansion rate of a particular universe, the universe is connected to the optimal entity through a wormhole, and the parameters in the optimal domain are updated as follows:
[0117]
[0118] Among them, r2, r3 and r4 are all random numbers in the interval [0,1]; x j is the value of the jth parameter of the current optimal universe; l j and u j are the maximum and minimum values of the jth parameter respectively; R is the moving distance; P WEP is the possibility coefficient of wormhole existence; TDR is the travel distance rate coefficient, and its solution formula is as follows:
[0119]
[0120] Among them, P WEPmax and P WEPmin P WEP The maximum and minimum values of , l is the current number of iterations, L is the maximum number of iterations, and p is the degree of exploration.
[0121] Model training step S230: configuring a CNN-BiLSTM model based on an optimal hyperparameter combination, training the CNN-BiLSTM model through the second historical spectral data and the category label of a single pixel spectral curve, and obtaining an MVO-CNN-BiLSTM model;
[0122] Preferably, the model training step S230 includes:
[0123] Based on the optimal hyperparameter combination, configure the learning rate, number of convolution kernels, and number of hidden layer neurons of the CNN-BiLSTM model;
[0124] Input the second historical spectrum data and the category label of the single pixel spectrum curve into the configured CNN-BiLSTM model, and train the CNN-BiLSTM model using a weight decay strategy based on the optimizer;
[0125] The model accuracy is verified at the end of each iteration cycle. If the model accuracy does not improve for multiple consecutive iteration cycles, the training is terminated to obtain the MVO-CNN-BiLSTM model.
[0126] Specifically, the specific structure of the MVO-CNN-BiLSTM model is as follows: it includes a feature extraction unit, a model classification unit and a parameter optimization unit; the feature extraction unit selects a convolutional neural network as a feature extractor. Since the convolutional neural network has a powerful feature extraction function, it can extract global and local feature information; the model classification unit selects a bidirectional long short-term memory network for classification based on feature information; the parameter optimization unit adopts a multiverse optimization algorithm to obtain the optimal hyperparameter combination.
[0127] Model fine-tuning step S240: fine-tuning the MVO-CNN-BiLSTM model based on aflatoxin spectral data of different concentrations to obtain an aflatoxin pixel-level detection model.
[0128] Since the multiverse optimization algorithm takes a lot of time, the present invention uses a high-concentration aflatoxin peanut spectrum curve for training and searching for the optimal parameter combination. A low-concentration aflatoxin spectrum curve is used for fine-tuning to greatly save the training time of the model.
[0129] Preferably, the weights and biases of the MVO-CNN-BiLSTM model are fixed, the MVO-CNN-BiLSTM model is derived, the aflatoxin spectral data with the minimum detection limit concentration is input into the MVO-CNN-BiLSTM model for fine-tuning, the weights and biases are updated, and the aflatoxin pixel-level detection model is obtained.
[0130] Aflatoxin detection step S300: inputting the spectral data of the grain to be tested into the aflatoxin pixel-level detection model to obtain the aflatoxin pixel-level detection result.
[0131] Embodiment 2
[0132] The following describes in detail the specific application of the aflatoxin pixel-level detection method based on multiverse optimization of the present invention, using peanuts as a sample grain for aflatoxin detection.
[0133] Data collection and processing step S100: acquiring first historical spectrum data and performing data preprocessing to acquire second historical spectrum data.
[0134] Specifically, taking peanuts as an example, the first historical spectral data is obtained by collecting hyperspectral image data of sample peanuts. The sample peanuts are placed under a UV lamp, and the peanut kernels are placed in groups of 9 with the contaminated side facing up. 9 peanut kernels are collected each time, and images of 250 kernels are collected in sequence. The size of the hyperspectral image data block obtained each time is 1392×1040×33.
[0135] In some embodiments, the image acquisition experimental instrument uses a portable imager, which is mainly composed of a liquid crystal tunable filter (LCTF) and an ordinary CCD camera, with a spectral range of 400-720nm, a spectral bandwidth of 10nm, and a UV 365nm high-power LED ultraviolet lamp (LUY-OR-3404 desktop ultraviolet lamp from Luyang, USA, 7000 lumens of illumination at the sample) as a light source. The analysis of the hyperspectral image is completed using ENVI4.7 (ITT Visual Information Solutions, Boulder, Colo.). The hyperspectral imager supporting acquisition software can automatically adjust the exposure time at each wavelength according to the overall brightness of the image, thereby avoiding oversaturation and undersaturation.
[0136] Since each hyperspectral image data block contains 9 peanuts, there are also many backgrounds. The pixel values of the background pixels will affect the extraction of the peanut spectrum curve. At the same time, the uneven illumination when the light source illuminates the peanuts will also have a certain impact on the extraction of the peanut spectrum curve, greatly reducing the detection accuracy, which cannot meet the needs of practical application business. Therefore, it is necessary to preprocess the hyperspectral image data of the collected sample peanuts.
[0137] In some embodiments, the data preprocessing operation for the collected hyperspectral image data of the sample peanuts specifically includes:
[0138] Firstly, the hyperspectral image data of the sample peanuts is denoised and enhanced. The processing methods include but are not limited to: median filtering, contrast enhancement, threshold segmentation, binarization, opening operation, closing operation, band illumination compensation and morphological segmentation.
[0139] Specifically, median filtering is used to remove noise and maintain the edge information of peanut kernels; contrast enhancement is used to increase the brightness difference between peanut kernels and the background in hyperspectral images; threshold segmentation is used to segment the image into objects and background by setting a threshold so that areas with pixel values above the threshold are considered objects, and areas below the threshold are considered background; band illumination compensation calculates the average brightness of the connected domain of each peanut kernel and adjusts it to a consistent brightness level to reduce the impact of uneven illumination.
[0140] The hyperspectral image cube of a single peanut kernel is obtained by segmenting the hyperspectral image data of the sample peanuts based on denoising and enhancement processing; and the spectrum curve of a single pixel is extracted based on the hyperspectral image cube of a single peanut kernel.
[0141] Based on the hyperspectral image cube of a single peanut kernel, several bands are selected and weighted to generate a pseudo-color image, and the category label of a single pixel spectral curve is obtained based on the pseudo-color image; in some embodiments, three bands of 720nm, 440nm and 550nm are selected, and a pseudo-color image is generated by weighting, and the category of each pixel point is marked by the yellow-green fluorescence in the pseudo-color image. Pixels with yellow-green fluorescence are peanut pixels infected with aflatoxin, and pixels without yellow-green fluorescence are healthy peanut pixels. After the single pixel spectral curve is marked according to the category label, the single pixel spectral curve is normalized, and finally a peanut aflatoxin hyperspectral data set (UV-Peanuts) is formed.
[0142] The MVO-CNN-BiLSTM model is constructed and fine-tuned based on the method provided in Example 1, and finally a pixel-level aflatoxin detection model is obtained. The following specifically describes the model construction optimization step S200 based on peanuts as aflatoxin detection samples in combination with Example 1.
[0143] In some embodiments, the specific parameters of the CNN-BiLSTM model constructed in the preliminary model construction step S210 are: construct a two-layer convolution model, use it as a feature extractor to extract the feature information of the spectral data, and connect a batch normalization layer (BatchNormalization) and a ReLU activation function after each convolution layer. The first convolution layer uses 64 filters of size 4, and the step size is set to 1. The second convolution layer uses 64 filters of size 2, and the step size is set to 1. After the feature extraction is completed, the features are processed using a one-dimensional global average pooling and a flatten layer to convert the feature size into the input size of the bidirectional long short-term memory network. The features are processed using a bidirectional long short-term memory network with a specific number of hidden units, and then the random inactivation layer, the fully connected layer, and the Softmax layer are connected to obtain the category output.
[0144] In some embodiments, the specific parameters of the multiverse algorithm in the model hyperparameter optimization step S220 are: the multiverse algorithm initializes 5 universes (i.e., individuals), each universe contains optimization variables: learning rate, number of convolution kernels, and number of hidden layer neurons; the search boundary of the optimization variable is set to the minimum search boundary [0.0001, 2, 5], the maximum search boundary is [0.01, 64, 60], and the maximum number of iterations is set to 80. Among them, the optimization interval of the learning rate is 0.0001-0.01, the optimization interval of the number of convolution kernels is 2-64, and the optimization interval of the number of hidden layer neurons is 5-60. During the optimization process, the number of convolution kernels and the number of hidden layer neurons are always set to integers. In each iteration, the multiverse optimization algorithm selects and updates the optimal universe by calculating the fitness value of each universe, dynamically adjusts the probability of wormhole existence and the exploration distance, and finally finds the optimal learning rate, number of convolution kernels, and number of hidden layer neurons.
[0145] In some embodiments, the model training step S230 is implemented in NVIDIA RTX A6000, and the software version includes Matlab2023a. The optimal parameter combination found based on the multiverse optimization algorithm is specifically: the optimal learning rate is 5.37e-04, the optimal number of convolution kernels is 64, and the optimal number of hidden layer neurons is 19. The CNN-BiLSTM model is configured based on the optimal parameter combination, and the category labels of the above-mentioned peanut aflatoxin hyperspectral dataset and the single pixel spectral curve are input into the configured CNN-BiLSTM model, and trained using the Adam optimizer; to prevent the neural network from overfitting, a weight decay strategy is adopted during the training process, which is achieved by adding an additional term to the loss function. This additional term is the sum of the squares of the model parameters multiplied by a regularization coefficient, and its mathematical expression is:
[0146] Where λ is the regularization coefficient set to 1.00e-04; at the same time, the model early stopping strategy is adopted. Before the training starts, a performance metric is set and a counter is initialized to record the number of consecutive unimproved iterations. Before the training starts, a performance metric is set and a counter is initialized to record the number of consecutive unimproved iterations. At the end of each training cycle (epoch), the performance of the model is evaluated using the validation set. Here, the training cycle is set to 50 iterations. Compare the performance of the current cycle with the previous best performance. If the current performance is better, update the best performance record and reset the counter of the number of unimproved iterations. If the current performance has not improved, increase the counter of the number of unimproved iterations. If the number of unimproved iterations reaches the preset threshold, the preset threshold here is 50 times, then the model is considered to have converged and further training is stopped.
[0147] In some embodiments, since the multiverse optimization algorithm takes a lot of time, the present invention uses a high-concentration aflatoxin peanut spectral curve to train and search for the optimal parameter combination. A low-concentration aflatoxin spectral curve is used for fine-tuning to greatly save the training time of the model. Based on the test results, a 1000ppb concentration aflatoxin spectral curve is selected for model training, and a 20ppb concentration, i.e., the minimum detection limit concentration of aflatoxin spectral curve is selected for fine-tuning, which can effectively improve the recognition accuracy and generalization ability of the model and obtain an aflatoxin pixel-level detection model. This strategy not only greatly reduces the time and computing resources required for training the aflatoxin pixel-level detection model, but also ensures the high accuracy of the model when processing low-concentration aflatoxin spectral data.
[0148] In some embodiments, the spectral data of the peanuts to be tested is input into a pixel-level aflatoxin detection model to obtain a pixel-level aflatoxin detection result.
[0149] In some embodiments, in order to make effective comparisons between different models, comparative experiments were conducted between the MVO-CNN-BiLSTM model and some major detection models. The method of the present invention was compared with other detection models, including traditional machine learning algorithms (such as SVM, RF, NB, DT, AdaBoost, etc.) and deep learning models (such as CNN, LSTM, GRU and BiLSTM, etc.), as well as some complex network structures combined with self-attention mechanisms (such as BiLSTM+Self-Attention, CNN-Self+Attention, GRU+Self-Attention and LSTM+Self-Attention, etc.)
[0150] The above comparative experiments mainly evaluate the model by comparing accuracy and recall. The calculation formula of the evaluation index is as follows:
[0151]
[0152] Among them, TP is the number of samples correctly predicted by the model as positive; TN is the number of samples correctly predicted by the model as negative; FP is the number of samples incorrectly predicted by the model as positive; FN is the number of samples incorrectly predicted by the model as negative.
[0153] like Figure 6As shown, the accuracy and recall rates of different models were obtained through the above comparative experiments. Comparative analysis shows that in terms of recognition accuracy, the MVO-CNN-BiLSTM model of the present invention exceeds the CNN-LSTM model with an accuracy rate of 3.08%, and the accuracy rate is the highest in all comparative experiments. In terms of recall rate, the MVO-CNN-BiLSTM model of the present invention achieves the highest recall rate of 95.59%, which is 0.28% higher than the GRU+Self-Attention model. Therefore, the present invention provides a pixel-level detection method of aflatoxin based on multiverse optimization, which greatly improves the detection accuracy and efficiency in the actual application of pixel-level detection of aflatoxin, is conducive to the development of aflatoxin sorting equipment, and has practical industrial application value and market potential.
[0154] Embodiment 3
[0155] like Figure 7 As shown, the present invention provides a pixel-level aflatoxin detection system based on a multiverse, comprising:
[0156] Data acquisition and processing module 100: acquiring first historical spectrum data and performing data processing to obtain second historical spectrum data;
[0157] Model building optimization module 200: construct a CNN-BiLSTM model, obtain an optimal hyperparameter combination based on a multiverse algorithm; configure the CNN-BiLSTM model based on the optimal hyperparameter combination, and train the CNN-BiLSTM model with the second historical spectral data to obtain
[0158] MVO-CNN-BiLSTM model; fine-tuning the MVO-CNN-BiLSTM model to obtain a pixel-level aflatoxin detection model;
[0159] Aflatoxin detection module 300: inputs the spectral data to be tested into the aflatoxin pixel-level detection model to obtain the aflatoxin pixel-level detection result.
[0160] The model building training module includes:
[0161] Model preliminary construction unit: construct the CNN-BiLSTM model and define the number of network layers and structure;
[0162] Model hyperparameter optimization unit: inputting the second historical spectrum data into the CNN-BiLSTM model, and obtaining an optimal hyperparameter combination based on a multiverse optimization algorithm;
[0163] Model training unit: configuring the CNN-BiLSTM model based on the optimal hyperparameter combination, training the CNN-BiLSTM model through the second historical spectral data, and obtaining
[0164] MVO-CNN-BiLSTM model;
[0165] Model fine-tuning unit: fine-tuning the MVO-CNN-BiLSTM model based on aflatoxin spectral data of different concentrations to obtain an aflatoxin pixel-level detection model.
[0166] like Figure 8 As shown, in some embodiments, the above-mentioned multiverse-based aflatoxin pixel-level detection system can realize pixel-level detection of aflatoxin in peanut seeds and visualization of detection results.
[0167] The system was developed based on Matlab software (2024a). The pixel-level detection of aflatoxin in peanut kernels and the visualization interface of the test results are as follows:
[0168] Load in the "Select Model" drop-down list of the visualization interface. When the user selects "MVO-CNN-BiLSTM" in the "Select Model" function, the system will load the built model. The model loaded when loading the program is a 1×1 SeriesNetwork format variable, which contains Layers, InputNames, and OutputNames. Layers contains the name of each layer of the trained structure, step size, weight, bias, weight initialization method, filter size, number of channels, number of filters, and input and output data size in the layer.
[0169] The "Data Type" drop-down list allows you to select whether the uploaded data is sequence data or hyperspectral image data. If it is sequence data, upload a data file in xlsx format. If it is hyperspectral image data, upload a hyperspectral data file in mat format.
[0170] The "Upload Data File" button can be used to upload data files of the corresponding format in the computer. Since it takes a certain amount of time to upload the hyperspectral image data, the spectral curve of each pixel will be displayed in the "Hyperspectral Image Pixel Spectral Curve" coordinate area after the upload is completed.
[0171] After clicking the “Start Analysis” button, the system will call the selected model to analyze the uploaded hyperspectral image data to determine whether it belongs to the health category or the aflatoxin category.
[0172] In the "Test Results" display area, the number of all pixels in the hyperspectral cube, as well as the number of pixels containing aflatoxin and the number of healthy pixels detected by the model are displayed. Aflatoxin detection is also visualized. An image of the entire peanut kernel is displayed, as well as the predicted location of the toxin, with different colors used to mark the background (black), healthy (yellow), and toxin (purple) pixel areas.
[0173] The visual interface allows for easy operation and interpretation of test results, which improves the usability and practicality of the multiverse-based aflatoxin pixel-level detection system.
[0174] The above description is only a preferred embodiment of the present invention and does not limit the present invention in other forms. Any technician familiar with the profession may use the technical content disclosed above to change or modify it into an equivalent embodiment with equivalent changes and apply it to other fields. However, any simple modification, equivalent change and modification made to the above embodiment based on the technical essence of the present invention without departing from the content of the technical solution of the present invention still falls within the protection scope of the technical solution of the present invention.
Claims
1. A pixel-level aflatoxin detection method based on multiverse optimization, characterized in that: The following steps are involved: Data collection and processing steps: acquiring first historical spectral data of sample grains and performing data preprocessing to obtain second historical spectral data; Model construction and optimization steps: constructing a CNN-BiLSTM model, optimizing the CNN-BiLSTM model based on a multiverse algorithm, and training the optimized CNN-BiLSTM model with the second historical spectrum data to obtain an MVO-CNN-BiLSTM model; fine-tuning the MVO-CNN-BiLSTM model to obtain an aflatoxin pixel-level detection model; Aflatoxin detection steps: Input the spectral data of the grain to be tested into the aflatoxin pixel-level detection model to obtain the aflatoxin pixel-level detection results.
2. The aflatoxin pixel-level detection method based on multiverse optimization according to claim 1 is characterized in that: The data collection and processing steps include: Acquire hyperspectral image data of sample grain as first historical spectral data, and perform data preprocessing on the first historical spectral data to obtain second historical spectral data; The data preprocessing specifically includes: Performing denoising and enhancement processing on the first historical spectral data; Obtaining a hyperspectral image cube of a single grain based on the first historical spectral data after denoising and enhancement processing; Acquire a single pixel spectral curve pixel by pixel based on the hyperspectral image cube of the single grain; Based on the hyperspectral image cube of the single grain, a plurality of bands are selected and weighted to generate a pseudo-color image, and a category label of a single pixel spectral curve is obtained based on the pseudo-color image; A normalization operation is performed on the single pixel spectrum curve to obtain normalized single pixel spectrum data as second historical spectrum data.
3. The aflatoxin pixel-level detection method based on multiverse optimization according to claim 2 is characterized in that: The model building optimization step specifically includes: Preliminary model building steps: Build the CNN-BiLSTM model and define the number of network layers and structure; Model hyperparameter optimization step: inputting the second historical spectral data and the category label of the single pixel spectral curve into the CNN-BiLSTM model, and obtaining the optimal hyperparameter combination based on the multiverse optimization algorithm; Model training step: configuring the CNN-BiLSTM model parameters based on the optimal hyperparameter combination, training the CNN-BiLSTM model through the second historical spectral data and the category label of the single pixel spectral curve, and obtaining an MVO-CNN-BiLSTM model; Model fine-tuning step: fine-tune the MVO-CNN-BiLSTM model based on aflatoxin spectral data of different concentrations to obtain an aflatoxin pixel-level detection model.
4. The aflatoxin pixel-level detection method based on multiverse optimization according to claim 3 is characterized in that: The preliminary steps of building the model include: Construct a convolutional model with a fixed number of layers. Each convolutional layer is connected to a batch normalization layer and a ReLU activation function, and the initial values of the hyperparameters are set. Connecting a one-dimensional global average pooling and a flattening layer after the convolutional model; Constructing a bidirectional long short-term memory model, connecting the convolutional layer through the one-dimensional global average pooling and flattening layer; A random dropout layer, a fully connected layer, and a Softmax layer are connected after the bidirectional long short-term memory model to complete the construction of the CNN-BiLSTM model.
5. The aflatoxin pixel-level detection method based on multiverse optimization according to claim 3 is characterized in that: The model hyperparameter optimization steps include: Initialization and parameter setting: Initialize several universes, each universe contains optimization variables: learning rate, number of convolution kernels and number of hidden layer neurons; set the search boundaries of the optimization variables, the number of convolution kernels and the number of hidden layer neurons are always set to integers; set the maximum number of iterations; Iterative update: simulate the expansion of the universe and the wormhole effect, dynamically adjust the probability of wormhole existence and the exploration distance, calculate the fitness value of each universe, select and update the optimal universe; Termination condition and output: Iterate until the maximum number of iterations is met to obtain the optimal hyperparameter combination, including: optimal learning rate, optimal number of convolution kernels, and optimal number of hidden layer neurons.
6. The aflatoxin pixel-level detection method based on multiverse optimization according to claim 3 is characterized in that: The model training step includes: Based on the optimal hyperparameter combination, configure the learning rate, number of convolution kernels, and number of hidden layer neurons of the CNN-BiLSTM model; Inputting the second historical spectral data and the category label of the single pixel spectral curve into the configured CNN-BiLSTM model, and training the CNN-BiLSTM model based on the optimizer using a weight decay strategy; The model accuracy is verified at the end of each iteration cycle. If the model accuracy does not improve for multiple consecutive iteration cycles, the training is terminated to obtain the MVO-CNN-BiLSTM model.
7. The aflatoxin pixel-level detection method based on multiverse optimization according to claim 3 is characterized in that: The model fine-tuning steps include: The weights and biases of the MVO-CNN-BiLSTM model are fixed, the MVO-CNN-BiLSTM model is exported, the aflatoxin spectral data with the minimum detection limit concentration is input into the MVO-CNN-BiLSTM model for fine-tuning, the weights and biases are updated, and the aflatoxin pixel-level detection model is obtained.
8. The aflatoxin pixel-level detection method based on multiverse optimization according to claim 1, characterized in that: The model hyperparameter optimization step further includes: Set the initial universe value to: Among them, U is a set of universes of size m×n; n is the variable dimension; m is the number of universes set, i.e., candidate solutions; In each iteration, the universe is sorted according to its expansion rate and a white hole is chosen via a roulette wheel mechanism: Among them, r i is a random number in the range [0, 1]; is the jth parameter of the ith universe; N I (U i ) represents the i-th universe U i The normalized expansion rate of ; k is a number selected according to the roulette mechanism; In order to increase the expansion rate of a particular universe, the universe is connected to the optimal entity through a wormhole, and the parameters in the optimal domain are updated as follows: Among them, r2, r3 and r4 are all random numbers in the interval [0, 1]; x j is the value of the jth parameter of the current optimal universe; l j and u j are the maximum and minimum values of the jth parameter respectively; R is the moving distance; P WEP is the possibility coefficient of wormhole existence; TDR is the travel distance rate coefficient, and its solution formula is as follows: Among them, P WEPmax and P WEPmin P WEP The maximum and minimum values of , l is the current number of iterations, L is the maximum number of iterations, and p is the degree of exploration.
9. A pixel-level aflatoxin detection system based on multiverse optimization, using the pixel-level aflatoxin detection method based on multiverse optimization according to any one of claims 1 to 8, characterized in that: include: Data acquisition and processing module: used for acquiring first historical spectral data of sample grains and performing data preprocessing to obtain second historical spectral data; Model building and optimization module: used to build a CNN-BiLSTM model, optimize the CNN-BiLSTM model based on the multiverse algorithm, and train the optimized CNN-BiLSTM model through the second historical spectrum data to obtain the MVO-CNN-BiLSTM model; fine-tune the MVO-CNN-BiLSTM model to obtain a pixel-level aflatoxin detection model; Aflatoxin detection module: used to input the spectral data of the grain to be tested into the aflatoxin pixel-level detection model to obtain the aflatoxin pixel-level detection results.
10. The aflatoxin pixel-level detection system based on multiverse optimization according to claim 9, characterized in that: The model building optimization module includes: Model preliminary construction unit: construct the CNN-BiLSTM model and define the number of network layers and structure; Model hyperparameter optimization unit: inputting the second historical spectrum data into the CNN-BiLSTM model, and obtaining an optimal hyperparameter combination based on a multiverse optimization algorithm; Model training unit: configuring the CNN-BiLSTM model based on the optimal hyperparameter combination, training the CNN-BiLSTM model through the second historical spectral data, and obtaining an MVO-CNN-BiLSTM model; Model fine-tuning unit: fine-tuning the MVO-CNN-BiLSTM model based on aflatoxin spectral data of different concentrations to obtain an aflatoxin pixel-level detection model.
Citation Information
Patent Citations
Quick detection method for aflatoxin B1 of rice based on near infrared spectroscopy
CN103575694A
Aflatoxin spectrum deep learning detection method based on projection compression and spectrum reconstruction
CN117074324A