A method, device, system and storage medium for detecting cream indigo pigment

By constructing a variable temperature attention residual network model, the problem of temperature changes affecting the accuracy of cream indigo pigment detection is solved, high-precision detection under variable temperature conditions is achieved, and the application of near-infrared spectroscopy technology in the field of food safety is supported.

CN117789101BActive Publication Date: 2024-12-10SHANGHAI BOOHEE INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311624480.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-11-29
Publication Date
2024-12-10
Estimated Expiration
2043-11-29

AI Technical Summary

Technical Problem

When existing near-infrared spectroscopy technology detects indigo pigments in cream, temperature changes affect the spectrum, resulting in inaccurate detection results. Existing methods such as removing temperature-sensitive wavelengths or using orthogonal image moment processing have problems with large amounts of calculation and sparse temperature points. It is difficult to achieve efficient quantitative analysis under variable temperature conditions.

Method used

By collecting the pending data of cream indigo pigment, preprocessing and randomly dividing it into training sets and test sets, a variable temperature attention residual network model is constructed, and the model is optimized to achieve high-precision detection under variable temperature conditions.

Benefits of technology

It improves the applicability, accuracy and robustness of the model, can realize the practical application of spectral quantitative analysis under variable temperature conditions, and supports the development of near-infrared spectroscopy artificial intelligence rapid detection technology in the field of food safety.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117789101B_ABST
    Figure CN117789101B_ABST
Patent Text Reader

Abstract

The present invention provides a cream indigo pigment detection method, device, system and storage medium, belonging to the field of data detection technology, the method comprises: obtaining cream indigo pigment to-be-processed data of a sample to be tested from a collection device; pre-processing the cream indigo pigment to-be-processed data to obtain cream indigo pigment to-be-divided data; randomly dividing the cream indigo pigment to-be-divided data into a cream indigo pigment training set and a cream indigo pigment test set; optimizing the model of the training model according to the cream indigo pigment training set to obtain a target detection model; and detecting the cream indigo pigment test set through the target detection model to obtain a detection result. The present invention enables the model to have the characteristics of high applicability, high precision, high robustness and high efficiency, improves the generalization ability of the model, can meet the standard of using spectral quantitative analysis under variable temperature conditions in practice, and contributes to the development of near-infrared spectroscopy artificial intelligence rapid detection technology in the field of food safety.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention mainly relates to the field of data detection technology, and specifically relates to a cream indigo pigment detection method, device, system and storage medium. Background Art

[0002] At present, near-infrared spectroscopy, as a rapid detection technology, has been combined with artificial intelligence technology to conduct quantitative analysis of different ingredients in a variety of foods under constant temperature conditions. In the field of food safety, many laboratories have conducted modeling analysis of indigo, lemon yellow, sunset yellow, brilliant blue and other pigments in cream under constant temperature conditions to detect whether their pigment content exceeds the standard. However, the sample temperature will change, causing changes in the strength of chemical bonds, which in turn affects the probability of molecules transitioning between different energy levels and changes the spectrum. Therefore, near-infrared spectroscopy artificial intelligence rapid detection technology has not yet been truly applied on a large scale in practice.

[0003] In order to solve the influence of temperature on the spectrum, there are two types of methods. The first type uses principal component analysis and its improved method, namely orthogonalization of external parameters, to remove temperature-sensitive wavelengths and reduce the influence of temperature on the spectrum. This method directly removes spectral information irrelevant to the target variable from the source and is widely used, but this method eliminates temperature information. The second type uses temperature information, takes temperature as an effective parameter, and uses orthogonal image moments to process three-dimensional spectra to establish a good correction model, but the temperature points are fixed and sparse and the calculation is large.

[0004] How to use random temperature information as a feature to conduct quantitative detection in the field of near-infrared spectroscopy analysis and meet the practical application standards of detection is an issue we need to focus on. Summary of the invention

[0005] The technical problem to be solved by the present invention is to provide a cream indigo pigment detection method, device, system and storage medium in view of the deficiencies in the prior art.

[0006] The technical solution of the present invention to solve the above technical problem is as follows: A method for detecting cream indigo pigment comprises the following steps:

[0007] Obtaining the cream indigo pigment processing data of each sample to be tested from the collection device;

[0008] Preprocessing each of the cream indigo pigment to-be-processed data respectively to obtain the cream indigo pigment to-be-classified data corresponding to each of the samples to be tested;

[0009] Randomly divide all the cream indigo pigment data to be divided into a cream indigo pigment training set and a cream indigo pigment test set;

[0010] Constructing a training model, and optimizing the training model according to the cream indigo pigment training set to obtain a target detection model;

[0011] The cream indigo pigment test set is detected by the target detection model to obtain a detection result.

[0012] Another technical solution of the present invention to solve the above technical problem is as follows: a cream indigo pigment detection device, comprising:

[0013] A data acquisition module, used for obtaining the cream indigo pigment to be processed data of each sample to be tested from a collection device;

[0014] A preprocessing module, used for preprocessing each of the cream indigo pigment to-be-processed data respectively, to obtain the cream indigo pigment to-be-classified data corresponding to each of the samples to be tested;

[0015] A partitioning module, used for randomly partitioning all the cream indigo pigment to-be-partitioned data into a cream indigo pigment training set and a cream indigo pigment test set;

[0016] A model optimization module, used for constructing a training model, optimizing the training model according to the cream indigo pigment training set, and obtaining a target detection model;

[0017] The detection result acquisition module is used to detect the cream indigo pigment test set through the target detection model to obtain the detection result.

[0018] Based on the above-mentioned cream indigo pigment detection method, the present invention also provides a cream indigo pigment detection system.

[0019] Another technical solution of the present invention to solve the above technical problem is as follows: a cream indigo pigment detection system, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the cream indigo pigment detection method as described above is implemented.

[0020] Based on the above-mentioned cream indigo pigment detection method, the present invention also provides a computer-readable storage medium.

[0021] Another technical solution of the present invention to solve the above technical problem is as follows: a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the cream indigo pigment detection method as described above is implemented.

[0022] The beneficial effects of the present invention are as follows: cream indigo pigment data to be divided is obtained by preprocessing the cream indigo pigment data to be processed, the cream indigo pigment data to be divided is randomly divided into a cream indigo pigment training set and a cream indigo pigment test set, a target detection model is obtained by optimizing the training model according to the cream indigo pigment training set, and a detection result is obtained by detecting the cream indigo pigment test set with the target detection model, so that the model has the characteristics of high applicability, high precision, high robustness and high efficiency, improves the generalization ability of the model, can meet the standards for the practical application of spectral quantitative analysis under variable temperature conditions, and contributes to the development of near-infrared spectroscopy artificial intelligence rapid detection technology in the field of food safety. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] Figure 1 A schematic diagram of a process for detecting cream indigo pigment provided by an embodiment of the present invention;

[0024] Figure 2 A module block diagram of a cream indigo pigment detection device provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0025] The principles and features of the present invention are described below in conjunction with the accompanying drawings. The examples given are only used to explain the present invention and are not used to limit the scope of the present invention.

[0026] Figure 1 A schematic flow chart of a method for detecting cream indigo pigment provided in an embodiment of the present invention.

[0027] like Figure 1 As shown, a method for detecting cream indigo pigment comprises the following steps:

[0028] Obtaining the cream indigo pigment processing data of each sample to be tested from the collection device;

[0029] Preprocessing each of the cream indigo pigment to-be-processed data respectively to obtain the cream indigo pigment to-be-classified data corresponding to each of the samples to be tested;

[0030] Randomly divide all the cream indigo pigment data to be divided into a cream indigo pigment training set and a cream indigo pigment test set;

[0031] Constructing a training model, and optimizing the training model according to the cream indigo pigment training set to obtain a target detection model;

[0032] The cream indigo pigment test set is detected by the target detection model to obtain a detection result.

[0033] It should be understood that all the cream indigo pigment data to be divided are randomly divided according to a ratio of 4:1.

[0034] Specifically, a unique random seed is used to ensure that the temperature and content data, as well as the processed spectral data, are fixedly divided into a training set (i.e., cream indigo pigment training set) and a test set (i.e., cream indigo pigment test set) to facilitate model tuning. After the training set (i.e., cream indigo pigment training set) and the test set (i.e., cream indigo pigment test set) are fixed, the evaluation index results during model tuning are fairer.

[0035] It should be understood that the random seed is fixed to 42.

[0036] Specifically, each time the training set (i.e., cream indigo pigment training set) and the test set (i.e., cream indigo pigment test set) are shuffled in order, the batch_size of the randomly screened data is set to 92.

[0037] It should be understood that the data selected from the training set (i.e., the cream indigo pigment training set) is input into the variable temperature attention residual network (i.e., the training model) for model tuning.

[0038] In the above embodiment, the cream indigo pigment data to be processed are preprocessed to obtain the cream indigo pigment data to be divided, the cream indigo pigment data to be divided are randomly divided into a cream indigo pigment training set and a cream indigo pigment test set, and the target detection model is obtained by optimizing the training model according to the cream indigo pigment training set. The detection result is obtained by detecting the cream indigo pigment test set with the target detection model, so that the model has the characteristics of high applicability, high precision, high robustness and high efficiency, and the generalization ability of the model is improved, and it can meet the standards for the practical application of spectral quantitative analysis under variable temperature conditions, which is conducive to the development of near-infrared spectroscopy artificial intelligence rapid detection technology in the field of food safety.

[0039] Optionally, as an embodiment of the present invention, the acquisition device includes a Fourier transform near-infrared spectrometer, a thermal imager and a camera device.

[0040] The process of obtaining the cream indigo pigment to be processed data of each sample to be tested from the acquisition device comprises:

[0041] Obtaining original near infrared spectrum data of each sample to be tested from the Fourier transform near infrared spectrometer;

[0042] Obtaining global temperature information corresponding to each of the samples to be tested from the thermal imager;

[0043] A plurality of cream indigo pigment content images corresponding to each of the samples to be tested are obtained from the imaging device, and the cream indigo pigment data to be processed includes the original near-infrared spectrum data, the global temperature information and a plurality of the cream indigo pigment content images.

[0044] It should be understood that the digital image of the balance display (i.e., the image of the indigo pigment content in cream) is acquired by monitoring the camera of the electronic balance.

[0045] It should be understood that the global temperature information of the sample to be tested is obtained by a thermal imager.

[0046] Specifically, the thermal imager can be a Hikvision card-type thermal imager, and the sample to be tested is placed in a fixed position in front of the thermal imager and is kept at a constant temperature using a constant temperature black body.

[0047] It should be understood that the near-infrared spectrum data (ie, original near-infrared spectrum data) of the sample to be tested is obtained by a Fourier transform near-infrared spectrometer.

[0048] In the above embodiment, the cream indigo pigment to be processed data of each sample to be tested is obtained from the acquisition device, without the need to manually fill in the data and perform basic calculations, thus saving experimental time and labor costs.

[0049] Optionally, as an embodiment of the present invention, the process of preprocessing each of the cream indigo pigment to-be-processed data to obtain the cream indigo pigment to-be-classified data corresponding to each of the samples to be tested comprises:

[0050] Performing noise reduction processing on each of the original near-infrared spectrum data respectively to obtain target near-infrared spectrum data corresponding to each of the samples to be tested;

[0051] Using the OpenCV tool to divide each of the global temperature information into regions, and obtain temperature regions corresponding to each of the samples to be tested;

[0052] Performing averaging processing on each of the temperature regions respectively to obtain temperature data corresponding to each of the samples to be tested;

[0053] Performing color separation processing on each of the cream indigo pigment content images using a pre-constructed hexagonal pyramid model to obtain a plurality of separated content images corresponding to each of the samples to be tested;

[0054] Performing image binarization processing on each of the separated content images to obtain multiple grayscale images corresponding to each of the samples to be tested;

[0055] The pre-built PaddleOCR model is used to identify multiple grayscale images corresponding to each of the samples to be tested, and the content data corresponding to each of the samples to be tested is obtained. The cream indigo pigment data to be divided includes the target near-infrared spectrum data, the temperature data and the content data.

[0056] It should be understood that the noise reduction processing is performed on each of the raw near-infrared spectral data respectively, which can be achieved by performing first-order derivative processing on the acquired raw spectral data (i.e., the raw near-infrared spectral data), thereby eliminating the problem of overall upward or downward deviation caused by the different hardness of the cream after whipping, eliminating baseline drift, and improving spectral resolution.

