CN114519402B - Citrus disease and insect pest detection method based on neural network - Google Patents

Citrus disease and insect pest detection method based on neural network Download PDF

Info

Publication number
CN114519402B
CN114519402B CN202210400877.4A CN202210400877A CN114519402B CN 114519402 B CN114519402 B CN 114519402B CN 202210400877 A CN202210400877 A CN 202210400877A CN 114519402 B CN114519402 B CN 114519402B
Authority
CN
China
Prior art keywords
swin
contextual
transformer model
model
citrus
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202210400877.4A
Other languages
Chinese (zh)
Other versions
CN114519402A (en
Inventor
吴琪
吴云志
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Anhui Agricultural University AHAU
Original Assignee
Anhui Agricultural University AHAU
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Anhui Agricultural University AHAU filed Critical Anhui Agricultural University AHAU
Priority to CN202210400877.4A priority Critical patent/CN114519402B/en
Publication of CN114519402A publication Critical patent/CN114519402A/en
Application granted granted Critical
Publication of CN114519402B publication Critical patent/CN114519402B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/21Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
    • G06F18/214Generating training patterns; Bootstrap methods, e.g. bagging or boosting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/24Classification techniques
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/70Determining position or orientation of objects or cameras
    • G06T7/73Determining position or orientation of objects or cameras using feature-based methods

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Evolutionary Computation (AREA)
  • General Engineering & Computer Science (AREA)
  • Artificial Intelligence (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Evolutionary Biology (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Biomedical Technology (AREA)
  • Health & Medical Sciences (AREA)
  • Biophysics (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Investigating Or Analysing Biological Materials (AREA)
  • Image Analysis (AREA)

Abstract

The invention discloses a citrus disease and insect pest detection method based on a neural network model, which comprises the following steps: step 1, acquiring an image of citrus diseases and insect pests as a data set; step 2, dividing the data set into a training set and a testing set, and preprocessing; step 3, constructing a Contextual Swin Transformer model, and training the model to obtain optimal configuration parameters; and 4, identifying the citrus disease image of the disease and insect species to be identified through the model with the optimal configuration parameters to obtain a disease and insect identification result. The invention can reduce the calculation amount and improve the detection efficiency and accuracy.

Description

Citrus disease and insect pest detection method based on neural network
Technical Field
The invention relates to the field of pest and disease detection methods, in particular to a citrus pest and disease detection method based on a neural network model.
Background
In agricultural citrus planting, pest control of citrus has been a major problem because many pests are encountered during the growth of citrus, and if the pest control is not timely performed, the yield of growers is reduced, wherein red spiders, ticks, scale insects, leaf miners, canker, anthracnose, scab and the like are common pests of citrus. So timely pest control is the key to reduce loss.
With the development of science and technology, computer vision has been widely used in agriculture, can be accurate through image recognition find the pest and disease damage of oranges and tangerines to plant and the prevention of pest and disease damage play a key role to oranges and tangerines. However, the prior Transformer and traditional CNN image recognition in the prior art are applied to the field of citrus pest and disease identification, and two main problems exist: firstly, the visual entity has large change, and the visual performance is not necessarily good under different scenes, thereby leading to low accuracy; and secondly, some images have high resolution, so that the image identification process has low efficiency and large calculation amount due to more pixel points.
Disclosure of Invention
The invention aims to provide a citrus disease and insect pest detection method based on a neural network model, and aims to solve the problems of low accuracy and large calculation amount of a citrus disease and insect pest detection method based on neural network image recognition in the prior art.
In order to achieve the purpose, the technical scheme adopted by the invention is as follows:
a citrus disease and insect pest detection method based on a neural network model realizes detection based on a context Swin transducer model and comprises the following steps:
step 1, acquiring a plurality of images of a plurality of citrus diseases and insect pests as a data set;
step 2, dividing the data set into a training set and a testing set, and respectively preprocessing the data in the training set and the testing set;
step 3, constructing a Contextual Swin Transformer model, and inputting the training set into the Contextual Swin Transformer model to train the Contextual Swin Transformer model;
mapping the input of the Contextual Swin Transformer model into a query vector, a key vector and a value vector by using a self-attention mechanism in the Contextual Swin Transformer model during each training, thereby transmitting the information in the three vectors to the relative position coding of the Contextual Swin Transformer model;
after each training, outputting the identified pest and disease types by the Contextual Swin Transformer model as output results, carrying out error calculation on the output results and the test set, and then adjusting the configuration parameters of the Contextual Swin Transformer model based on the error calculation results, thereby obtaining the optimal configuration parameters of the Contextual Swin Transformer model when the error calculation results are in line with expectations after multiple times of training;
and 4, setting configuration parameters of the Contextual Swin Transformer model as the optimal configuration parameters, inputting the citrus image of the pest and disease types to be identified into the Contextual Swin Transformer model with the parameters adjusted to the optimal configuration parameters, and outputting a final pest and disease type identification result by the Contextual Swin Transformer model.
In a further step 2, the data set is divided into a training set and a test set in a ratio of 7: 3.
Further, the preprocessing in step 2 includes data augmentation, image filling, and sliding window operation processing with hierarchy.
Further, the data amplification preprocessing sequentially comprises random turning, scaling, random cutting and normalization.
Further, when data amplification is performed on the data in the training set, random inversion is performed with a probability of 0.5, and one of the random inversion from a plurality of scales is randomly selected to scale the data in the training set.
In a further step 3, the context switch transform model divides the input image into n non-overlapping windows according to the size windows size based on the self-attention mechanism, and obtains x ═ x (x is obtained 1 ,...,x n ) X represents a vector obtained after division according to the windows size; output z of ith self-attention mechanism in Contextual Swin Transformer model i By inputting x i Multiplying the result with a corresponding query parameter matrix and a key parameter matrix, then multiplying the result with a value parameter matrix through a SoftMax function, and finally mapping the input of the context Swin transform model into a query vector, a key vector and a value vector.
Further, in step 3, the error calculation performed on the trained output result and the test set includes a classification error and a regression error, and when the calculation results of the classification error and the regression error both conform to expectations, the configuration parameters of the context Swin Transformer model at this time are used as the optimal configuration parameters.
The citrus disease and insect damage image recognition method based on the context Swin Transformer model identifies the citrus disease and insect damage image, so that the disease and insect damage type is detected, wherein the context Swin Transformer model used maps input into three different vectors, so that the accuracy of output results can be ensured, the calculated amount is reduced, and the detection efficiency is improved. The method can efficiently and accurately analyze various diseases and insect pests of the citrus, so that a grower can perform symptomatic control on different conditions, and a good control effect is achieved.
Drawings
FIG. 1 is a block flow diagram of the method of the present invention.
FIG. 2 is a block diagram of the context Swin Transformer model employed in the present invention.
Fig. 3 is a structural diagram of an information interaction process in the present invention.
FIG. 4 is a test result chart showing the test results in the embodiment of the present invention.
Detailed Description
The invention is further illustrated with reference to the following figures and examples.
As shown in figure 1, the invention relates to a method for detecting citrus diseases and insect pests based on a neural network model, which comprises the following steps:
(1) preparing a data set:
collecting a plurality of leaf image datasets containing a plurality of citrus diseases and insect pests as a dataset;
(2) processing the data set:
dividing the data in the data set into a training set and a testing set according to the proportion of 7:3, and respectively preprocessing the data in the training set and the testing set.
The first step of the preprocessing is to perform data amplification, and the data amplification sequentially comprises several processes of random flip (RandomFlip), zoom (Resize), random crop (RandomCrop) and normalization. When data in the training set is subjected to data amplification, random inversion is carried out with the probability of 0.5, and 1 type of data in the training set is randomly selected from 11 types of scales so as to scale the data in the training set.
And after the data are expanded, filling (Pad) is carried out on the data so as to avoid feature loss and keep the features of citrus diseases and insect pests.
And finally, processing the image by adopting a sliding window operation with a hierarchical design.
In the sliding window operation processing, when dividing an image, the superparameter block size (patch size) is first designated 4 × 4, and a picture is sliced into window sizes of patch _ size × patch _ size one by one. The attention calculation is limited to a small window in the sliding window operation, and the resolution of the input feature map is reduced by flattening the vectors within the block. The block fusion (patch merging) in the sliding window operation processing is down-sampled before each Stage starts, and the number of channels is adjusted, so that a hierarchical design is formed. Each down-sampling is doubled, i.e. the elements are chosen in the row and column directions at an interval 2. Then the images are spliced together to be used as a whole tensor, and finally the tensors are expanded, at the moment, the dimension of the adjusting channel is doubled as compared with the original dimension through a full connection layer and is used as the input of the modified context Swin Transformer, and after 12 blocks of fusion and Swin Transformer Block, the resolution of the images is reduced to 16 times of the original resolution.
Through the pretreatment, abnormal and repeated citrus disease images can be removed from the existing training set and the testing set.
(3) Constructing a Contextual Swin Transformer model, and training to obtain optimized configuration parameters:
as shown in FIG. 2, the context Swin Transformer model of the present invention includes a Block Partition layer (Patch Partition), a layer consisting of a Patch embedding and a context Swin Transformer Block.
As shown in FIG. 3, the information transfer process of the model of the present invention is that the input vector x passes through the parameterized matrix W Q 、 W K And W V The multiplication results in the corresponding q, k, v vectors. q, k related relative position embedding matrix r q ,r k After multiplying q, k, v to exchange information, q k T Added and passed through the SoftMax layer. v-related relative position embedding matrix r v And v is multiplied and then added with v, and the added output is multiplied with the output of SoftMax.
In the invention, a training set is input into a Contextual Swin Transformer model to train the Contextual Swin Transformer model;
the Self Attention mechanism Self attribute in the context switch Transformer model is utilized to map the input of the context switch Transformer model (namely, the image data of the training set) into a query vector, a key vector and a value vector during each training, thereby transferring the information in the three vectors into the relative position coding of the context switch Transformer model. The Self Attention is calculated as follows:
Figure GDA0003687935400000041
wherein, the first and the second end of the pipe are connected with each other,
Figure GDA0003687935400000042
is a parameterized matrix, W Q ,W K ,W V The method is characterized in that the method is a learnable parameter matrix, x represents a vector in a window (windows) in Self attribute, z represents an output vector of Self attribute, a Swin transform divides a feature map into n non-overlapping windows according to window sizes, wherein i represents an ith window (windows), j represents a jth window (windows), relative position coding in a Swin transform model does not generate information interaction with query, key and value values, and the method can interact with query, key and value values and transmit information in three vectors to the relative position coding.
The relative position codes in the context Swin Transformer model of the invention are as follows:
Figure GDA0003687935400000051
from the above formula, it can be seen that, in the context switch transform model of the present invention, the context switch transform model divides the input image into n non-overlapping windows according to the size of windows size based on the self-attention mechanism, and obtains x ═ x (x ═ x 1 ,...,x n ) X represents a vector obtained after the windows size is divided; n is represented as the number of windows (windows), where i ═ {1, 2, 3 … … n }, j ═ 2, 3 … … n }; the output of the ith Self Attentention in the Contextual Swin Transformer model is denoted as z i By inputting x i Multiplying the result with a corresponding query parameter matrix and a key parameter matrix, then multiplying the result with a value parameter matrix through a SoftMax function, and finally mapping the input of the context Swin transform model into a query vector, a key vector and a value vector.
For a more intuitive representation, the relative position bias strategy proposed in Swin Transformer can be simply expressed as follows:
Figure GDA0003687935400000052
in the present invention, the relative position bias is modified to a conditional relative position bias, which includes:
Figure GDA0003687935400000053
wherein:
B q,k =Q(B q ) T +K(B k ) T
Figure GDA0003687935400000054
is the query, key, value vector, B in the Attention q ,B k ,B v Are relative position matrices corresponding to Q, K, V, where M is the number of blocks (patches) in the window (windows) and d is the dimension of the Self Attention output vector z.
The invention additionally establishes three learnable position offset tables
Figure GDA0003687935400000055
To guide the relative position matrix B q ,B k ,B v The generation of (c) is as follows:
Q,K,V∈R M×M×d
Figure GDA0003687935400000061
in the context Swin transform model, M is generated by the relative position coding 2 ×M 2 And d learnable parameter matrixes are learnt. Compared with the traditional relative position offset, the context Swin Transformer model of the invention increases the information transmission with three vectors of query, value and key,
compared with the traditional relative position coding, the method greatly reduces the number of parameters.
Through multiple times of training, the Contextual Swin Transformer model outputs the pest type as an output result during each training. And calculating the classification error and the regression error of the model output result and the test set, and adjusting the configuration parameters of the trained Contextual Swin Transformer model into optimal configuration parameters according to the verification and test results, wherein the Contextual Swin Transformer model under the optimal configuration parameters is used as a final model.
(5) Image recognition:
selecting images corresponding to three citrus diseases and insect pests (HLB, HEALTH and ILL), inputting the images of the diseases and insect pests serving as a data set to be identified into the final Contextual Swin Transformer model in the step (4), and outputting a disease and insect pest identification result by the Contextual Swin Transformer model to obtain information of which disease and insect pest the input image belongs to, so as to realize accurate identification and detection.
As shown in FIG. 4, the image detected by the method of the invention shows that the model has the capability of detecting citrus diseases and pests, and the accuracy rate can reach more than 95%.
The embodiments of the present invention are described only for the preferred embodiments of the present invention, and not for the limitation of the concept and scope of the present invention, and various modifications and improvements made to the technical solution of the present invention by those skilled in the art without departing from the design concept of the present invention shall fall into the protection scope of the present invention, and the technical content of the present invention which is claimed is fully set forth in the claims.

Claims (6)

1. A citrus disease and insect pest detection method based on a neural network model is characterized in that detection is realized based on a Contextual Swin Transformer model, and the method comprises the following steps:
step 1, acquiring a plurality of images of a plurality of citrus diseases and insect pests as a data set;
step 2, dividing the data set into a training set and a testing set, and respectively preprocessing the data in the training set and the testing set;
step 3, constructing a Contextual Swin Transformer model, and inputting the training set into the Contextual Swin Transformer model to train the Contextual Swin Transformer model;
each training time utilizes the self-attention mechanism in the Contextual Swin Transformer model, the block division part of the Contextual Swin Transformer model divides the input image into n blocks of 4 × 4, and the n blocks are flattened to obtain x ═ x (x ═ x { (x) } through flattening operation 1 ,x 2 ...,x n ) X represents a vector obtained after patch partition; output z of ith self-attention mechanism in Contextual Swin Transformer model i Is formed by inputting x i Multiplying the result with a corresponding query parameter matrix and a key parameter matrix, then multiplying the result with a value parameter matrix through a SoftMax function, and finally mapping the input of the context Swin Transformer model into a query vector, a key vector and a value vector, so that the information in the query vector, the key vector and the value vector is transmitted to the relative position coding of the context Swin Transformer model;
the relative position bias strategy proposed in Swin Transformer is simply expressed as follows:
Figure FDA0003687935390000011
modifying the relative position bias into a textual relative position bias includes:
Figure FDA0003687935390000012
wherein:
B q,k =Q(B q ) T +K(B k ) T
Figure FDA0003687935390000013
is the query, key, value vector, B in the Attention q ,B k ,B v All are relative position matrixes corresponding to Q, K and V, wherein M is the number of dispatches in the window, and d is the dimensionality of the output vector z of the Self Attention;
additionally establishing three learnable position offset tables
Figure FDA0003687935390000014
To guide the relative position matrix B q ,B k ,B v The generation of (c) is as follows:
Q,K,V∈R M×M×d
Figure FDA0003687935390000021
in the context Swin transform model, M is generated by the relative position coding 2 ×M 2 Learning by x d learnable parameter matrixes;
after each training, outputting the identified pest and disease types by the Contextual Swin Transformer model as output results, carrying out error calculation on the output results and the test set, and then adjusting the configuration parameters of the Contextual Swin Transformer model based on the error calculation results, thereby obtaining the optimal configuration parameters of the Contextual Swin Transformer model when the error calculation results are in line with expectations after multiple times of training;
and 4, setting configuration parameters of the Contextual Swin Transformer model as the optimal configuration parameters, inputting the citrus image of the pest and disease types to be identified into the Contextual Swin Transformer model with the parameters adjusted to the optimal configuration parameters, and outputting a final pest and disease type identification result by the Contextual Swin Transformer model.
2. The citrus disease and pest detection method based on the neural network model according to claim 1, wherein in the step 2, the data set is divided into a training set and a testing set according to a ratio of 7: 3.
3. The method for detecting citrus diseases and pests based on the neural network model according to claim 1, wherein the preprocessing in the step 2 comprises data amplification, image filling and sliding window operation processing with hierarchy.
4. The citrus disease and pest detection method based on the neural network model according to claim 3, wherein the data amplification pretreatment sequentially comprises random inversion, scaling, random cutting and normalization.
5. The citrus disease and pest detection method based on the neural network model is characterized in that when data amplification is carried out on data in the training set, random inversion is carried out with the probability of 0.5, and one of a plurality of scales is randomly selected to scale the data in the training set.
6. The citrus disease and pest detection method based on the neural network model according to claim 1, wherein in the step 3, the error calculation performed on the trained output result and the test set includes a classification error and a regression error, and when the calculation results of the classification error and the regression error are both in accordance with expectations, the configuration parameters of the context Swin Transformer model at the moment are taken as the optimal configuration parameters.
CN202210400877.4A 2022-04-18 2022-04-18 Citrus disease and insect pest detection method based on neural network Active CN114519402B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210400877.4A CN114519402B (en) 2022-04-18 2022-04-18 Citrus disease and insect pest detection method based on neural network

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210400877.4A CN114519402B (en) 2022-04-18 2022-04-18 Citrus disease and insect pest detection method based on neural network

Publications (2)

Publication Number Publication Date
CN114519402A CN114519402A (en) 2022-05-20
CN114519402B true CN114519402B (en) 2022-08-09

Family

ID=81600103

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210400877.4A Active CN114519402B (en) 2022-04-18 2022-04-18 Citrus disease and insect pest detection method based on neural network

Country Status (1)

Country Link
CN (1) CN114519402B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114943831A (en) * 2022-07-25 2022-08-26 安徽农业大学 Knowledge distillation-based mobile terminal pest target detection method and mobile terminal equipment

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114066820A (en) * 2021-10-26 2022-02-18 武汉纺织大学 Fabric defect detection method based on Swin-transducer and NAS-FPN

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111178177A (en) * 2019-12-16 2020-05-19 西京学院 Cucumber disease identification method based on convolutional neural network
CN114199880A (en) * 2021-11-22 2022-03-18 西南大学 Citrus disease and insect pest real-time detection method based on edge calculation
CN114241307B (en) * 2021-12-09 2023-01-24 中国电子科技集团公司第五十四研究所 Self-attention network-based synthetic aperture radar aircraft target identification method

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114066820A (en) * 2021-10-26 2022-02-18 武汉纺织大学 Fabric defect detection method based on Swin-transducer and NAS-FPN

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
CRTransSar: A Visual Transformer Based on Contextual Joint Representation Learning for SAR Ship Detection;Tianwen Zhang等;《Remote Sensing》;20220319;第1-27页 *

Also Published As

Publication number Publication date
CN114519402A (en) 2022-05-20

Similar Documents

Publication Publication Date Title
Kamath et al. Classification of paddy crop and weeds using semantic segmentation
CN111582401B (en) Sunflower seed sorting method based on double-branch convolutional neural network
CN114519402B (en) Citrus disease and insect pest detection method based on neural network
EP3971767A1 (en) Method for constructing farmland image-based convolutional neural network model, and system thereof
US20240212162A1 (en) Semantic segmentation method for cross-satellite remote sensing images based on unsupervised bidirectional domain adaptation and fusion
CN115661544B (en) Spinach seedling water stress grade classification system and method based on N-MobileNetXt
CN114821338A (en) Sugarcane multi-disaster meteorological disaster early warning method based on multi-source heterogeneous data fusion
CN114663777B (en) Hyperspectral image change detection method based on space-time joint graph attention mechanism
Wang et al. DualSeg: Fusing transformer and CNN structure for image segmentation in complex vineyard environment
CN114764827B (en) Self-adaptive mulberry leaf disease and pest detection method in low-light scene
CN113936019A (en) Method for estimating field crop yield based on convolutional neural network technology
CN117853861A (en) Training method of crop disease recognition model and crop disease recognition method
CN116524283A (en) Agricultural insect pest image detection and classification method and system
CN116977862A (en) Video detection method for plant growth stage
CN116740567A (en) Soil moisture content detection method and system for Paulownia seedling cultivation
CN116844041A (en) Cultivated land extraction method based on bidirectional convolution time self-attention mechanism
CN116258914A (en) Remote sensing image classification method based on machine learning and local and global feature fusion
CN115546745A (en) Road cleaning segmentation and identification method based on cross-modal cleaning robot
CN116257786A (en) Asynchronous time sequence classification method based on multi-element time sequence diagram structure
CN114741548A (en) Mulberry leaf disease and insect pest detection method based on small sample learning
CN114627370A (en) Hyperspectral image classification method based on TRANSFORMER feature fusion
CN112131954A (en) China northern winter wheat remote sensing estimated yield based on convolutional neural network
CN111899234A (en) Citrus disease and insect pest epidemic situation intelligent pushing system based on big data mining
CN113128577B (en) Intertillage period sugarcane seedling ridging method based on machine learning
CN117115668B (en) Crop canopy phenotype information extraction method, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant