Plant leaf disease identification method based on FasterNet

By improving the image embedding module and feature extraction process of the FasterNet model and combining it with multi-label learning technology, the problems of feature loss and time-consuming annotation in the identification of plant leaf diseases by the FasterNet model were solved, and higher recognition accuracy and efficiency were achieved.

CN119295926AActive Publication Date: 2025-01-10SOUTH CHINA AGRICULTURAL UNIVERSITY +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411337914.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-25
Publication Date
2025-01-10
Estimated Expiration
2044-09-25

AI Technical Summary

Technical Problem

The existing FasterNet model suffers from feature loss and imbalanced feature extraction in plant leaf disease identification, which affects the accuracy of identification, and the target box annotation step is time-consuming.

Method used

The FasterNet model is improved by adding convolutional layers and SE_Block blocks to the image embedding module. Combined with multi-label learning techniques, the feature extraction and prediction layers are optimized to reduce feature loss and improve the model's attention to image regions.

Benefits of technology

It improves the accuracy of plant leaf disease identification, reduces the time cost of target box annotation, and enables the simultaneous identification of multiple disease features.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119295926A_ABST
    Figure CN119295926A_ABST
Patent Text Reader

Abstract

The invention provides a Faster Net-based plant leaf disease identification method. The method comprises the following steps: firstly, acquiring original plant leaf disease identification images of a corresponding category, and storing the original plant leaf disease identification images into image folders of the corresponding category according to the image category; traversing the original plant leaf disease identification images in the image folder of each category by using Python, dividing the original images into training original images, verification original images and test original images in proportion, and performing preprocessing to obtain a plant leaf disease identification image data set; then, constructing an original Faster Net model, and improving the original Faster Net model to obtain a Faster Net Improved model; obtaining a model parameter tensor, which needs to be iteratively trained and verified, of the Faster NetImproved model, and initializing the model parameter tensor; thirdly, carrying out iterative training and verification on the Faster NetImproved model to obtain an optimal model parameter tensor omega FI, and storing the optimal model parameter tensor omega FI; and the Faster NetImproved model after the training and the verification is carried out on the Faster NetImproved model. The invention aims to improve the accuracy of plant leaf disease identification and reduce the time cost of dependent target frame labeling.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of plant leaf disease recognition and computer vision, and specifically relates to a plant leaf disease recognition method based on FasterNet. Background Art

[0002] Plant leaf diseases can seriously affect plant growth. Through accurate and effective plant leaf disease recognition, leaf disease prevention and control can be achieved, the use of pesticides can be reduced, and the pollution of soil, water sources and ecosystems can be reduced (Hu Qiuxia. Research on plant leaf disease recognition method based on image analysis [D]. Northwest A&F University, 2013.). Traditional plant leaf disease recognition is mainly carried out by farmers or field experts through naked eye observation and based on experience. The use of lightweight deep learning methods for plant leaf disease recognition can improve the efficiency of implementation. Hu et al. (Hu Y, Liu G, Chen Z, et al. Lightweight one-stage maize leaf disease detection model with knowledge distillation [J]. Agriculture, 2023, 13 (9).) proposed a currently more efficient plant leaf disease recognition method. This method combines the lightweight image classification model FasterNet and the YOLOv5 algorithm. It can accurately identify multiple diseases on a plant leaf while ensuring that the model is small, but this method relies on the target box annotation step. According to the research of Everingham et al. (Everingham M, Eslami SMA, Van Gool L, et al. The Pascal visual object classes challenge: A retrospective [J]. International Journal of Computer Vision, 2015, 111: 98-136.), the target box annotation step is relatively time-consuming. At the same time, the FasterNet model used in the literature of Hu et al. emphasizes universal recognition.According to the research of Qian et al. (Qian S, Shao H, Zhu Y, et al. Blending anti-aliasing into vision transformer [C] / / Proceedings of the 35th Conference on Neural Information Processing Systems. 2021, 7: 5416-5429.) and Xiao et al. (Xiao T, Singh M, Mintun E, et al. Early convolutions help transformers see better [C] / / Proceedings of the 35th Conference on Neural Information Processing Systems. 2021, 36: 30392-30400.), the image embedding module in the FasterNet model will cause some features in the original image input to the model to be lost. When applied to plant leaf disease recognition, the image embedding module in the FasterNet model will affect the accuracy of plant leaf disease recognition to a certain extent because the plant leaf disease image has the characteristics of a large feature distribution range and complex features. At the same time, the feature extraction module in the FasterNet model does not use the attention mechanism. During the feature extraction process, the model cannot effectively adjust the attention of each area in the image, making some areas in the image irrelevant to the classification become noise, affecting the accuracy of plant leaf disease recognition (Wang Q, Wu B, Zhu P, et al. ECA-Net: Efficient channel attention for deep convolutional neural networks [C] / / Proceedings of the 2020 IEEE / CVF Conference on Computer Vision and Pattern Recognition. 2020: 11531-11539.). Therefore, it is of great theoretical significance and application value to study how to improve the efficiency of plant leaf disease recognition by improving the FasterNet model. Summary of the invention

[0003] The main purpose of the present invention is to overcome the shortcomings and deficiencies of the prior art, provide a plant leaf disease recognition method based on FasterNet, improve the FasterNet model and combine it with multi-label learning technology to further improve the accuracy of plant leaf disease recognition and reduce the time cost of target frame annotation.

[0004] In order to achieve the above object, the present invention adopts the following technical solutions:

[0005] A plant leaf disease recognition method based on FasterNet comprises the following steps:

[0006] Determine the classification label type for leaf disease identification of the target plant, construct a plant leaf disease identification feature category name set, and construct a plant leaf disease identification image category name set based on the plant leaf disease identification feature category name set, obtain the original plant leaf disease identification image of the corresponding category for the category in the plant leaf disease identification image category name set, and obtain the original plant leaf disease identification image set;

[0007] Based on the category names in the plant leaf disease recognition image category name set, an image folder of a corresponding category is established; the images in the obtained original plant leaf disease recognition image set are stored in the image folder of the corresponding category according to the image category, so as to obtain a plant leaf disease recognition image dataset before preprocessing;

[0008] In each category of image folder, a training folder, a verification folder, and a test folder are simultaneously established; Python is used to traverse the original plant leaf disease recognition images in each category of the image folder in the plant leaf disease recognition image dataset before preprocessing, and the images are divided into training original images, verification original images, and test original images in proportion, and the training original images are stored in the training folder in the image folder of the corresponding category, the verification original images are stored in the verification folder in the image folder of the corresponding category, and the test original images are stored in the test folder in the image folder of the corresponding category;

[0009] Preprocess the images in all training folders, verification folders and test folders to obtain preprocessed training images, preprocessed verification images and preprocessed test images, and obtain a plant leaf disease recognition image dataset;

[0010] Construct the original FasterNet model and improve the original FasterNet model to get FasterNet Improved Model, represented by: TPLb = FasterNet Improved (TInput,ω FI ), where TPLb is FasterNet Improved The model's predicted label tensor, TInput is the input tensor, ω FI is the model parameter tensor;

[0011] Get FasterNet Improved The model parameter tensor that the model needs to iteratively train and validate;

[0012] Initialize the FasterNet Improved model;

[0013] Use the pre - processed training images in all training folders and the pre - processed validation images in all validation folders to iteratively train and validate the FasterNet Improved model to obtain the optimal model parameter tensor ω FI and save it;

[0014] Test the trained and validated FasterNet Improved model.

[0015] As a preferred technical solution, the obtaining of the original plant leaf disease recognition image set is specifically as follows:

[0016] Determine the leaf disease recognition classification label type tyLabl ∈ {0, 1} of the target plant according to the requirement. When tyLabl = 0, it means that each image in the original plant leaf disease recognition image set will be single - labeled, and when tyLabl = 1, it means that each image in the original plant leaf disease recognition image set will be multi - labeled;

[0017] Determine the number of plant leaf disease recognition feature categories nmCFt and the set of plant leaf disease recognition feature category names neCFt = neHCFt ∪ neDCFt; where, neHCFt = {neCFt1} is the set of healthy feature category names, and neDCFt = {neCFt i |i ∈ {2,…,nmCFt}} is the set of disease feature category names; Let neSDCFt = {neCFt j1 ,…,neCFt j|neSDCFt| |2 ≤ j1 < … < j|neSDCFt| ≤ nmCFt} be the non - empty and non - single - element ordered subset of neDCFt, where neCFt j1 is the j1 - th element in neCFt, and |neSDCFt| is the length of neSDCFt;

[0018] When tyLabl = 0, the number of plant leaf disease recognition image categories is nmCIm = nmCFt; when tyLabl = 1, the number of plant leaf disease recognition image categories is nmCIm = 2 (nmCFt-1) , then the set of plant leaf disease recognition image category names is:

[0019] where is an empty set, ∨ is logical OR, and ∧ is logical AND;

[0020] Identify the image category name neCIm for each plant leaf disease k ∈neCIm, where 1≤k≤nmCIm, nmOIm is obtained through image acquisition equipment or the Internet k The original plant leaf disease recognition images of this category are collected or obtained. The original images are saved in JPG format to obtain the original plant leaf disease recognition image set. Where 1≤t≤nmOIm, nmOIm is the number of images in OImg.

[0021] As a preferred technical solution, the plant leaf disease recognition image dataset obtained before preprocessing is specifically:

[0022] Use the nmCIm image category names in neCIm as folder names to create nmCIm image folders; store the images in OImg into image folders of corresponding categories according to image categories, and obtain the plant leaf disease recognition image dataset before preprocessing.

[0023] As a preferred technical solution, the plant leaf disease recognition image dataset is obtained specifically as follows:

[0024] First, in each of the nmCIm image folders, a folder named train for storing training images, a folder named val for storing verification images, and a folder named test for storing test images are created; then, each image folder in the nmCIm image folders is traversed, and the image set OImg under the traversed image folder is used by the random library in Python. k The original images in P train :P val :P test The images are divided into training original images, verification original images and test original images of corresponding image categories, and the training original images, verification original images and test original images are moved to the train folder, val folder and test folder under the image folder of the corresponding category respectively;

[0025] Use the Torchvision library in Python to resize the original images in all train folders, all val folders, and all test folders, and resize the images to 3*H*W pixels, where H is the height of the image and W is the width of the image. Get the preprocessed training images, preprocessed verification images, and preprocessed test images;

[0026] The preprocessed training set PTrDast is obtained, wherein PTrDast consists of all preprocessed training images and corresponding image category names; the preprocessed validation set PVaDast is obtained, wherein PVaDast consists of all preprocessed validation images and corresponding image category names; the preprocessed test set PTeDast is obtained, wherein PTeDast consists of all preprocessed test images and corresponding image category names; PTrDast, PVaDast and PTeDast are combined and operated to obtain the plant leaf disease recognition image data set PFast, wherein PFast=PTrDast∪PVaDast∪PTeDast.

[0027] As a preferred technical solution, the original FasterNet model is constructed and the original FasterNet model is improved to obtain FasterNet Improved Model, specifically:

[0028] Build the original FasterNet model with reference to existing technologies;

[0029] The image embedding module in the original FasterNet model is improved to obtain an improved image embedding module, that is, three convolutional layers with different parameters are added before the image embedding module in the original FasterNet model;

[0030] Referring to the prior art, a SE_Block squeezing and excitation block is constructed and the values ​​of the dim parameter and the reduction parameter of the SE_Block block are set; an SE_Block block constructed and having the parameter values ​​set is added after the FasterNetBlock block of the original FasterNet model to obtain an improved FasterNetBlock block;

[0031] By adding the Sigmoid function and rounding operation after the prediction layer of the original FasterNet model, we get an improved prediction layer, and finally get FasterNet Improved Model.

[0032] As a preferred technical solution, the three convolutional layers with different parameters are conv1, conv2 and conv3; the outputs of conv1, conv2 and conv3 are added and input into the image embedding module of the original FasterNet model to obtain the output of the improved image embedding module, which is expressed as:

[0033] Embed Improved (TInput)=Embed Original(conv1(TInput)+conv2(TInput)+conv3(TInput)),

[0034] Among them, Embed Improved Represents the improved image embedding module, Embed Original Represents the image embedding module of the original FasterNet model.

[0035] As a preferred technical solution, the improved FasterNet Block is expressed as:

[0036] FNB Improved (TFInput) = SE_Block (FNB Original (TFInput)),

[0037] Among them, FNB Improved Block is the improved FasterNet Block, TFInput is the input tensor of the improved FasterNetBlock, SE_Block is the squeeze and excitation block, FNB Original The block is the FasterNet Block in the original FasterNet model.

[0038] As a preferred technical solution, the improved prediction layer is expressed as:

[0039] Prediction Improved (TPInput)=round(Sigmoid(Prediction Original (TPInput))),

[0040] Among them, Prediction Improved Represents the improved prediction layer, TPInput is the input tensor of the improved prediction layer, Prediction Original Represents the prediction layer of the original FasterNet model; round outputs 0 when the value of the input tensor of round is less than 0.5, and round outputs 1 when the value of the input tensor of round is not less than 0.5.

[0041] As a preferred technical solution, the FasterNet Improved The model parameter tensors that the model needs to iteratively train and verify are as follows:

[0042] FasterNet is obtained by combining the parameters of the original FasterNet model that need to be iteratively trained and verified, the parameters of the three convolutional layers with different parameters that need to be iteratively trained and verified, and the parameters of the squeeze and excitation block SE_Block that need to be iteratively trained and verified.Improved The model needs to iteratively train and validate the model parameter tensor ω FI =[ω FO ,ω conv ,ω SK ], where ω FO is the parameter tensor of the original FasterNet model that needs iterative training and verification, ω conv The parameter tensor for the three additional convolutional layers with different parameters that require iterative training and verification, ω SK Parameter tensor required for iterative training and validation for the squeeze and excitation block SE_Block.

[0043] As a preferred technical solution, the FasterNet Improved The model is initialized as follows:

[0044] Referring to the existing technology, FasterNet Improved The model inherits the parameter settings initialization values ​​from the original FasterNet model.

[0045] As a preferred technical solution, the specific process of iterative training and verification is as follows:

[0046] Using Python, convert all preprocessed training images in the preprocessed training set PTrDast into training image tensors of size [nmPTrIm, 3, H, W]; convert all preprocessed verification images in the preprocessed verification set PVaDast into verification image tensors of size [nmPVaIm, 3, H, W]; where nmPTrIm is the number of preprocessed training images in the preprocessed training set PTrDast, nmPVaIm is the number of preprocessed verification images in the preprocessed verification set PVaDast, H is the height of the image, and W is the width of the image; convert the image category name of the preprocessed training image into the true label tensor of the preprocessed training image; convert the image category name of the preprocessed verification image into the true label tensor of the preprocessed verification image; using Python, normalize the training image tensor to obtain the normalized training image tensor, and normalize the verification image tensor to obtain the normalized verification image tensor;

[0047] Setting up FasterNet ImprovedThe optimizer algorithm, learning rate, batch size, and training and validation rounds of the model. Get the number of training batches of the normalized training image tensor and its true label tensor, and the number of validation batches of the normalized validation image tensor and its true label tensor; use minibatch technology to batch the normalized training image tensor, the true label tensor of the preprocessed training image, the normalized validation image tensor, and the true label tensor of the preprocessed validation image;

[0048] In each training and validation round of iterative training and validation, for each training batch: first, the training image tensor of the batch is taken as the input tensor TInput and passed through FasterNet Improved The model calculates the predicted label tensor of the preprocessed training images of the batch, and then uses the binary cross entropy loss value calculation formula to calculate the binary cross entropy loss value of the batch, and then updates the model parameter tensor ω through the back propagation algorithm FI ;

[0049] In each training and validation round of iterative training and validation, for each validation batch: the validation image tensor of the batch is taken as the input tensor TInput and passed through FasterNet Improved The model calculates the predicted label tensor of the preprocessed validation images of the batch and compares it with the true label tensor of the preprocessed validation images of the batch, and calculates the number of correctly predicted images in the batch;

[0050] In each training and validation round of iterative training and validation: first, the number of correctly predicted images of all validation batches in the current round is accumulated, and the accumulated value is divided by the total number of preprocessed validation images as the accuracy of the current round; second, if the accuracy of the current round is the highest accuracy among all the training and validation rounds that have been iterated and are being iterated, the model parameter tensor ω in the current round is saved in the form of a file FI ; Then, the model parameter tensor ω saved in the file when all training and validation rounds are completed FI As the optimal model parameter tensor ω FI .

[0051] As a preferred technical solution, the trained and verified FasterNet Improved The specific process of model testing is as follows:

[0052] The saved optimal model parameter tensor ω FI Loading to FasterNet Improved In the model;

[0053] Use Python to convert all preprocessed test images in the preprocessed test set PTeDast into a test image tensor of size [nmPTeIm,3,H,W], where nmPTeIm is the number of preprocessed test images in the preprocessed test set PTeDast; convert the image category name of the preprocessed test image into the true label tensor of the preprocessed test image; use Python to normalize the test image tensor to obtain the normalized test image tensor;

[0054] The normalized test image tensor is used as the tensor loaded with the optimal model parameter ω FI FasterNet Improved The input of the model; calculating the predicted label tensor of the preprocessed test image; using the real label tensor of the preprocessed test image and the evaluation index to evaluate the method of the present invention.

[0055] Compared with the prior art, the present invention has the following advantages and beneficial effects:

[0056] 1. The FasterNet-based plant leaf disease recognition method proposed in the present invention can use images that have only been labeled with categories to train and verify the model, and can realize the simultaneous recognition of multiple different disease features in a single image, which helps to reduce the workload of making data sets.