[0057] It should be understood that the pre-built hexagonal pyramid model, HSV, is a color space created by AR Smith in 1978 based on the intuitive characteristics of color, also known as the hexagonal pyramid model. The color parameters in this model are: hue (H), saturation (S), and value (V). HSV can perceive colors more accurately than the traditional RGB color space, and still maintains simplicity in calculation. The basic steps of HSV color separation are: convert HSV representation, set target threshold, set mask, and filter target color.

[0058] Specifically, a desired temperature region of the global temperature is demarcated through OpenCV (ie, OpenCV tool), and the temperature information of the desired temperature region is averaged, and each temperature data corresponds to a piece of near-infrared spectrum data (ie, target near-infrared spectrum data).

[0059] It should be understood that the global temperature information is a thermal map of the entire area captured by the thermal imager, and each pixel in the thermal map has a temperature value.

[0060] It should be understood that the slice area is specified through the OpenCV computer vision library, the function is called to delineate the required temperature area, and all temperature pixels in the required temperature area are averaged to obtain the final temperature data (ie, temperature data).

[0061] It should be understood that when the camera monitors the electronic balance screen, a reflective effect will occur, which will affect digital recognition, so the acquired data needs to be processed.

[0062] Specifically, HSV channel processing is used to make the digital image have a line negative effect, eliminating the influence of reflections to make the numbers easier to binarize, and then the image is binarized, that is, a threshold is given, and numbers greater than this value become pure white, and the background less than this value becomes pure black, and the image is binarized into a black and white photo. Finally, PaddleOCR is used to identify the white digital part. After processing, the content of the sample to be tested, namely, cream indigo pigment (i.e., content data), is obtained, and each content data corresponds to a near-infrared spectrum data (i.e., target near-infrared spectrum data).

[0063] It should be understood that PaddleOCR's ultra-lightweight PP-OCRv3 model for Chinese and English directly calls the tool library through Feijiang to perform digital recognition on the binarized images.

[0064] It should be understood that the negative film effect is obtained by processing the HSV channel, and its brightness is opposite to that of the subject.

[0065] Specifically, the gram weight of indigo pigment is first identified, with the purity of indigo being above 99%. The gram weight of the mixture of pigment and whipped cream is then identified. The gram weight of indigo pigment is divided by the gram weight of the mixture to obtain the content of indigo pigment in the cream (i.e., content data), which corresponds one-to-one to the spectral data to be collected (i.e., target near-infrared spectral data).

[0066] It should be understood that a sample of cream indigo pigment to be tested corresponds to a near-infrared spectrum data (i.e., target near-infrared spectrum data), a temperature data, and a content data. The near-infrared spectrum data (i.e., target near-infrared spectrum data) and the temperature data are features, and the content data is the regression target.

[0067] In the above embodiment, the cream indigo pigment data to be processed are preprocessed to obtain the cream indigo pigment data to be divided, which eliminates the problem of overall upward or downward deviation caused by different hardness of the cream after whipping, eliminates baseline drift, improves spectral resolution, avoids wrong filling, erroneous filling and missing filling, and saves experimental time and labor costs.

[0068] Optionally, as an embodiment of the present invention, the cream indigo pigment training set includes a plurality of cream indigo pigment training data, and the process of constructing a training model, optimizing the training model according to the cream indigo pigment training set, and obtaining a target detection model includes:

[0069] S41: Build training models using PyTorch tools;

[0070] S42: training the training model according to all the cream indigo pigment training data to obtain a prediction value corresponding to each of the cream indigo pigment training data;

[0071] S43: importing the true value corresponding to each of the cream indigo pigment training data, and calculating the loss function of all the predicted values ​​and all the true values ​​using a mean square error function to obtain a cream indigo pigment loss function;

[0072] S44: Update the parameters of the training model according to the Adam algorithm and the cream indigo pigment loss function, and return to S42 after the parameters are updated until the preset number of iterations is reached, and the training model after the parameter update is used as the target detection model.

[0073] It should be understood that PyTorch is an open source machine learning framework based on Torch using the Python programming language. Torch is an open source machine learning library written in the Lua scripting language for creating deep neural networks. PyTorch supports a variety of different mathematical operations, simplifying the creation of artificial neural network models.

[0074] It should be understood that the preset number of iterations may be 500.

[0075] Specifically, during the iterative optimization of the model, the adaptive moment estimation Adam algorithm is used to make the model converge quickly and stably, and the learning rate is set to 0.001. The mean square error function is used as the loss function of the model.

[0076] It should be understood that after 500 rounds of training, the optimal variable temperature attention residual network model (ie, training model) is obtained as the final detection model (ie, target detection model).

[0077] It should be understood that the true value is the actual detection result corresponding to the cream indigo pigment training data.

[0078] Specifically, the mean square error loss function MSE is the most commonly used error in the regression loss function. It is the mean of the sum of squares of the differences between the predicted value f(x) and the target value y (ie, the true value). Its formula is as follows:

[0079]

[0080] It should be understood that the advantages of the PyTorch framework are: easy to get started; concise and flexible code: using nn.module encapsulation makes network construction more convenient; based on the dynamic graph mechanism, it is more flexible and convenient for debugging; there are abundant resources; and there are many developers.

[0081] Specifically, the specific steps of the Adam algorithm are as follows:

[0082] The update step size is calculated by comprehensively considering the first-order moment estimate of the gradient, i.e. the mean of the gradient, and the second-order moment estimate, i.e. the uncentered variance of the gradient. The Adam method calculates the adaptive learning rate of different parameters from the budget of the first-order moment and the second-order moment of the gradient. The Adam algorithm obtains the advantages of both the adaptive gradient algorithm and the root mean square propagation algorithm. The adaptive gradient algorithm AdaGrad reserves a learning rate for each parameter to improve the performance on sparse gradients, and the root mean square propagation RMSProp adaptively reserves the learning rate for each parameter based on the mean of the nearest magnitude of the weight gradient.

