Agricultural product pesticide residue detection method and system based on multi-scale convolutional neural network
By combining hyperspectral technology and multi-scale convolutional neural networks, rapid, accurate, and non-destructive detection of pesticide residues in agricultural products has been achieved, solving the problems of low detection efficiency and high cost in existing technologies and improving detection efficiency and accuracy.
Patent Information
- Application Number
- CN202310884037.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-18
- Publication Date
- 2025-12-16
- Estimated Expiration
- 2043-07-18
AI Technical Summary
Existing pesticide residue detection methods are inefficient, costly, and destructive. Current pesticide residue detection methods based on hyperspectral technology have shortcomings in feature extraction, and further algorithm optimization and improvement are needed.
A method for detecting pesticide residues in agricultural products based on hyperspectral technology and multi-scale convolutional neural networks is proposed. This method includes acquiring hyperspectral images, performing feature extraction and classification through multi-scale convolutional neural networks, and achieving rapid detection using spatial attention modules, feature extraction modules, and classification modules.
It enables rapid, accurate, and non-destructive detection of pesticide residues in agricultural products, improving detection efficiency and accuracy while reducing costs.
Smart Images

Figure CN117011707B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of food safety detection, and relates to a pesticide residue detection method and system, in particular to a pesticide residue detection method and system based on hyperspectral technology and a multi-scale convolutional neural network. BACKGROUND
[0002] Pesticide residue refers to the residual amount of pesticides in agricultural products. If it exceeds the national standard, it will have adverse effects on human health, and pesticide residue detection is one of the important means to ensure food safety (Document 1). Traditional pesticide residue detection methods are mainly based on chemical analysis techniques such as high-performance liquid chromatography and gas chromatography. Although these methods have high sensitivity and accuracy, they have high requirements for experimental environment, complex operation, long cycle and high cost (Documents 2-3).
[0003] In recent years, with the development of hyperspectral technology, hyperspectral technology has also been widely applied in pesticide residue detection (Document 4). It analyzes the spectral characteristics of agricultural products to quickly and accurately detect pesticide residues, and has the advantages of simple operation, short cycle and low cost, so it has broad application prospects (Document 5). However, the hyperspectral image of agricultural products contains a large amount of redundant information, and an effective feature extraction algorithm needs to be established to extract discriminative features. The existing pesticide residue detection methods based on hyperspectral technology still have deficiencies in feature extraction, and further algorithm optimization and improvement are needed to realize more accurate and reliable pesticide residue detection.
[0004] Qiao X W. Discussion on some problems of pesticide residue dietary exposure assessment in food [J]. Journal of Pesticide Science, 2020, 22(5): 727-733.
[0005] Lin T, Shao J L, Liu X Y, et al. Determination of 41 pesticide residues in vegetables by QuEChERS-ultra performance liquid chromatography-tandem mass spectrometry [J]. Chromatography, 2015, 33(3): 235-241.
[0006] Li J M, Zhong D B, Wang Y Q, et al. On-line gel permeation chromatography-gas chromatography / mass spectrometry for the determination of 153 pesticide residues in tea [J]. Chromatography, 2010, 28(9): 840-848.
[0007] Wang L, Qiao X Y, Dong Y E, et al. Application progress of hyperspectral image technology in agricultural product detection [J]. Applied Optics, 2009, 30(4): 639-645.
[0008] Zhao M T, Li B C, Zhou Y, et al. Hyperspectral detection of low-concentration pesticide residues on the surface of fragrant pears [J]. Optical Technology, 2016(5): 408-412. SUMMARY
[0009] In order to solve the problems of low detection efficiency, high cost and loss detection of the prior art detection method, the present application provides a pesticide residue rapid detection method and system for agricultural products based on hyperspectral technology and a multi-scale convolutional neural network, which can be applied to pesticide residue detection of agricultural products such as tea.
[0010] The technical scheme adopted by the method of the present application is: a pesticide residue detection method for agricultural products based on a multi-scale convolutional neural network, comprising the following steps:
[0011] Step 1: collecting hyperspectral images of agricultural products;
[0012] Step 2: inputting the hyperspectral images into a multi-scale convolutional neural network for rapid detection and analysis of pesticide residues;
[0013] The multi-scale convolutional neural network comprises a spatial attention module, a feature extraction module and a classification module.
[0014] The spatial attention module comprises a global max pooling layer, a global average pooling layer, a connection layer, a dimension reduction convolution layer, a sigmoid activation function layer and a multiplication operation layer.
[0015] The feature extraction module comprises four multi-scale convolution blocks, each of which comprises a batch normalization layer, a multi-scale convolution layer and a LeakyReLU activation function layer.
[0016] The classifier module is composed of a full connection layer and a Softmax activation function layer, wherein the input channel number of the full connection layer is the feature dimension, and the output channel number is the number of pesticide categories.
[0017] As a preferred, in step 1, the collected hyperspectral images of agricultural products are preprocessed, including noise reduction and normalization of hyperspectral data, the noise reduction is to remove part of the abnormal values and noise in the data by using wavelet transform, and the normalization is to eliminate the differences between sample data collected at different positions and different times by using maximum and minimum value normalization.
[0018] As a preferred, in step 2, the spatial attention module first performs global max pooling and global average pooling on the channel dimension of the original feature map to obtain two feature maps, and then connects the two feature maps; then a convolution operation with a convolution kernel size of 7 and a step of 1 is used to reduce the feature map channel dimension to 1, and then a sigmoid activation function is used to obtain the spatial attention weight; finally, the original feature map is multiplied by the spatial attention weight to obtain the final weighted feature map.
[0019] Preferably, in step 2, the feature extraction module comprises 4 multi-scale convolution blocks, each of which comprises a batch normalization layer, a multi-scale convolution layer and a LeakyReLU activation function; for each input feature representation, one-third of the channels are convolved with a 1x1 filter, one-third of the channels are convolved with a 3x3 filter, and the remaining channels are convolved with a 5x5 filter; the step size of the convolution kernel in all convolution layers is 1.
[0020] Preferably, in step 2, the multi-scale convolutional neural network is a trained multi-scale convolutional neural network; the training process comprises the following sub-steps:
[0021] Step S1: Prepare agricultural product samples and collect hyperspectral data thereof;
[0022] Step S2: Preprocess the collected hyperspectral image data;
[0023] Step S3: Prepare a pesticide type recognition data set;
[0024] Step S4: Input the preprocessed hyperspectral data into the multi-scale convolutional neural network for training, extract multi-scale spatial-spectral features related to pesticide residues, and continuously optimize the model parameters through a back propagation algorithm so that the model can accurately identify pesticide residues.
[0025] Preferably, in step S1, a plurality of fresh tea leaves are collected and subjected to fixation or withering pretreatment, and fixation and withering are the primary processing procedures for different tea leaves, the former generally uses high-temperature baking or steaming method, and the latter places fresh tea leaves at appropriate temperature and humidity for a period of time to lose water and make tea leaves soft.
[0026] Preferably, in step S2, the preprocessing comprises denoising and spectral normalization; first, the original spectral data is subjected to smoothing filtering to remove high-frequency noise points, improve the signal-to-noise ratio, and smooth the original data sequence; then, the hyperspectral data is subjected to normalization processing to eliminate the differences between different spectral data.
[0027] Preferably, in step S3, the pesticide type detection data set is prepared by first labeling the hyperspectral data to obtain pesticide type labels in different sample data, and then dividing the labeled data set into a training set and a test set.
[0028] Preferably, in step S4, a cross-entropy loss function is used in the training process, and the network is trained until it converges, i.e., the training loss curve remains stable and does not decrease any more. The pesticide type with the highest prediction probability is taken as the final detection result.
[0029] The technical scheme adopted by the system of the present application is: a pesticide residue detection system for agricultural products based on a multi-scale convolutional neural network, comprising:
[0030] one or more processors;
[0031] a storage device for storing one or more programs, which when executed by the one or more processors, cause the one or more processors to implement the pesticide residue detection method based on the multi-scale convolutional neural network.
[0032] The present application adopts atlas-unified hyperspectral technology and multi-scale convolutional neural network model to realize pesticide residue detection of agricultural products. This technology combines hyperspectral imaging technology and deep learning algorithm. First, the hyperspectral image of agricultural products is obtained by using hyperspectral imaging instrument. These images contain rich spectral information. Then, the multi-scale convolutional neural network model is used for feature extraction and classification of the hyperspectral image, so as to realize the detection of pesticide residues in agricultural products. Compared with traditional detection methods, the present application has the advantages of automation, non-damage, non-pollution, rapidness and high efficiency, which can greatly improve the accuracy and efficiency of pesticide residue detection of agricultural products, and provide strong guarantee for the quality and safety of agricultural products. BRIEF DESCRIPTION OF DRAWINGS
[0033] The technical solutions of the present application are further described below using examples and specific embodiments. In addition, some drawings are also used in the process of explaining the technical solutions. For those skilled in the art, other drawings and the intention of the present application can also be obtained without creative labor.
[0034] Figure 1 The method flowchart of the embodiment of the present application is as follows:
[0035] Figure 2 The multi-scale convolutional neural network structure diagram of the embodiment of the present application is as follows:
[0036] Figure 3 The multi-scale convolutional neural network training flowchart of the embodiment of the present application is as follows. DETAILED DESCRIPTION
[0037] In order to facilitate those skilled in the art to understand and implement the present application, the present application is further described in detail below in combination with drawings and examples. It should be understood that the implementation examples described herein are only used to illustrate and explain the present application, and are not used to limit the present application.
[0038] The present embodiment takes tea pesticide residue detection as an example to further illustrate the present application. Please see Figure 1 The tea pesticide residue detection method based on the multi-scale convolutional neural network provided in the present embodiment comprises the following steps:
[0039] Step 1: Place the agricultural products evenly on the conveyor belt, pass through the darkroom at a fixed conveying speed, use the imaging spectrometer and artificial light source to obtain hyperspectral images, and perform image preprocessing;
[0040] In an embodiment, the image preprocessing includes noise reduction and normalization of the hyperspectral data, the noise reduction removes part of the abnormal values and noise in the data using wavelet transform, and the normalization eliminates the differences between sample data collected at different positions and different times using maximum and minimum value normalization.
[0041] Step 2: Input the hyperspectral image into a multi-scale convolutional neural network for rapid detection and analysis of pesticide residues.
[0042] See Figure 2 , the multi-scale convolutional neural network includes a spatial attention module, a feature extraction module, and a classification module; the spatial attention module includes a global maximum pooling layer, a global average pooling layer, a connection layer, a dimension reduction convolution layer, a sigmoid activation function layer, and a multiplication operation layer; the feature extraction module includes four multi-scale convolution blocks, each multi-scale convolution block includes a batch normalization layer, a multi-scale convolution layer, and a LeakyReLU activation function layer; the classifier module is composed of a full connection layer and a Softmax activation function layer, wherein the input channel number of the full connection layer is the feature dimension, and the output channel number is the number of pesticide categories.
[0043] In an embodiment, the spatial attention module first performs global maximum pooling and global average pooling on the channel dimension of the original feature map to obtain two feature maps, and connects the two feature maps. Then, a convolution operation with a convolution kernel size of 7 and a step size of 1 is used to reduce the feature map channel dimension to 1, and then a sigmoid activation function is used to obtain a spatial attention weight. Finally, the original feature map is multiplied by the spatial attention weight to obtain a final weighted feature map;
[0044] In an embodiment, the feature extraction module includes four multi-scale convolution blocks, each multi-scale convolution block includes a batch normalization layer, a multi-scale convolution layer, and a LeakyReLU activation function. The multi-scale convolution layer has one-third of the channels convolved with a 1x1 filter, one-third of the channels convolved with a 3x3 filter, and the remaining channels convolved with a 5x5 filter for each input feature representation. The step size of the convolution kernel in all convolution layers is 1;
[0045] In an embodiment, the classifier module is composed of a full connection layer and a Softmax activation function, wherein the input channel number of the full connection layer is the feature dimension, and the output channel number is the number of pesticide categories.
[0046] See Figure 3In an embodiment, the multi-scale convolutional neural network is a trained multi-scale convolutional neural network; the training process comprises the following sub-steps:
[0047] Step S1: preparing a sample of agricultural products and collecting hyperspectral data thereof;
[0048] In an embodiment, the sample of agricultural products is obtained by collecting several fresh tea leaves, and then performing fixation or withering pretreatment on the fresh tea leaves, wherein the fixation and the withering are respectively the primary processing procedures for different tea leaves, the former generally adopts high-temperature baking or steaming, and the latter places the fresh tea leaves at appropriate temperature and humidity for a period of time to cause water loss and softening of the tea leaves.
[0049] Step S2: pre-processing the collected hyperspectral image data;
[0050] In an embodiment, the pre-processing comprises denoising and spectral normalization; first, smoothing filtering is performed on the original spectral data to remove high-frequency noise points, improve the signal-to-noise ratio, and smooth the original data sequence. Then, normalization processing is performed on the hyperspectral data to eliminate the differences between different spectral data.
[0051] Step S3: preparing a pesticide type recognition data set;
[0052] In an embodiment, in step S3, the pesticide type detection data set is prepared by first labeling the hyperspectral data to obtain pesticide type labels in different sample data, and then dividing the labeled data set into a training set and a test set.
[0053] Step S4: inputting the pre-processed hyperspectral data into the multi-scale convolutional neural network model for training, extracting multi-scale spatial-spectral features related to pesticide residues, and constantly optimizing model parameters through a back propagation algorithm to enable accurate identification of pesticide residues.
[0054] In an embodiment, in step S4, a cross-entropy loss function is used in the training process, and the network is trained until convergence, i.e., the training loss curve remains stable and does not decrease any more. The pesticide type with the highest prediction probability is taken as the final detection result.
[0055] The application also provides a multi-scale convolutional neural network-based agricultural product pesticide residue detection system, comprising:
[0056] one or more processors;
[0057] a storage device for storing one or more programs, which, when executed by the one or more processors, cause the one or more processors to implement the multi-scale convolutional neural network-based agricultural product pesticide residue detection method.
[0058] The application can realize accurate detection of pesticide residues in tea leaves, has the advantages of fast detection speed, low cost and simple operation, and can be widely applied to pesticide residue detection of other agricultural products, and has good popularization and application prospect.
[0059] It should be understood that the above description of the preferred embodiments is more detailed, and therefore should not be considered as limiting the scope of patent protection of the application. Ordinary skilled in the art can make substitutions or modifications without departing from the scope of protection of the claims under the inspiration of the application, which all fall within the protection scope of the application. The scope of protection of the application should be subject to the appended claims.
Claims
1. A method for detecting pesticide residues in agricultural products based on a multi-scale convolutional neural network, characterized in that, The method comprises the following steps: Step 1: collecting hyperspectral images of agricultural products; Step 2: inputting the hyperspectral images into a multi-scale convolutional neural network for rapid detection and analysis of pesticide residues; The multi-scale convolutional neural network comprises a spatial attention module, a feature extraction module and a classification module; The spatial attention module comprises a global max pooling layer, a global average pooling layer, a connection layer, a dimension reduction convolution layer, a sigmoid activation function layer and a multiplication operation layer; first, the channel dimension of the original feature map is subjected to global max pooling and global average pooling to obtain two feature maps, and the two feature maps are connected; then, a convolution operation with a convolution kernel size of 7 and a step of 1 is used to reduce the channel dimension of the feature map to 1, and then a sigmoid activation function is used to obtain spatial attention weights; finally, the original feature map is multiplied by the spatial attention weights to obtain a final weighted feature map; The feature extraction module comprises four multi-scale convolution blocks, each of which comprises a batch normalization layer, a multi-scale convolution layer and a LeakyReLU activation function layer; for each input feature representation, one-third of the channels are subjected to 1x1 filter convolution, one-third of the channels are subjected to 3x3 filter convolution, and the remaining channels are subjected to 5x5 filter convolution; the step of the convolution kernel in all convolution layers is 1; The classification module comprises a full connection layer and a Softmax activation function layer, wherein the input channel number of the full connection layer is the feature dimension, and the output channel number is the number of pesticide categories. 2.The method of detecting pesticide residues in agricultural products based on a multi-scale convolutional neural network according to claim 1, characterized in that: In step 1, the collected hyperspectral images of agricultural products are preprocessed, including noise reduction and normalization of hyperspectral data; the noise reduction is to remove part of the abnormal values and noise in the data by using wavelet transform, and the normalization is to eliminate the differences between sample data collected at different positions and different times by using maximum and minimum value normalization.
3. The multi-scale convolutional neural network-based method for pesticide residue detection of agricultural products according to claim 1, characterized in that: In step 2, the multi-scale convolutional neural network is a trained multi-scale convolutional neural network; The training process comprises the following sub-steps: Step S1: preparing agricultural product samples and collecting hyperspectral data thereof; Step S2: preprocessing the collected hyperspectral image data; Step S3: preparing a pesticide category recognition data set; Step S4: inputting the preprocessed hyperspectral data into the multi-scale convolutional neural network for training, extracting multi-scale spatial-spectral features related to pesticide residues, and continuously optimizing model parameters through a back propagation algorithm to enable accurate identification of pesticide residues.
4. The method according to claim 3, wherein the method is characterized by: In step S1, a plurality of fresh tea leaves are collected, and the fresh tea leaves are subjected to fixation or withering pretreatment; fixation and withering are initial processing procedures for different tea leaves; the former generally adopts high-temperature baking or cooking methods, and the latter places fresh tea leaves at appropriate temperature and humidity for a period of time to make the tea leaves lose water and become soft.
5. The method according to claim 3, wherein the method is characterized by: In step S2, the preprocessing comprises denoising and spectral normalization; first, the original spectral data is subjected to smoothing filtering to remove high-frequency noise points and improve the signal-to-noise ratio to smooth the original data sequence; then, the hyperspectral data is subjected to normalization processing to eliminate the differences between different spectral data.
6. The method according to claim 3, wherein the method is characterized by: The pesticide type identification data set in step S3 is made by first labeling the hyperspectral data to obtain pesticide type labels in different sample data, and then dividing the labeled data set into a training set and a test set.
7. The multi-scale convolutional neural network based method for pesticide residue detection of agricultural products according to any one of claims 3-6, characterized in that: In step S4, a cross-entropy loss function is used in the training process, and the network is trained until it converges, i.e., the training loss curve remains stable and does not decrease any more; the pesticide type with the highest prediction probability is taken as the final detection result.
8. A multi-scale convolutional neural network-based agricultural product pesticide residue detection system, characterized in that, Comprise: One or more processors; A storage device for storing one or more programs, which, when executed by the one or more processors, cause the one or more processors to implement the multi-scale convolutional neural network-based agricultural product pesticide residue detection method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Method for detecting organo-chlorine pesticide residues in astragalus membranaceus
CN112345511A
Hyperspectral target detection method based on L1 regular constraint depth multi-example learning
CN112364773A