[0057] 2. FasterNet constructed by the present invention Improved The model can reduce the feature loss when embedding the original plant leaf disease image, and add extrusion and excitation blocks in the feature extraction process to give the model the ability to adjust the weights of different channels, which helps to improve the plant leaf disease recognition performance.

[0058] 3. The FasterNet-based plant leaf disease recognition method designed in the present invention can realize auxiliary recognition of plant leaf diseases, which helps to reduce the workload of plant leaf disease recognition. BRIEF DESCRIPTION OF THE DRAWINGS

[0059] Figure 1 This is an overall flow chart of sugarcane leaf disease identification based on FasterNet in an embodiment of the present invention.

[0060] Figure 2 FasterNet in the embodiment of the present invention Improved Schematic diagram of the model's structure.

[0061] Figure 3 Embed in the embodiment of the present invention Improved Schematic diagram of the structure of the image embedding module.

[0062] Figure 4 FNB in ​​the embodiment of the present invention Improved Schematic diagram of the block structure.

[0063] Figure 5 In the embodiment of the present invention, Prediction Improved Schematic diagram of the prediction layer structure.

[0064] Figure 6 In the embodiment of the present invention, based on FasterNet Improved Confusion matrix plot of the model for sugarcane leaf disease identification. DETAILED DESCRIPTION

[0065] In order to make the objectives, technical solutions and advantages of the present invention more clear, the embodiments of the present invention are described in further detail below.

[0066] Example 1

[0067] In this example, sugarcane is selected as the target plant to illustrate the method of the present invention in detail. Figure 1 As shown, the specific steps are:

[0068] S1. Determine the classification label type tyLabl for sugarcane leaf disease identification, determine the number of sugarcane leaf disease identification feature categories nmCFt, construct a sugarcane leaf disease identification feature category name set neCFt, and construct a sugarcane leaf disease identification image category name set neCIm based on the sugarcane leaf disease identification feature category name set, obtain the original sugarcane leaf disease identification image of the corresponding category for the category in the sugarcane leaf disease identification image category name set, and obtain the original sugarcane leaf disease identification image set OImg.

[0069] Furthermore, in this embodiment, the steps of obtaining the original sugarcane leaf disease recognition image set OImg are:

[0070] S101. First, determine that the target plant is sugarcane, and the classification label type for sugarcane leaf disease identification is multi-label, that is, tyLabl=1.

[0071] S102. Determine the number of sugarcane leaf disease identification feature categories nmCFt=4 and the sugarcane leaf disease identification feature category name set neCFt=neHCFt∪neDCFt={Healthy,BS,RS,RR}; wherein neHCFt={neCFt1} is the health feature category name set, neCFt1=Healthy is the health feature name, neDCFt={neCFt2,neCFt3,neCFt4} is the disease feature category name set, neCFt2=BS is the sugarcane brown streak disease feature name, neCFt3=RS is the sugarcane ring spot disease feature name, and neCFt4=RR is the sugarcane red rot disease feature name.

[0072] S103, the number of sugarcane leaf disease recognition image categories is nmCIm=2 (4-1) =8, then the sugarcane leaf disease recognition image category name set is: neCIm={neCIm k |1≤k≤8}={Healthy,BS,RS,RR,BS_RS,BS_RR,RS_RR,BS_RS_RR}, where the underscore “_” represents that a single image simultaneously contains features of feature categories corresponding to two or more feature names connected by _.

[0073] S104. Select smartphones iPhone SE, iPhone 13 and iPhone 14Pro, and digital camera Canon EOS as image acquisition devices, and collect 608 Healthy, 666 BS, 750 RS, 716 RR, 738 BS_RS, 560 BS_RR, 696 RS_RR and 700 BS_RS_RR original sugarcane leaf disease recognition images, and convert the collected images into The original sugarcane leaf disease recognition images with different resolutions were saved in JPG format to obtain the original sugarcane leaf disease recognition image set.

[0074] S2, using the eight image category names in neCIm as folder names to create eight image folders; storing the images in OImg obtained into image folders of corresponding categories according to image categories, that is, k The images in the image folder are stored in neCIm k In the above figure, we obtain the sugarcane leaf disease recognition image dataset before preprocessing.

[0075] S3. Obtaining a sugarcane leaf disease recognition image dataset, the specific steps are as follows:

[0076] S301, first, in each of the 8 image folders in step S2, a folder named train for storing training images, a folder named val for storing verification images, and a folder named test for storing test images are created; then, each of the 8 image folders in step S2 is traversed, and the image set OImg under the traversed image folder is used by the random library in Python. k The original images in P train :P val :P test =6:2:2 ratio divided into nmTrIm corresponding to the image category kThe original training image TrImg k 、nmVaIm k Zhang verification original image VaImg k and nmTeIm k The original test image TeImg k ,Right now All make OImg k =TrImg k ∪VaImg k ∪TeImg k , where nmTrIm k =|TrImg k |=nmOIm k *(3 / 5),nmVaIm k =|VaImg k |=nmOIm k *(1 / 5),nmTeIm k =|TeImg k |=nmOIm k *(1 / 5). Then, the total number of original training images is: Verify that the total number of original images is: The total number of original test images is: Then train the original image TrImg k , verify the original image VaImg k And the test original image TeImg k Move to the folder neCIm respectively k In the train folder, val folder and test folder under.

[0077] S302, use the Torchvision library in Python to resize the 5434 original images in all train folders, all val folders, and all test folders, and resize the images to 3*H*W pixel size, where H=448, W=448; obtain the preprocessed training images Preprocessed validation image And the preprocessed test image

[0078] S303, obtain the preprocessed training set PTrDast, where PTrDast={(PTrImg1,neCIm1),…,(PTrImg nmPTrIm ,neCIm8)}, nmPTrIm=3264 is the number of images contained in PTrDast; get the preprocessed validation set PVaDast, where PVaDast={(PVaImg1,neCIm1),…,(PVaImgnmPVaIm ,neCIm8)}, nmPVaIm=1085 is the number of images contained in PVaDast; get the preprocessed test set PTeDast, where PTeDast={(PTeImg1,neCIm1),…,(PTeImg nmPTeIm ,neCIm8)}, nmPTeIm=1085 is the number of images contained in PTeDast. PTrDast, PVaDast and PTeDast are combined and operated to obtain the sugarcane leaf disease recognition image dataset PDast, where PFast=PTrDast∪PVaDast∪PTeDast, nmPIm=nmPTrIm+nmPVaIm+nmPTeIm=3264+1085+1085=5434 is the number of images contained in PDast.