[0083] Specifically, Adam is a first-order optimization algorithm that can replace the traditional stochastic gradient descent process. It can iteratively update the weights of the neural network based on the training data. Adam is like walking with your eyes blindfolded. You need direction and also need to perceive the environment. The first-order moment is the maintenance of inertia and represents the direction. The second-order moment is the perception of the environment and represents the size of the slope. The gradient of the model is a random variable. The first-order moment represents the mean of the gradient and the second-order moment represents its variance. The first-order moment controls the direction of the model update and the second-order moment controls the step size (learning rate). Adam uses momentum and adaptive learning rate to speed up convergence. Specifically, the algorithm calculates the exponential moving mean of the gradient. The hyperparameter beta1 controls the decay of the first-order moment estimate and the hyperparameter beta2 controls the decay of the second-order moment estimate. The initial value of the moving mean and the values ​​of beta1 and beta2 are close to 1 (recommended value), so the bias of the moment estimate is close to 0. The bias is improved by first calculating the biased estimate and then calculating the bias-corrected estimate.

[0084] Specifically, the advantages of the Adam algorithm are that after bias correction, the learning rate of each iteration has a certain range, which makes the parameters relatively stable; the calculation is efficient; the memory requirement is small; different adaptive learning rates are calculated for different parameters; and it is suitable for optimization problems with high feature dimensions.

[0085] In the above embodiment, the target detection model is obtained by optimizing the training model according to the cream indigo pigment training set, so that the parameters are relatively stable, the calculation is efficient, the memory requirement is small, and different adaptive learning rates are calculated for different parameters. It is suitable for optimization problems with high feature dimensions, so that the model has the characteristics of high applicability, high precision, high robustness, and high efficiency, and improves the generalization ability of the model.

[0086] Optionally, as an embodiment of the present invention, the training model includes a first convolutional layer, an adaptive maximum pooling layer, a first Relu activation function layer, a plurality of sequentially arranged attention residual modules, a plurality of sequentially arranged maximum pooling layers, a Dropout layer having the same number as the maximum pooling layers and arranged sequentially, and a plurality of fully connected layers,

[0087] The process of S42 includes:

[0088] Performing feature extraction on each of the cream indigo pigment training data through the first convolutional layer to obtain extracted training data corresponding to each of the cream indigo pigment training data;

[0089] Performing feature enhancement on each of the extracted training data through the first attention residual module, and inputting the feature enhancement result into the next attention residual module until the last attention residual module is input, thereby obtaining enhanced training data corresponding to each of the cream indigo pigment training data;

[0090] Performing maximum pooling processing on each of the enhanced training data through the first maximum pooling layer, and inputting the maximum pooling processing result into the first Dropout layer for random discarding processing, and inputting the random discarding processing result into the next maximum pooling layer, until it is input into the last Dropout layer, thereby obtaining the randomly discarded training data corresponding to each of the cream indigo pigment training data;

[0091] Performing maximum pooling processing on each of the randomly discarded training data through the adaptive maximum pooling layer to obtain pooled training data corresponding to each of the cream indigo pigment training data;

[0092] Flattening each of the pooled training data through a plurality of the fully connected layers to obtain flattened training data corresponding to each of the cream indigo pigment training data;

[0093] The first Relu activation function layer is used to map each of the flattened training data to obtain a plurality of prediction values ​​corresponding to each of the cream indigo pigment training data.

[0094] It should be understood that the attention residual module, the maximum pooling layer, the Dropout layer and the fully connected layer can all be 2.

[0095] It should be understood that the activation function of the output layer (i.e., the first Relu activation function layer) is adjusted using the Relu function.

[0096] Specifically, if multiple maximum pooling layers include maximum pooling layer A and maximum pooling layer B, and multiple Dropout layers include Dropout layer A and Dropout layer B, then each of the enhanced training data is input into the maximum pooling layer A for maximum pooling processing, and the obtained maximum pooling processing result a1 is input into the Dropout layer A for random drop processing, and the random drop processing result b1 is input into the maximum pooling layer B for maximum pooling processing, and the obtained maximum pooling processing result a2 is input into the Dropout layer B for random drop processing, thereby obtaining the training data b2 after random drop.

[0097] Specifically, the variable temperature attention residual network model (i.e., training model) consists of a one-dimensional convolution layer (i.e., the first convolution layer), two attention residual modules, two maximum pooling layers, two random dropout layers (i.e., Dropout layers), an adaptive maximum pooling layer, two fully connected layers, and an activation function layer (i.e., the first Relu activation function layer). The one-dimensional convolution input channel is 1, the output channel generated is 12, the convolution kernel size is 3, the step size is 1, and the number of layers of each edge of the input is supplemented by 1. The data extracted by the preliminary feature of the one-dimensional convolution (i.e., the extracted training data) is input into the attention residual module for feature enhancement, and then the one-dimensional maximum pooling layer and random dropout layer are used to reduce the number of parameters, reduce the model calculation amount, and prevent overfitting. The window size of the one-dimensional maximum pooling layer is set to 2, and the dropout probability of the random dropout layer is set to 0.2. The attention residual module, the one-dimensional maximum pooling layer, and the random dropout layer are repeated twice to fully empower the extraction of complex spectral high-dimensional features and temperature features. Next, an adaptive maximum pooling layer is used to reduce the data dimension. After retaining the information, the data is flattened by the fully connected layer, and an activation function is added as the output layer to enhance the nonlinear ability of the model.

[0098] It should be understood that the calculation formula of the one-dimensional convolution layer (i.e., the first convolution layer) is:

[0099]

[0100] x i is the input, k i is the convolution kernel, b i is the bias value, is the convolution operation, f is the activation function, x i+1 is the output.

[0101] Specifically, the maximum pooling layer directly calculates the original data in the pooling window. The calculation process is to select the maximum value. Maximum pooling alleviates the position sensitivity of the features to be identified.

[0102] It should be understood that the random dropout layer (i.e., the Dropout layer) stops the activation value of a certain neuron from working with a certain probability p during forward propagation, which can make the model more generalizable because it will not rely too much on certain local features.

[0103] It should be understood that the adaptive maximum pooling layer automatically controls the output according to the input parameters.

[0104] It should be understood that each layer in the fully connected layer is a tiled structure composed of many neurons.

[0105] Specifically, the activation function layer (i.e., the first Relu activation function layer) uses the Relu activation function, and the calculation formula is:

[0106] f(x)=max(0,x)

[0107] The Relu activation function converts all negative activations to zero.

