Hami melon pesticide residue identification method based on convolutional neural network
1. A Hami melon pesticide residue identification method based on a convolutional neural network is characterized by comprising the following steps:
s1, collecting visible/near infrared spectrum information of the pesticide residue of the Hami melon;
s2, preprocessing the spectrum data;
s3, dividing the spectrum data into a training set and a test set according to a certain proportion;
s4, constructing an asymmetric multi-scale one-dimensional convolution neural network model;
and S5, outputting the identification result of the pesticide residue of the Hami melon.
2. The method for identifying pesticide residues in Hami melons based on a convolutional neural network as claimed in claim 1, wherein in step S1, a visible/near infrared spectrometer is used to collect spectral information of no residues in Hami melons, chlorothalonil and imidacloprid residues.
3. The method for identifying pesticide residues in Hami melons based on convolutional neural networks as claimed in claim 2, wherein instruments and acquisition parameters of the visible/near infrared spectrometer comprise:
the spectral resolution of the QE Pro micro fiber optic spectrometer is 0.69 nm, and the waveband range is 380-1100 nm;
QP600-2-VIS-NIROOS-00-5172-11 fiber probe, 3 cm from the surface of Hami melon;
the spectrum acquisition mode is diffuse reflection, the integration time is 100 ms, and the average scanning time is 10 times.
4. The Hami melon pesticide residue identification method based on the convolutional neural network as claimed in claim 1, which is characterized in that: in the step S2, the spectral information collected in the step S1 is preprocessed by the Savitzky-Golay first derivative and the standard deviation normalization algorithm.
5. The Hami melon pesticide residue identification method based on the convolutional neural network as claimed in claim 1, which is characterized in that: in step S3, the ratio of the training set to the test set is 8: 2.
6. The Hami melon pesticide residue identification method based on the convolutional neural network as claimed in claim 1, which is characterized in that: in step S4, the asymmetric multi-scale one-dimensional convolutional neural network model includes 1 input layer, 3 convolutional channels, 1 fusion layer, 1 flat layer, 1 fully-connected layer, and 1 output layer.
7. The Hami melon pesticide residue identification method based on the convolutional neural network as claimed in claim 6, which is characterized in that: the 3 spooling channels comprise:
the convolution channel 1 comprises 1 convolution module, wherein the number and the size of convolution kernels are respectively 16 and 1, the step length is 2, and the activation function is a linear rectification unit;
the convolution channel 2 comprises 1 pooling module and 1 convolution module, wherein the pooling mode is maximum pooling, the number and the size of convolution kernels are 16 and 1 respectively, the step length is 2, and the activation function is a linear rectification unit;
the convolution channel 3 comprises 3 convolution modules, wherein the number of convolution kernels is 16, the sizes are 1, 3 and 5 respectively, the steps are 2, and the activation function is a linear rectification unit.
8. The method for identifying the pesticide residues of the Hami melons based on the convolutional neural network as claimed in claim 6, wherein the fusion mode of the fusion layers is cascade connection, namely the extracted depth features are spliced along the length direction, and the calculation formula is as follows:
;
whereinThe feature vector after the fusion is represented,v 1、v 2andv 3respectively representing feature vectors after feature extraction of 3 convolution channels;
the full connection layer comprises 128 neurons, and an activation function is a linear rectifying unit;
the loss function of the output layer is a cross entropy function, the optimization algorithm is random gradient descent, the classification activation function is a softmax function, and the number of the neurons is 3.
9. The method for identifying pesticide residues in Hami melons based on the convolutional neural network as claimed in claim 6, wherein the training set data in step S3 is used for training the model, and the test set data is used for testing the performance of the model.
Background
In recent years, the problem of pesticide residue on fruits has become a focus of social attention, and the "pollution-free", "green" and the like have become important standards for consumers to select fruit products. Hami melon is a special fruit in Xinjiang and is easily infected by various plant diseases and insect pests during planting, so that melon farmers often use bactericides and insecticides such as chlorothalonil and imidacloprid for preventing and treating diseases and pests. The reasonable use of the pesticide can effectively prevent and control plant diseases and insect pests, but the excessive use can cause the pesticide to be enriched in fruits, so that the problem of pesticide residue is increasingly serious. Because the Hami melon is bulky, and the surface reticulate pattern is many, so the rainwater is difficult to wash the residual pesticide who adheres to the melon skin surface clean, and the residual pesticide can be followed the inside infiltration of Hami melon surface, lasts the pollution fruit. The pesticide residue problem of the Hami melons not only threatens human health, but also is an important factor for limiting market competitiveness of the Hami melons in Xinjiang. Therefore, the problem of rapid nondestructive testing of pesticide residues on the surfaces of the Hami melons is solved.
The chemical detection method of pesticide residue mainly comprises gas/liquid chromatography, gas/liquid chromatography combined mass spectrometry and gas/liquid chromatography tandem mass spectrometry. Although the chemical detection method has high accuracy and sensitivity, the detection cost is high, and the operation is complicated and destructive. The visible/near infrared spectrum technology is used as a modern nondestructive testing technology, point source spectrum information of a sample can be obtained, the quality and safety of the sample are evaluated by analyzing the correlation between spectral line characteristics and components to be tested, the visible/near infrared spectrum technology is widely applied to the internal quality testing fields of soluble solid matters, water and nutrient content, maturity and the like of fruits, and has great potential in the nondestructive testing field of pesticide residues of the fruits.
The original spectrum information usually contains a large amount of irrelevant information, the spectrum effective characteristics are acquired through a specific preprocessing and variable screening method, then the relation between the near infrared spectrum and the sample attribute is established through a multivariate modeling method, and the spectrum analysis process brings challenges to the calculation complexity and the generalization capability of the model. The development of deep learning in recent years shows that the convolutional neural network model reduces the requirements of data preprocessing and variable screening, and the capability of providing accurate identification and prediction is gradually improved, so that the convolutional neural network model becomes one of the most popular and most widely applied deep learning methods.
According to the current report on nondestructive testing research of fruit pesticide residues, the research for identifying the pesticide residues of large fruits by applying a visible/near infrared spectrum technology and a convolutional neural network model is rarely reported. Therefore, the development of the Hami melon pesticide residue identification method based on the convolutional neural network has important significance for realizing the rapid nondestructive detection of pesticide residues, and simultaneously provides reference for the pesticide residue detection research of other similar large fruits.
Disclosure of Invention
In view of the above, the present invention aims to provide a method for identifying pesticide residues in hami melons based on a convolutional neural network, so as to achieve nondestructive identification of pesticide residues, chlorothalonil and imidacloprid residues in the hami melons.
In order to achieve the purpose, the invention adopts the following technical scheme.
The invention provides a Hami melon pesticide residue identification method based on a convolutional neural network, which comprises the following steps.
And S1, collecting the visible/near infrared spectrum information of the pesticide residue of the Hami melon.
And S2, preprocessing the spectral data.
And S3, dividing the spectral data into a training set and a test set according to a certain proportion.
And S4, constructing an asymmetric multi-scale one-dimensional convolutional neural network model.
And S5, outputting the identification result of the pesticide residue of the Hami melon.
Preferably, in step S1, the visible/near infrared spectrometer is used to collect the spectral information of the residue-free hami melon, chlorothalonil and imidacloprid.
Preferably, the instrumentation and acquisition parameters of the visible/near infrared spectrometer include: the spectral resolution of the QE Pro micro fiber optic spectrometer is 0.69 nm, and the waveband range is 380-1100 nm; QP600-2-VIS-NIROOS-00-5172-11 fiber probe, 3 cm from the surface of Hami melon; the spectrum acquisition mode is diffuse reflection, the integration time is 100 ms, and the average scanning time is 10 times.
Preferably, in step S2, the collected spectral information is preprocessed by using Savitzky-Golay first derivative and standard deviation normalization algorithm.
Preferably, in step S3, the ratio of the training set to the test set is 8: 2.
Preferably, in step S4, the asymmetric multi-scale one-dimensional convolutional neural network model includes 1 input layer, 3 convolutional channels, 1 fusion layer, 1 flat layer, 1 fully-connected layer, and 1 output layer.
Preferably, the 3 convolution channels comprise convolution and pooling module types as follows.
Convolution channel 1 employs 1 convolution module, where the number of convolution kernels is 16, the size is 1 × 1, the step size is 2, and the activation function is ReLU.
The convolution channel 2 adopts 1 pooling module and 1 convolution module, wherein the pooling mode is maximum pooling, the number of convolution kernels is 16, the size is 1 multiplied by 1, the steps are both 2, and the activation function is ReLU.
The convolution channel 3 adopts 3 convolution modules, wherein the number of convolution kernels is 16, the sizes are 1 × 1, 3 × 1 and 5 × 1 respectively, the steps are 2, and the activation function is ReLU.
Preferably, the fusion mode of the fusion layer is cascade, that is, the extracted depth features are spliced along the length direction, and the calculation formula is as follows:
;
whereinThe feature vector after the fusion is represented,v 1、v 2andv 3each represents a feature vector after feature extraction of 3 convolution channels.
Preferably, the fully-connected layer includes 128 neurons and the activation function is ReLU.
Preferably, the loss function of the output layer is a cross entropy function, the optimization algorithm is random gradient descent, the classification activation function is a softmax function, and the number of neurons is 3.
Preferably, the model is trained using the training set data in step S3, and the model performance is tested using the test set data.
The invention has the beneficial effect. The invention provides a Hami melon pesticide residue identification method based on a convolutional neural network, which has important significance for realizing the rapid nondestructive detection of the Hami melon pesticide residue, provides reference for the pesticide residue detection research of other similar large fruits, and has the following specific beneficial effects.
(1) The Hami melon pesticide residue is identified by adopting a visible/near infrared spectrum technology, a sample does not need to be pretreated, the steps are simple and the consumed time is short compared with a chemical detection method, and a technical reference is provided for the rapid nondestructive detection of the fruit pesticide residue.
(2) The asymmetric multi-scale one-dimensional convolutional neural network is adopted to construct the model, the depth characteristics of the spectrum can be automatically extracted and fused, the requirement of a traditional chemometrics modeling method on characteristic screening is avoided, the modeling speed and the model precision are effectively improved, and the accurate identification of the existence of pesticide residues, chlorothalonil and imidacloprid residues in the Hami melon can be realized.
Drawings
Fig. 1 is a flowchart of a cantaloupe pesticide residue identification method based on a convolutional neural network in the embodiment of the present invention.
Fig. 2 is a structural diagram of an asymmetric multi-scale one-dimensional convolutional neural network model in the embodiment of the present invention.
FIG. 3 is a normalized confusion matrix graph of model test results in an embodiment of the invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be described in detail below with reference to the accompanying drawings in the embodiments of the present invention. The invention is not limited to the described embodiments, but all other embodiments that can be obtained by a person skilled in the art without inventive step are included in the scope of protection of the invention.
Fig. 1 is a flowchart of a method for identifying pesticide residues in cantaloupes based on a convolutional neural network in an embodiment of the present invention, and as shown in fig. 1, the present invention provides a method for identifying pesticide residues in cantaloupes based on a convolutional neural network, which includes the following steps.
And S1, collecting the visible/near infrared spectrum information of the pesticide residue of the Hami melon.
The number of Hami melon samples in the embodiment is 90, the varieties are West Zhou honey No. 25, and the Hami melon samples are from the agricultural product transaction center in the Shihezi city; wiping the surface of Hami melon, placing in a dark and ventilated dry place (25 ℃, 30% RH) in a room for 24 hours, and then averagely dividing into 3 groups. The pesticide is selected from chlorothalonil and imidacloprid, and is sourced from agricultural and agricultural material market in the stone river market; the chlorothalonil and the imidacloprid are prepared into pesticide solution according to the mass ratio of the active ingredient content to clear water of 1: 1000. 3 groups of Hami melon samples are respectively and uniformly sprayed with clear water, chlorothalonil and imidacloprid pesticide solution: group 1 is free of pesticide residue; 2 group is chlorothalonil residue; and 3 groups are imidacloprid residues. And (3) after the prepared sample is placed in an indoor dry and ventilated place for 10 hours, collecting the visible/near infrared spectrum information of pesticide residues of the Hami melon.
Specifically, the spectrum collection position of each cantaloupe sample is an equatorial position, and the spectra are collected every 90 ° along the equatorial position, wherein 360 spectra are collected in the embodiment.
S2, in order to eliminate the translation and drift of the base line and improve the spectral sensitivity, firstly, performing spectral preprocessing on the original spectrum by adopting a Savitzky-Golay first derivative algorithm, wherein the polynomial order is 2, and the size of a filter window is 5; and in order to accelerate the convergence speed of the model, standard deviation normalization processing is carried out on the preprocessed spectral data.
And S3, dividing the preprocessed spectral data into a training set and a test set according to the ratio of 8:2, wherein the training set comprises 288 spectrums, and the test set comprises 72 spectrums.
S4, constructing an asymmetric multi-scale one-dimensional convolutional neural network model, wherein the model comprises 1 input layer, 3 convolutional channels, 1 fusion layer, 1 flat layer, 1 full-connection layer and 1 output layer, and the structure of the model is shown in FIG. 2.
Specifically, the convolution kernel size of the convolution module 1 is 1 × 1; the filter size of the maximum pooling module is 2 × 1; the convolution kernel size of the convolution module 2 is 1 × 1; the convolution kernel size of the convolution module 3 is 1 × 1; the convolution kernel size of the convolution module 4 is 3 × 1; the convolution kernel size of the convolution module 5 is 5 x 1.
Particularly, the number of convolution kernels in the convolution module is 16, the filling modes are same, and the activation functions are equal to ReLU; both convolution and pooling steps are 2.
The cascaded fusion layer splices the depth characteristics extracted by the 3 convolution channels along the length direction.
The flat layer is used for carrying out one-dimensional operation on the multi-dimensional features after cascade fusion.
The fully-connected layer includes 128 neurons, with the activation function being ReLU.
The output layer includes 3 neurons and the activation function is softmax.
The parameter updating during model training adopts a Newton momentum optimized random gradient descent method, the learning rate is 0.01, the learning rate attenuation value is 1e-6, and the momentum value is 0.8.
S5, outputting the pesticide residue identification result of Hami melon, and testing the model by using a test set, wherein the result is shown in figure 3; the identification accuracy rates of no residue, chlorothalonil and imidacloprid residue are respectively 100%, 96% and 92%, and the comprehensive identification accuracy rate reaches 95.83%.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the invention; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the spirit and scope of the technical solutions of the embodiments of the present invention.