[0079] S4. Build the original FasterNet model FasterNet Original And FasterNet Original Improvements were made to obtain FasterNet Improved Model, represented by: TPLb = FasterNet Improved (TInput,ω FI ), where TPLb is FasterNet Improved The model's predicted label tensor, TInput is the input tensor, ω FI is the model parameter tensor. Figure 2 As shown, the specific steps are:

[0080] S401. Construct the original FasterNet model FasterNet according to the method in the paper by Chen et al. (Chen J, Kao SH, He H, et al. Run, don't walk: Chasing higher FLOPS for faster neural networks [C] / / Proceedings of the 2023 IEEE / CVF Conference on Computer Vision and Pattern Recognition. 2023: 12021-12031.) Original .

[0081] S402, FasterNet Original Image embedding module in Embed Original Improved image embedding module Embed Improved .like Figure 3 As shown, the specific steps are:

[0082] First, in FasterNet Original Image embedding module in Embed Original First, add three convolutional layers conv1, conv2, and conv3 with different parameters. Then, add the outputs of conv1, conv2, and conv3 and input them into FasterNet. Original Image embedding module Embed Original , get the improved image embedding module Embed Improved The output is expressed as:

[0083] Embed Improved (TInput)=Embed Original (conv1(TInput)+conv2(TInput)+conv3(TInput)),

[0084] Among them, the parameters of conv1, conv2 and conv3 include the convolution kernel size kernel, dilation rate dilation, stride, padding and input and output channel numbers channel, and the parameters of conv1 are: kernel1=5, dilation1=1, stride1=1, padding1=2, channel1=3; the parameters of conv2 are: kernel2=3, dilation2=2, stride2=1, padding2=2, channel2=3; the parameters of conv3 are: kernel3=3, dilation3=1, stride3=1, padding3=1, channel3=3.

[0085] S403, such as Figure 4 As shown, first, refer to the paper of Hu et al. (Hu J, Shen L, Sun G. Squeeze-and-excitation networks [C] / / Proceedings of the 31st Meeting of the IEEE / CVFConference on Computer Vision and Pattern Recognition. 2018: 7132-7141.) to build a SE_Block squeeze and excitation block, and set the value of the dim parameter of the SE_Block block to the FNB connected to the SE_Block block. Original The number of channels of the output tensor of the block, and the value of the reduction parameter of the SE_Block block is set to 8. Next, in FNBOriginal Add a constructed SE_Block block with parameter values ​​set after the block to get FNB Improved Block, represented as:

[0086] FNB Improved (TFInput) = SE_Block (FNB Original (TFInput)),

[0087] Among them, FNB Improved The block is the improved FasterNet Block, and TFInput is FNB Improved The input tensor of the block, SE_Block is the squeeze and excitation block, FNB Original Block for FasterNet Original FasterNet Block in .

[0088] S404, such as Figure 5 As shown, in FasterNet Original Prediction layer Original Then add the Sigmoid function and rounding operation to get the improved prediction layer Prediction Improved , expressed as:

[0089] Prediction Improved (TPInput)=round(Sigmoid(Prediction Original (TPInput))),

[0090] Among them, TPInput is Prediction Improved Input tensor, round(TRInput) = {0|TRInput < 0.5; 1|TRInput ≥ 0.5}, TRInput = Sigmoid(Prediction Original (TPInput)) is the input tensor of round.

[0091] Prediction Improved The output of FasterNet Improved The output of the model, i.e. TPLb = Prediction Improved (TPInput).

[0092] S5. Get FasterNet Improved The model requires model parameter tensors for iterative training and validation. Improved The model is initialized. The specific steps are:

[0093] First, combine FasterNet Original The parameters that the model needs to be iteratively trained and verified, the parameters that the three convolutional layers with different parameters need to be iteratively trained and verified, and the parameters that the SE_Block block needs to be iteratively trained and verified to obtain FasterNet Improved The model needs to iteratively train and validate the model parameter tensor ω FI =[ω FO ,ω conv ,ω SK Then, referring to the paper by Chen et al. (Chen J, Kao SH, He H, et al. Run, don't walk: Chasing higher FLOPS for faster neural networks [C] / / Proceedings of the 2023 IEEE / CVFConference on Computer Vision and Pattern Recognition. 2023: 12021-12031.), FasterNet Improved Inherited from FasterNet Original The parameter settings are initialized as follows: embed_dim is 96, feature_dim is 1280, patch_size is 8, patch_stride is 8, drop_path_rate is 0.05, norm_layer is BN, act_layer is RELU, n_div is 4, and num_classes is 4.

[0094] S6. Use the preprocessed training images PTrImg in all training folders and the preprocessed verification images PVaImg in all verification folders to train FasterNet Improved The model is iteratively trained and verified to obtain the optimal model parameter tensor ω FI And save, the specific process of iterative training and verification is:

[0095] S601, using Python, convert all preprocessed training images PTrImg in the preprocessed training set PTrDast obtained in step S303 into training image tensors of size [3264, 3, 448, 448] Convert all preprocessed verification images PVaImg in the preprocessed verification set PVaDast obtained in step S303 into verification image tensors of size [1085, 3, 448, 448] The image category name of the preprocessed training image PTrImg Converted to the true label tensor of the preprocessed training image PTrImg Among them, neCI (PTrImg m ) is the image PTrImg m The parent folder name of the train folder. is a multi-hot label tensor, The size of TRTLb is [3264, 4]; the image category name of the preprocessed verification image PVaImg is converted to the true label tensor of the preprocessed verification image PVaImg using the same conversion method as the true label tensor TRTLb of the preprocessed training image PTrImg Among them TVTLb p is a multi-hot label tensor, the size of TVTLb is [1085, 4]; use the Normalize function in the torchvision library in Python, set the value of the image mean parameter in the Normalize function to mean = [0.485, 0.456, 0.406], and set the value of the image standard deviation parameter in the Normalize function to std = [0.229, 0.224, 0.225]; call the Normalize function to normalize the training image tensor TTrImg to obtain the normalized training image tensor Call the Normalize function to normalize the verification image tensor TVaImg to obtain the normalized verification image tensor

[0096] S602. Set up FasterNet Improved The optimizer algorithm of the model is the adaptive motion estimation algorithm, the learning rate lr = 0.0002, the batch size szbt = 128 and the training verification round epochs = 100. Get the normalized training image tensor And the number of training batches of its true label tensor TRTLb: And the normalized validation image tensor And the number of validation batches of its true label tensor TVTLb: Use minibatch technology to normalize the training image tensor The true label tensor TRTLb of the preprocessed training image and the normalized validation image tensor And the true label tensor TVTLb of the preprocessed verification image is batched: ,

[0097] in Represents the training image tensor of the sth batch, TRTLb s represents the true label tensor of the preprocessed training images of the sth batch, Represents the verification image tensor of the uth batch, TVTLb u A tensor representing the true labels of the preprocessed validation images of batch u.

[0098] S603, in each training and verification round of iterative training and verification For each training batch ①First, the batch of training image tensors As input tensor TInput and through TRPLb s =TPLb=FasterNet Improved (TInput,ω FI ) Calculate the predicted label tensor TRPLb of the batch of preprocessed training images s ② Secondly, the binary cross entropy loss value calculation formula is used Calculate the binary cross entropy loss value BCELoss for this batch s , where nim s is the number of images in the batch, TRTLb s The true label tensor of the ε+1th image in , TRPLb s The predicted label tensor for the ε+1th image in , For tensors The value of the βth element in , For tensors ③Then, according to the calculated BCELoss s , update the model parameter tensor ω through the back-propagation algorithm FI ;

[0099] S604, in each training and verification round of iterative training and verification For each validation batch The validation image tensor of the batch As input tensor TInput and through TVPLb u =TPLb=FasterNet Improved (TInput,ω FI ) Calculate the predicted label tensor TVPLb of the preprocessed validation images of this batch u and the true label tensor TVTLb of the batch of preprocessed validation imagesu Compare and calculate the number of correctly predicted images in the batch. Furthermore, an image is considered correctly predicted only when its predicted label tensor is exactly the same as its true label tensor.

[0100] S605, in each training and verification round of iterative training and verification In: First, the number of correctly predicted images of all 9 validation batches in the current x-th training validation round is accumulated, and the accumulated value is divided by the total number of preprocessed validation images as the accuracy of the current x-th training validation round. Secondly, if the accuracy of the current x-th training validation round is the highest accuracy among all the training validation rounds that have been iterated and are being iterated, the tensor ω in the current x-th training validation round is saved in the form of a file FI , that is, if the model.pt file does not exist, create the model.pt file and convert the tensor ω FI Save to this file. If the model.pt file already exists and the accuracy of the current x-th training and verification round is higher than the accuracy recorded in the model.pt file, then the tensor ω in the current x-th training and verification round is saved. FI Save it to the model.pt file in an overwritten way. Then, the tensor ω saved in the model.pt file when all 100 training and validation rounds are completed FI As the optimal model parameter tensor ω FI .

[0101] S7. FasterNet after training and verification Improved The model is tested, the specific process is:

[0102] S701, the optimal model parameter tensor ω saved in the model.pt file FI Loaded into FasterNet with the initialization value set in step S5 Improved In the model.

[0103] S702, using Python, convert all preprocessed test images PTeImg in the preprocessed test set PTeDast obtained in step S303 into a test image tensor of size [1085, 3, 448, 448] The image category name of the preprocessed test image PTeImg is converted into the real label tensor of the preprocessed test image PTeImg using the same conversion method as the real label tensor TRTLb of the preprocessed training image PTrImg in step S601 Among them, TETLb qis a multi-hot label tensor, and the size of TETLb is [1085, 4]. Use the Normalize function in the torchvision library in Python to set the parameter mean and the parameter std according to the value of the image mean parameter in step S601. Call the Normalize function to normalize the test image tensor TTeImg to obtain the normalized test image tensor

[0104] S703: normalize the test image tensor As loaded with the optimal model parameter tensor ω FI FasterNet Improved The input of the model. Then, through TPLb = FasterNet Improved (TInput,ω FI ) calculates the predicted label tensor TEPLb of the preprocessed test image PTeImg. Then, the true label tensor TETLb of the preprocessed test image PTeImg obtained in step S702 is used, and accuracy, precision, recall rate, F1 value, and model size are used as evaluation indicators to evaluate the method of the present invention. The evaluation results are shown in Table 1 and Figure 6 As shown, Figure 6 Predict in the figure indicates the predicted image category name, GroundTruth indicates the real image category name, the value before the “ / ” in the second line of each unit indicates the number of images predicted to be the image category name corresponding to the vertical coordinate of the unit, the value after the “ / ” in the second line of each unit indicates the number of images whose real image category name is the image category name corresponding to the horizontal coordinate of the unit, and the value in the first line of each unit is the value obtained by dividing the second line and retaining it to four decimal places and converting it to a percentage. It can be seen that based on FasterNet Improved The overall accuracy of sugarcane leaf disease recognition is higher than 80%, and the accuracy of recognizing the combined disease type image categories BS_RS, BS_RR, RS_RR, and BS_RS_RR is higher than 70%, and the model size is small, only 57.6MB. It can be seen that the plant leaf disease recognition method based on FasterNet proposed in the present invention has a good recognition effect when applied to sugarcane leaf disease recognition.

[0105] Table 1 Based on FasterNet Improved Evaluation of sugarcane leaf disease identification effect

[0106] Evaluation Metrics Evaluation index value Accuracy 84.88% Accuracy 88.98% Recall 84.92% F1 value 78.77% Model size 57.6MB

Claims

1. A plant leaf disease identification method based on FasterNet, characterized in that: The steps include: Determine the classification label type for leaf disease identification of the target plant, construct a plant leaf disease identification feature category name set, and construct a plant leaf disease identification image category name set based on the plant leaf disease identification feature category name set, obtain the original plant leaf disease identification image of the corresponding category for the category in the plant leaf disease identification image category name set, and obtain the original plant leaf disease identification image set; Based on the category names in the plant leaf disease recognition image category name set, an image folder of a corresponding category is established; the images in the obtained original plant leaf disease recognition image set are stored in the image folder of the corresponding category according to the image category, so as to obtain a plant leaf disease recognition image dataset before preprocessing; In each category of image folder, a training folder, a verification folder, and a test folder are simultaneously established; Python is used to traverse the original plant leaf disease recognition images in each category of the image folder in the plant leaf disease recognition image dataset before preprocessing, and the images are divided into training original images, verification original images, and test original images in proportion, and the training original images are stored in the training folder in the image folder of the corresponding category, the verification original images are stored in the verification folder in the image folder of the corresponding category, and the test original images are stored in the test folder in the image folder of the corresponding category; Preprocess the images in all training folders, verification folders and test folders to obtain preprocessed training images, preprocessed verification images and preprocessed test images, and obtain a plant leaf disease recognition image dataset; Construct the original FasterNet model and improve the original FasterNet model to get FasterNet Improved Model, represented by: TPLb = FasterNet Improved (TInput,ω FI ), where TPLb is FasterNet Improved The model's predicted label tensor, TInput is the input tensor, ω FI is the model parameter tensor; Get FasterNet Improved The model requires model parameter tensors for iterative training and validation; for FasterNet Improved Initialize the model; Use the preprocessed training images in all training folders and the preprocessed validation images in all validation folders to train FasterNet Improved The model is iteratively trained and verified to obtain the optimal model parameter tensor ω FI and save; For the trained and verified FasterNet Improved The model is tested.

2. A plant leaf disease identification method based on FasterNet according to claim 1, characterized in that: The original plant leaf disease recognition image set is obtained, specifically: Determine the target plant leaf disease identification classification label type tyLabl∈{0,1} according to the requirements. When tyLabl=0, it means that each image in the original plant leaf disease identification image set will be labeled with a single label. When tyLabl=1, it means that each image in the original plant leaf disease identification image set will be labeled with multiple labels. Determine the number of plant leaf disease recognition feature categories nmCFt and the set of plant leaf disease recognition feature category names neCFt = neHCFt ∪ neDCFt; where neHCFt = {neCFt1} is the set of healthy feature category names, and neDCFt = {neCFt i | i ∈ {2, …, nmCFt}} is the set of disease feature category names; let neSDCFt = {neCFt j1 , …, neCFt j|neSDCFt| | 2 ≤ j1 < … < j|neSDCFt| ≤ nmCFt} be the non-empty and non-singleton ordered subset of neDCFt, where neCFt j1 is the j1-th element in neCFt, and |neSDCFt| is the length of neSDCFt; When tyLabl=0, the number of plant leaf disease recognition image categories is nmCIm=nmCFt; when tyLabl=1, the number of plant leaf disease recognition image categories is nmCIm=2 (nmCFt-1) , then the plant leaf disease recognition image category name set is: neCIm = {neCIm k |1≤k≤nmCIm}=neCFt∪ in is an empty set, ∨ is a logical OR, ∧ is a logical AND; Identify the image category name neCIm for each plant leaf disease k ∈neCIm, where 1≤k≤nmCIm, nmOIm is obtained through image acquisition equipment or the Internet k The original plant leaf disease recognition images of this category are collected or obtained. The original images are saved in JPG format to obtain the original plant leaf disease recognition image set. Where 1≤t≤nmOIm, nmOIm is the number of images in OImg.

3. A plant leaf disease identification method based on FasterNet according to claim 1, characterized in that: The plant leaf disease recognition image dataset is obtained, specifically: First, in each of the nmCIm image folders, a folder named train for storing training images, a folder named val for storing verification images, and a folder named test for storing test images are created; then, each image folder in the nmCIm image folders is traversed, and the image set OImg under the traversed image folder is used by the random library in Python. k The original images in P train :P val :P test The images are divided into training original images, verification original images and test original images of corresponding image categories, and the training original images, verification original images and test original images are moved to the train folder, val folder and test folder under the image folder of the corresponding category respectively; Use the Torchvision library in Python to resize the original images in all train folders, all val folders, and all test folders, and resize the images to 3*H*W pixels, where H is the height of the image and W is the width of the image. Get the preprocessed training images, preprocessed verification images, and preprocessed test images; The preprocessed training set PTrDast is obtained, wherein PTrDast consists of all preprocessed training images and corresponding image category names; the preprocessed validation set PVaDast is obtained, wherein PVaDast consists of all preprocessed validation images and corresponding image category names; the preprocessed test set PTeDast is obtained, wherein PTeDast consists of all preprocessed test images and corresponding image category names; PTrDast, PVaDast and PTeDast are combined and operated to obtain the plant leaf disease recognition image data set PFast, wherein PFast=PTrDast∪PVaDast∪PTeDast.

4. The method for identifying plant leaf diseases based on FasterNet according to claim 1, characterized in that: The original FasterNet model is constructed and improved to obtain FasterNet Improved Model, specifically: Build the original FasterNet model with reference to existing technologies; The image embedding module in the original FasterNet model is improved to obtain an improved image embedding module, that is, three convolutional layers with different parameters are added before the image embedding module in the original FasterNet model; Referring to the prior art, a SE_Block squeezing and excitation block is constructed and the values ​​of the dim parameter and the reduction parameter of the SE_Block block are set; an SE_Block block constructed and having the parameter values ​​set is added after the FasterNetBlock block of the original FasterNet model to obtain an improved FasterNetBlock block; By adding the Sigmoid function and rounding operation after the prediction layer of the original FasterNet model, we get an improved prediction layer, and finally get FasterNet Improved Model.

5. A plant leaf disease identification method based on FasterNet according to claim 4, characterized in that: The three convolutional layers with different parameters are conv1, conv2 and conv3; the outputs of conv1, conv2 and conv3 are added and input into the image embedding module of the original FasterNet model to obtain the output of the improved image embedding module, which is expressed as: Embed Improved (TInput)=Embed Original (conv1(TInput)+conv2(TInput)+conv3(TInput)), Among them, Embed Improved Represents the improved image embedding module, Embed Original Represents the image embedding module of the original FasterNet model.

6. A method for identifying plant leaf diseases based on FasterNet according to claim 4, characterized in that: The improved FasterNet Block is expressed as: FNB Improved (TFInput)=SE_Block(FNB Original (TFInput)), Among them, FNB Improved Block is the improved FasterNet Block, TFInput is the input tensor of the improved FasterNet Block, SE_Block is the squeeze and excitation block, FNB Original The block is the FasterNetBlock block in the original FasterNet model.

7. A method for identifying plant leaf diseases based on FasterNet according to claim 4, characterized in that: The improved prediction layer is expressed as: Prediction Improved (TPInput)=round(Sigmoid(Prediction Original (TPInput))), Among them, Prediction Improved Represents the improved prediction layer, TPInput is the input tensor of the improved prediction layer, Prediction Original Represents the prediction layer of the original FasterNet model; round outputs 0 when the value of the input tensor of round is less than 0.5, and round outputs 1 when the value of the input tensor of round is not less than 0.

5.

8. The method for identifying plant leaf diseases based on FasterNet according to claim 1, characterized in that: The FasterNet Improved The model parameter tensors that the model needs to iteratively train and verify are as follows: FasterNet is obtained by combining the parameters of the original FasterNet model that need to be iteratively trained and verified, the parameters of the three convolutional layers with different parameters that need to be iteratively trained and verified, and the parameters of the squeeze and excitation block SE_Block that need to be iteratively trained and verified. Improved The model needs to iteratively train and validate the model parameter tensor ω FI =[ω FO ,ω conv ,ω SK ], where ω FO is the parameter tensor of the original FasterNet model that needs iterative training and verification, ω conv The parameter tensor for the three additional convolutional layers with different parameters that require iterative training and verification, ω SK Parameter tensor required for iterative training and validation for the squeeze and excitation block SE_Block.

9. The method for identifying plant leaf diseases based on FasterNet according to claim 1, characterized in that: The specific process of iterative training and verification is as follows: Using Python, convert all preprocessed training images in the preprocessed training set PTrDast into training image tensors of size [nmPTrIm, 3, H, W]; convert all preprocessed verification images in the preprocessed verification set PVaDast into verification image tensors of size [nmPVaIm, 3, H, W]; where nmPTrIm is the number of preprocessed training images in the preprocessed training set PTrDast, nmPVaIm is the number of preprocessed verification images in the preprocessed verification set PVaDast, H is the height of the image, and W is the width of the image; convert the image category name of the preprocessed training image into the true label tensor of the preprocessed training image; convert the image category name of the preprocessed verification image into the true label tensor of the preprocessed verification image; using Python, normalize the training image tensor to obtain the normalized training image tensor, and normalize the verification image tensor to obtain the normalized verification image tensor; Setting up FasterNet Improved The optimizer algorithm, learning rate, batch size, and training and validation rounds of the model. Get the number of training batches of the normalized training image tensor and its true label tensor, and the number of validation batches of the normalized validation image tensor and its true label tensor; use minibatch technology to batch the normalized training image tensor, the true label tensor of the preprocessed training image, the normalized validation image tensor, and the true label tensor of the preprocessed validation image; In each training and validation round of iterative training and validation, for each training batch: first, the training image tensor of the batch is taken as the input tensor TInput and passed through FasterNet Improved The model calculates the predicted label tensor of the preprocessed training images of the batch, and then uses the binary cross entropy loss value calculation formula to calculate the binary cross entropy loss value of the batch, and then updates the model parameter tensor ω through the back propagation algorithm FI ; In each training and validation round of iterative training and validation, for each validation batch: the validation image tensor of the batch is taken as the input tensor TInput and passed through FasterNet Improved The model calculates the predicted label tensor of the preprocessed validation images of the batch and compares it with the true label tensor of the preprocessed validation images of the batch, and calculates the number of correctly predicted images in the batch; In each training and validation round of iterative training and validation: first, the number of correctly predicted images of all validation batches in the current round is accumulated, and the accumulated value is divided by the total number of preprocessed validation images as the accuracy of the current round; second, if the accuracy of the current round is the highest accuracy among all the training and validation rounds that have been iterated and are being iterated, the model parameter tensor ω in the current round is saved in the form of a file FI ; Then, the model parameter tensor ω saved in the file when all training and validation rounds are completed FI As the optimal model parameter tensor ω FI .

10. The method for identifying plant leaf diseases based on FasterNet according to claim 1, characterized in that: The FasterNet after training and verification Improved The specific process of model testing is as follows: The saved optimal model parameter tensor ω FI Loading to FasterNet Improved In the model; Use Python to convert all preprocessed test images in the preprocessed test set PTeDast into test image tensors of size [nmPTeIm,3,H,W], where nmPTeIm is the number of preprocessed test images in the preprocessed test set PTeDast; convert the image category name of the preprocessed test image into the true label tensor of the preprocessed test image; Use Python to normalize the test image tensor to obtain a normalized test image tensor; The normalized test image tensor is used as the tensor loaded with the optimal model parameter ω FI FasterNet Improved The input of the model; calculating the predicted label tensor of the preprocessed test image; using the real label tensor of the preprocessed test image and the evaluation index to evaluate the method of the present invention.

Citation Information

Patent Citations

  • Litchi fruit identification method based on deep learning

    CN117058669A

  • Pest recognition method and device based on improved lightweight network, and storage medium

    CN117994651A