[0108] Specifically, randomly disrupting the input data can enhance the robustness of the model. The Relu activation function can increase the nonlinear characteristics of the model and even the entire neural network without affecting the expression effect of the convolutional layer, solving the problem of slow learning convergence of the neural network caused by gradient disappearance.

[0109] In the above embodiment, the training model is trained according to the cream indigo pigment training data to obtain the prediction value, which enhances the nonlinear ability and robustness of the model and solves the problem of slow convergence of neural network learning caused by gradient disappearance.

[0110] Optionally, as an embodiment of the present invention, the attention residual module includes a residual module and an SCSE attention mechanism layer,

[0111] The process of performing feature enhancement on each of the extracted training data by using the first attention residual module comprises:

[0112] Mapping the extracted training data respectively through the residual module to obtain mapped training data corresponding to the cream indigo pigment training data;

[0113] The SCSE attention mechanism layer is used to perform feature weighting on each of the mapped training data to obtain enhanced training data corresponding to each of the cream indigo pigment training data.

[0114] It should be understood that the scSE attention mechanism (i.e., the SCSE attention mechanism layer) is connected in series after the residual module.

[0115] It should be understood that the residual network (i.e., residual module) has fewer training parameters and lower training cost, uses skip connections to perform identity mapping on high-dimensional features, achieves cross-layer flow, and better preserves features.

[0116] Specifically, due to the limited amount of spectral data, the residual module is prone to overfitting under limited data. The attention module (i.e., SCSE attention mechanism layer) is embedded in the residual network. Through weight learning, the network's relevance to the important features of temperature and content in the spectrum is enhanced globally, effectively improving the ability to extract features. Benefiting from the residual structure, the use of the attention mechanism (i.e., SCSE attention mechanism layer) in series after the residual module can capture two information sources, fully integrate feature-related weights, and greatly improve learning efficiency. The number of input channels of scSE (i.e., SCSE attention mechanism layer) is 12. By extracting the importance of the input features in space and channels respectively and adding them together, the backbone network's ability to represent important spatial and channel feature information is improved, prompting the network to learn more meaningful information, and effectively alleviating the problem that the shallow network has poor extraction effect on high-dimensional and complex features of near-infrared spectra.

[0117] Specifically, the scSE attention mechanism (i.e., the SCSE attention mechanism layer) consists of spatial squeezing and channel excitation cSE and channel squeezing and spatial excitation sSE. cSE first uses global average pooling to decompose the spatial features, and then performs convolution on the channels to generate a tensor representing the channel attention. Relu and Sigmoid activation functions are used on the tensor to obtain the corresponding attention weights on each channel, and finally the weights are multiplied by the original features channel by channel to complete the channel information adjustment. sSE uses convolution with kernel 1 and channel 1 and Sigmoid activation function to obtain the spatial attention weights, which are fused with the input features to complete the spatial information adjustment. Finally, the channel information and spatial information are fused to obtain the output of scSE attention.

[0118] It should be understood that the calculation formula of the residual network (i.e., the residual module) is:

[0119] y=y(x,w)+x,

[0120] x is the input value, y is the output value, and f(x,w) is the value after network operation.

[0121] Specifically, the specific process of cSE in the scSE attention mechanism is as follows: the feature spectrum is changed from [C, H, W] to [C, 1, 1] through the global average pooling method, where H represents the width of the image, W represents the height of the image, and C represents the number of channels of the image. Then two one-dimensional convolutions are used to process the information, and finally a C-dimensional vector is obtained. Then the sigmoid function is used for normalization to obtain the corresponding mask, and finally the channel adjustment is multiplied to obtain the feature spectrum that has been calibrated with information. The specific process of sSE is as follows: directly use one-dimensional convolution on the feature spectrum to change the feature from [C, H, W] to [1, H, W], and then use sigmoid for activation to obtain the spatial attention weight, which is then directly applied to the original feature spectrum to complete the spatial information calibration.

[0122] It should be understood that the formula of the sigmoid activation function is

[0123] Specifically, global average pooling can better match the category with the feature map of the last convolutional layer, reduce the number of parameters, and the global average pooling layer has no parameters, which can prevent overfitting in this layer, integrate global spatial information, and be more robust to the spatial transformation of the input image. Global average pooling is actually to average all pixel values ​​of each channel map, and then obtain a new 1*1 channel map.

[0124] In the above embodiment, the first attention residual module is used to enhance the features of the extracted training data, thereby improving the backbone network's ability to represent important spatial and channel feature information, prompting the network to learn more meaningful information, and effectively alleviating the problem of poor extraction of high-dimensional and complex features of near-infrared spectra by shallow networks.

[0125] Optionally, as an embodiment of the present invention, the residual module includes a second convolutional layer, a BatchNorm1d layer and a second Relu activation function layer.

[0126] The process of mapping each of the extracted training data by the residual module to obtain mapped training data corresponding to each of the cream indigo pigment training data comprises:

[0127] Performing feature extraction on each of the extracted training data through the second convolutional layer to obtain training data to be normalized corresponding to each of the cream indigo pigment training data;

[0128] Each of the training data to be normalized is normalized by the BatchNorm1d layer to obtain normalized training data corresponding to each of the cream indigo pigment training data;

[0129] The normalized training data are mapped respectively through the second Relu activation function layer to obtain mapped training data corresponding to the cream indigo pigment training data.

[0130] It should be understood that the network structure of the second convolutional layer is different from that of the first convolutional layer.

[0131] Specifically, the residual layer in the attention residual module (i.e., the residual module) has 12 input channels, 6 intermediate channels, and 12 output channels, and is composed of convolutional layers (i.e., the second convolutional layer) with convolution kernel sizes of 1, 3, and 1, respectively. Each convolutional layer is followed by a batch normalization layer (i.e., the BatchNorm1d layer) and a Relu activation function layer (i.e., the second Relu activation function layer). The batch normalization layer makes the distribution of small batch values ​​in each layer of the neural network meet the standard normal distribution, making the model training process more stable.

[0132] Specifically, the batch normalization layer in the residual network makes the distribution of small batch values ​​in each layer of the neural network meet the standard normal distribution, making the model training process more stable. The core formula of batch normalization is:

[0133]

[0134] B={x 1…m} is the input value set, γ, β are trainable parameters, y i is the output.

[0135] In the above embodiment, the extracted training data is mapped by the residual module to obtain the mapped training data, which can make the distribution of small batch values ​​in each layer of the neural network satisfy the standard normal distribution, make the model training process more stable, and achieve the standard for the practical application of spectral quantitative analysis under variable temperature conditions, which is conducive to the development of near-infrared spectroscopy artificial intelligence rapid detection technology in the field of food safety.

[0136] Optionally, as another embodiment of the present invention, it also includes:

[0137] The test set (i.e., cream indigo pigment test set) is input into the final detection model (i.e., target detection model) and iterated for 500 rounds to obtain the average evaluation index of the final model for the test set and the quantitative detection results of this model. The evaluation indicators include training loss, test loss, determination coefficient, and relative analysis error.

[0138] It should be understood that the evaluation index is calculated based on the relationship between the true value and the predicted value of the quantitative detection of the training set. It is an assessment of whether the model has the same effect on the training set if it performs well on the training set.

[0139] It should be understood that both training loss and test loss are calculated based on the mean square error loss function.

[0140] Specifically, is the training target variable value, y i is the true value, is the mean, and the coefficient of determination R 2 The calculation formula is:

[0141]

[0142] It should be understood that the relative analytical error RPD formula is:

[0143]

[0144] Optionally, as another embodiment of the present invention, the present invention can be run on the virtual environment Python 3.6 of Ubuntu 18.04, the development framework is Pytorch 1.4.0, and the server GPU model is NVIDIA GTX2080Ti with 8GB video memory.

[0145] Optionally, as another embodiment of the present invention, the specific steps of the present invention are as follows:

[0146] S1: Obtain the original spectral data and the corresponding temperature and content data through the variable temperature near infrared spectroscopy data acquisition platform; S2: Denoise the obtained original spectral data to obtain the processed spectral data; S3: Randomly divide the temperature and content data and the processed spectral data into training sets and test sets; S4: Input the training set into the variable temperature attention residual network for model construction and tuning to obtain the final detection model; S5: Use the final detection model to perform quantitative detection on the test set to obtain the detection results. The detection results show that the variable temperature attention residual network model has the characteristics of high applicability, high precision, high robustness and high efficiency, and can be used in practice to quantitatively analyze cream indigo pigment under variable temperature conditions.

[0147] Optionally, as another embodiment of the present invention, the present invention aims at the problem of sample temperature change, takes the indigo pigment in cream as the spectral quantitative analysis data, and proposes a variable temperature attention residual network. The total number of training rounds is 500, and the amount of data selected in each round of training and testing of the model is fixed and the order of the data is fully disrupted to improve the generalization ability of the model. Before entering the variable temperature attention residual network model, the input data is firstly normalized and dimensioned by the first-order derivative to achieve the effect of spectral noise reduction and increase of channel dimension, and the channel is set to 1 for input of one-dimensional convolution. The data extracted by the preliminary feature of the one-dimensional convolution is input into the attention residual module for feature enhancement, and then the one-dimensional maximum pooling layer and the random drop layer are used to reduce the number of parameters, reduce the model calculation amount, and prevent overfitting. Next, the adaptive maximum pooling layer is used to reduce the data dimension, and after retaining the information, the fully connected layer is input for data flattening, and the Relu function is added as the output layer to enhance the nonlinear ability of the model. The variable temperature attention residual network integrates temperature and spectral features, and fully weights and extracts the high-dimensional features and temperature features of the complex spectrum. In the variable temperature attention residual network, the scSE attention mechanism is placed after the residual module, which can not only give full play to the advantages of the residual network, reduce the number of model parameters, and reduce training time, but also utilize the fusion features of the identity mapping to improve learning efficiency. The scSE attention mechanism extracts the importance of the input features in space and channels respectively, and after adding them, it improves the backbone network's ability to represent important spatial and channel feature information, prompts the network to learn more meaningful information, and effectively alleviates the problem that the shallow network has poor extraction effect on high-dimensional complex features of near-infrared spectra. After model tuning, the Adam optimizer converges faster, is easier to find the optimal solution, and can better promote the role of the Relu activation function, prevent gradient diffusion and speed up calculations. The coefficient of determination and relative analysis error of the model in the final evaluation indicators on the test set reached 0.9293 and 3.7031 respectively. The gap between training loss and test loss narrowed to 0.0005. The results show that the variable temperature attention residual network model is simple and efficient, with high precision and high robustness. It meets the standards for the practical application of spectral quantitative analysis under variable temperature conditions, and is conducive to the development of near-infrared spectroscopy artificial intelligence rapid detection technology in the field of food safety.

[0148] Optionally, as another embodiment of the present invention, the present invention includes the following steps:

[0149] S1: Obtain the original spectral data and the corresponding temperature and content data through the variable temperature near infrared spectroscopy data acquisition platform;

[0150] S2: Denoising the acquired original spectral data to obtain processed spectral data;

[0151] S3: randomly divide the temperature and content data and the processed spectral data into training and test sets;

[0152] S4: Input the training set into the variable temperature attention residual network for model construction and tuning to obtain the final detection model;

[0153] S5: Perform quantitative detection on the test set through the final detection model to obtain the detection results.

[0154] Optionally, as another embodiment of the present invention, the present invention obtains raw spectral data and corresponding temperature and content data through a variable temperature near infrared spectroscopy data acquisition platform. There is no need to manually fill in the data and perform basic calculations. By connecting the interfaces of the electronic balance screen monitoring camera, Hikvision card-type thermal imager, and Fourier transform near infrared spectrometer to the platform, the near infrared spectrum and the corresponding content and temperature data can be directly obtained and stored in the database of the server. In VScode, the data in the server is pulled and displayed using a csv file. There are a total of 466 data, each of which contains high-dimensional near infrared spectral data, temperature data, and content data. Among them, high-dimensional near infrared spectral data and temperature data are features, and content data is the model regression target. The fully automated data acquisition platform greatly facilitates the acquisition of data, avoids wrong filling, misfilling, and missing filling, and saves experimental time costs and labor costs.

[0155] Figure 2 A module block diagram of a cream indigo pigment detection device provided in an embodiment of the present invention.

[0156] Optionally, as another embodiment of the present invention, Figure 2 As shown, a cream indigo pigment detection device comprises:

[0157] A data acquisition module, used for obtaining the cream indigo pigment to be processed data of each sample to be tested from a collection device;

[0158] A preprocessing module, used for preprocessing each of the cream indigo pigment to-be-processed data respectively, to obtain the cream indigo pigment to-be-classified data corresponding to each of the samples to be tested;

[0159] A partitioning module, used for randomly partitioning all the cream indigo pigment to-be-partitioned data into a cream indigo pigment training set and a cream indigo pigment test set;

[0160] A model optimization module, used for constructing a training model, optimizing the training model according to the cream indigo pigment training set, and obtaining a target detection model;

[0161] The detection result acquisition module is used to detect the cream indigo pigment test set through the target detection model to obtain the detection result.

[0162] Optionally, another embodiment of the present invention provides a cream indigo pigment detection system, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the cream indigo pigment detection method as described above is implemented. The system may be a computer or other system.

[0163] Optionally, another embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the cream indigo pigment detection method as described above is implemented.

[0164] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device.

[0165] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices and units can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0166] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.

[0167] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiments of the present invention.

[0168] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0169] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

[0170] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for detecting cream indigo pigment, characterized in that: The steps include: Obtaining the cream indigo pigment processing data of each sample to be tested from the collection device; Preprocessing each of the cream indigo pigment to-be-processed data respectively to obtain the cream indigo pigment to-be-classified data corresponding to each of the samples to be tested; Randomly divide all the cream indigo pigment data to be divided into a cream indigo pigment training set and a cream indigo pigment test set; Constructing a training model, and optimizing the training model according to the cream indigo pigment training set to obtain a target detection model; Detecting the cream indigo pigment test set using the target detection model to obtain a detection result; The acquisition equipment includes a Fourier transform near-infrared spectrometer, a thermal imager and a camera. The process of obtaining the cream indigo pigment to be processed data of each sample to be tested from the acquisition device comprises: Obtaining original near infrared spectrum data of each sample to be tested from the Fourier transform near infrared spectrometer; Obtaining global temperature information corresponding to each of the samples to be tested from the thermal imager; Obtaining a plurality of cream indigo pigment content images corresponding to each of the samples to be tested from the camera device, wherein the cream indigo pigment data to be processed includes the original near-infrared spectrum data, the global temperature information and a plurality of the cream indigo pigment content images; The cream indigo pigment training set includes a plurality of cream indigo pigment training data, and the process of constructing a training model, optimizing the training model according to the cream indigo pigment training set, and obtaining a target detection model includes: S41: Build training models using PyTorch tools; S42: training the training model according to all the cream indigo pigment training data to obtain a prediction value corresponding to each of the cream indigo pigment training data; S43: importing the true value corresponding to each of the cream indigo pigment training data, and calculating the loss function of all the predicted values ​​and all the true values ​​using a mean square error function to obtain a cream indigo pigment loss function; S44: updating the parameters of the training model according to the Adam algorithm and the cream indigo pigment loss function, and returning to S42 after the parameters are updated until a preset number of iterations is reached, and the training model after the parameters are updated is used as the target detection model; The training model includes a first convolutional layer, an adaptive maximum pooling layer, a first Relu activation function layer, a plurality of sequentially arranged attention residual modules, a plurality of sequentially arranged maximum pooling layers, a number of Dropout layers that are the same as the number of the maximum pooling layers and are sequentially arranged, and a plurality of fully connected layers. The process of S42 includes: Performing feature extraction on each of the cream indigo pigment training data through the first convolutional layer to obtain extracted training data corresponding to each of the cream indigo pigment training data; Performing feature enhancement on each of the extracted training data through the first attention residual module, and inputting the feature enhancement result into the next attention residual module until the last attention residual module is input, thereby obtaining enhanced training data corresponding to each of the cream indigo pigment training data; Performing maximum pooling processing on each of the enhanced training data through the first maximum pooling layer, and inputting the maximum pooling processing result into the first Dropout layer for random discarding processing, and inputting the random discarding processing result into the next maximum pooling layer, until it is input into the last Dropout layer, thereby obtaining the randomly discarded training data corresponding to each of the cream indigo pigment training data; Performing maximum pooling processing on each of the randomly discarded training data through the adaptive maximum pooling layer to obtain pooled training data corresponding to each of the cream indigo pigment training data; Flattening each of the pooled training data through a plurality of the fully connected layers to obtain flattened training data corresponding to each of the cream indigo pigment training data; Mapping each of the flattened training data through the first Relu activation function layer to obtain a plurality of prediction values ​​corresponding to each of the cream indigo pigment training data; The attention residual module includes a residual module and an SCSE attention mechanism layer. The process of performing feature enhancement on each of the extracted training data by using the first attention residual module comprises: Mapping the extracted training data respectively through the residual module to obtain mapped training data corresponding to the cream indigo pigment training data; The SCSE attention mechanism layer performs feature weighting on each of the mapped training data to obtain enhanced training data corresponding to each of the cream indigo pigment training data; The residual module includes a second convolutional layer, a BatchNorm1d layer and a second Relu activation function layer. The process of mapping each of the extracted training data by the residual module to obtain mapped training data corresponding to each of the cream indigo pigment training data comprises: Performing feature extraction on each of the extracted training data through the second convolutional layer to obtain training data to be normalized corresponding to each of the cream indigo pigment training data; Each of the training data to be normalized is normalized by the BatchNorm1d layer to obtain normalized training data corresponding to each of the cream indigo pigment training data; Mapping each of the normalized training data using the second Relu activation function layer to obtain mapped training data corresponding to each of the cream indigo pigment training data; The process of preprocessing each of the cream indigo pigment to-be-processed data to obtain the cream indigo pigment to-be-classified data corresponding to each of the samples to be tested comprises: Performing noise reduction processing on each of the original near-infrared spectrum data respectively to obtain target near-infrared spectrum data corresponding to each of the samples to be tested; Using the OpenCV tool to divide each of the global temperature information into regions, and obtain temperature regions corresponding to each of the samples to be tested; Performing averaging processing on each of the temperature regions respectively to obtain temperature data corresponding to each of the samples to be tested; Performing color separation processing on each of the cream indigo pigment content images using a pre-constructed hexagonal pyramid model to obtain a plurality of separated content images corresponding to each of the samples to be tested; Performing image binarization processing on each of the separated content images to obtain multiple grayscale images corresponding to each of the samples to be tested; The pre-built PaddleOCR model is used to identify multiple grayscale images corresponding to each of the samples to be tested, and the content data corresponding to each of the samples to be tested is obtained. The cream indigo pigment data to be divided includes the target near-infrared spectrum data, the temperature data and the content data.

2. A cream indigo pigment detection device, characterized in that: include: A data acquisition module, used for obtaining the cream indigo pigment to be processed data of each sample to be tested from a collection device; A preprocessing module, used for preprocessing each of the cream indigo pigment to-be-processed data respectively, to obtain the cream indigo pigment to-be-classified data corresponding to each of the samples to be tested; A partitioning module, used for randomly partitioning all the cream indigo pigment to-be-partitioned data into a cream indigo pigment training set and a cream indigo pigment test set; A model optimization module, used for constructing a training model, optimizing the training model according to the cream indigo pigment training set, and obtaining a target detection model; A detection result obtaining module, used to detect the cream indigo pigment test set through the target detection model to obtain a detection result; The acquisition equipment includes a Fourier transform near-infrared spectrometer, a thermal imager and a camera. In the data acquisition module, the process of obtaining the cream indigo pigment to be processed data of each sample to be tested from the acquisition device includes: Obtaining original near infrared spectrum data of each sample to be tested from the Fourier transform near infrared spectrometer; Obtaining global temperature information corresponding to each of the samples to be tested from the thermal imager; Obtaining a plurality of cream indigo pigment content images corresponding to each of the samples to be tested from the camera device, wherein the cream indigo pigment data to be processed includes the original near-infrared spectrum data, the global temperature information and a plurality of the cream indigo pigment content images; The cream indigo pigment training set includes a plurality of cream indigo pigment training data, and the model optimization module is specifically used for: S41: Build training models using PyTorch tools; S42: training the training model according to all the cream indigo pigment training data to obtain a prediction value corresponding to each of the cream indigo pigment training data; S43: importing the true value corresponding to each of the cream indigo pigment training data, and calculating the loss function of all the predicted values ​​and all the true values ​​using a mean square error function to obtain a cream indigo pigment loss function; S44: updating the parameters of the training model according to the Adam algorithm and the cream indigo pigment loss function, and returning to S42 after the parameters are updated until a preset number of iterations is reached, and the training model after the parameters are updated is used as the target detection model; The training model includes a first convolutional layer, an adaptive maximum pooling layer, a first Relu activation function layer, a plurality of sequentially arranged attention residual modules, a plurality of sequentially arranged maximum pooling layers, a number of Dropout layers that are the same as the number of the maximum pooling layers and are sequentially arranged, and a plurality of fully connected layers. In the model optimization module, the training model is trained according to all the cream indigo pigment training data to obtain a prediction value corresponding to each of the cream indigo pigment training data, including: Performing feature extraction on each of the cream indigo pigment training data through the first convolutional layer to obtain extracted training data corresponding to each of the cream indigo pigment training data; Performing feature enhancement on each of the extracted training data through the first attention residual module, and inputting the feature enhancement result into the next attention residual module until the last attention residual module is input, thereby obtaining enhanced training data corresponding to each of the cream indigo pigment training data; Performing maximum pooling processing on each of the enhanced training data through the first maximum pooling layer, and inputting the maximum pooling processing result into the first Dropout layer for random discarding processing, and inputting the random discarding processing result into the next maximum pooling layer, until it is input into the last Dropout layer, thereby obtaining the randomly discarded training data corresponding to each of the cream indigo pigment training data; Performing maximum pooling processing on each of the randomly discarded training data through the adaptive maximum pooling layer to obtain pooled training data corresponding to each of the cream indigo pigment training data; Flattening each of the pooled training data through a plurality of the fully connected layers to obtain flattened training data corresponding to each of the cream indigo pigment training data; Mapping each of the flattened training data through the first Relu activation function layer to obtain a plurality of prediction values ​​corresponding to each of the cream indigo pigment training data; The attention residual module includes a residual module and an SCSE attention mechanism layer. In the model optimization module, the process of performing feature enhancement on each of the extracted training data by using the first attention residual module includes: Mapping the extracted training data respectively through the residual module to obtain mapped training data corresponding to the cream indigo pigment training data; The SCSE attention mechanism layer performs feature weighting on each of the mapped training data to obtain enhanced training data corresponding to each of the cream indigo pigment training data; The residual module includes a second convolutional layer, a BatchNorm1d layer and a second Relu activation function layer. The process of mapping each of the extracted training data by the residual module to obtain mapped training data corresponding to each of the cream indigo pigment training data comprises: Performing feature extraction on each of the extracted training data through the second convolutional layer to obtain training data to be normalized corresponding to each of the cream indigo pigment training data; Each of the training data to be normalized is normalized by the BatchNorm1d layer to obtain normalized training data corresponding to each of the cream indigo pigment training data; Mapping each of the normalized training data using the second Relu activation function layer to obtain mapped training data corresponding to each of the cream indigo pigment training data; In the preprocessing module, the process of preprocessing each of the cream indigo pigment to-be-processed data to obtain the cream indigo pigment to-be-classified data corresponding to each of the samples to be tested comprises: Performing noise reduction processing on each of the original near-infrared spectrum data respectively to obtain target near-infrared spectrum data corresponding to each of the samples to be tested; Using the OpenCV tool to divide each of the global temperature information into regions, and obtain temperature regions corresponding to each of the samples to be tested; Performing averaging processing on each of the temperature regions respectively to obtain temperature data corresponding to each of the samples to be tested; Performing color separation processing on each of the cream indigo pigment content images using a pre-constructed hexagonal pyramid model to obtain a plurality of separated content images corresponding to each of the samples to be tested; Performing image binarization processing on each of the separated content images to obtain multiple grayscale images corresponding to each of the samples to be tested; The pre-built PaddleOCR model is used to identify multiple grayscale images corresponding to each of the samples to be tested, and the content data corresponding to each of the samples to be tested is obtained. The cream indigo pigment data to be divided includes the target near-infrared spectrum data, the temperature data and the content data.

3. A cream indigo pigment detection system, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the cream indigo pigment detection method as claimed in claim 1 is implemented.

4. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the cream indigo pigment detection method as claimed in claim 1 is implemented.