Lightweight identification method for crop diseases

By using the improved YOLOv8 classification model, combined with the AKConv structure and Shuffle Attention mechanism, the problem of difficulty in identifying similar diseases in corn leaves is solved, and high-accurate disease classification and period judgment are achieved.

CN119478688APending Publication Date: 2025-02-18HENAN AGRICULTURAL UNIVERSITY
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411561059.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-04
Publication Date
2025-02-18

AI Technical Summary

Technical Problem

Due to the wide variety of corn leaf diseases and the similar characteristics of different periods, it is more difficult to identify specific types of diseases, and it is difficult to accurately identify similar corn leaf diseases in the prior art.

Method used

Using the YOLOv8 classification model and its improved model, by dividing spots and rust in corn leaves into three periods: initial, mid-term and late period, and using AKConv structure to replace the standard convolutional structure, combining the calculation of sample weights and adding lightweight attention mechanisms Shuffle Attention, improves the recognition accuracy of the model.

Benefits of technology

It effectively improves the classification accuracy of similar diseases in corn leaves, can better identify the categories and corresponding periods of the disease, and assists in judging the occurrence of the disease in a timely manner and takes reasonable response measures.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119478688A_ABST
    Figure CN119478688A_ABST
Patent Text Reader

Abstract

The invention provides a light-weight identification method for crop diseases, and provides a YOLOv8 classification model based on fusion of a light-weight convolution structure AKConv and a light-weight attention mechanism SA in allusion to similar diseases of two types of diseases including leaf blotch (northern leaf blight, southern leaf blight and gray leaf blight) and rust disease (southern rust disease and common rust disease) in the initial period, the middle period and the last period. According to the research, an optimal classification model for the similar diseases of the corn leaf blotch is YOLOv8s-cls-AKConv, the classification accuracy is 93.800%, an optimal classification model for the similar diseases of the corn leaf rust is YOLOv8s-cls-AKConv-Balancecd-SA, the classification accuracy is 95.000%, through classification testing on real field disease images, the classification accuracy is 93.800%, and the classification accuracy is 95.000%. The YOLOv8s-cls-AKConv improved model and the YOLOv8s-cls-AKConv-Balancecd-SA improved model provided by the research can be used for well completing the classification task of the similar diseases of the corn leaf blotch and the rust disease, reference is provided for subsequent research, and the method has important significance in prevention and control of the diseases of the corn.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of crop disease recognition, and in particular to a classification and recognition method for similar diseases on corn leaves. Background Art

[0002] Common corn leaf diseases include large leaf spot, small leaf spot, Curvularia leaf spot, gray leaf spot and many other diseases. However, the characteristics of diseases in different periods and categories are very similar. For example, large leaf spot appears as water-soaked blue-gray spots in the early stage, and then the spots expand, with dark brown edges and light brown or gray spindle-shaped spots in the center. When the disease is serious, the spots are connected to each other to form large dead spots. Small leaf spot and brown leaf spot are also water-soaked in the early stage, with very similar characteristics. Later, the spots of small leaf spot become oval or round, and the color deepens to yellow-brown or red. Brown with obvious edges. In severe cases, the spots fuse and become larger. The small spot disease in the middle and late stages is very similar to Curvularia leaf spot. In the early stages of gray spot disease, elliptical spots grow, gray to light brown, with no obvious edges. This is similar to the period when large spot disease has not formed obvious spindle shapes. Subsequently, the edges of the gray spot spots expand into rectangles. In the later stages, the edges of the spots appear brown, with gray in the middle. At this time, the characteristics of gray spot disease are obvious enough, and they will have similar characteristics to the late stages of small spot disease. When gray spot disease is severe, the spots will also fuse into pieces, causing leaf death.

[0003] As for corn leaf rust, due to the high incidence and serious disease of southern rust, people often refer to southern rust when they say "rust". But in fact, rust is subdivided into southern rust and common rust, but people do not actually distinguish between the two types of rust in planting. However, the two different types of rust have different disease characteristics at different times: in the early stage of southern rust, herpes-like bulges appear, and then the epidermis breaks and yellow to orange powder is scattered. In the later stage, the lesions are dense and the leaves are covered with spore piles. Common rust will start from scattered or clustered yellowish dots on the leaves, and then the lesions will bulge, the surrounding epidermis will turn up, and rust-colored powder will be scattered. In the later stage, the lesions will produce black-brown powder and both sides of the leaves will grow, which is relatively unrestricted by the separation of veins. During the growth of the two, the leaves will have powdery characteristics. If the two are distinguished based on whether the double-sided powdery characteristics appear or the density of the lesions, it is largely necessary to go to the middle and late stages of the disease, but at this time the disease is already extremely serious. When taking prevention and control measures, especially chemical prevention and control measures, it is easy to cause excessive use of drugs and pollute the environment.

[0004] It can be seen that due to the presence of a large number of similar lesions in corn leaves and the complex field environment, there are many types of corn leaf diseases with similar manifestations in different periods. As the disease occurs over time, the characteristics of the lesions become more and more similar, making it more difficult to specifically identify the type of disease. Therefore, accurate identification of corn diseases, especially similar diseases, is of great significance for the precise prevention and control of diseases.

[0005] Traditional corn leaf disease classification and judgment mainly rely on expert expertise and farmers' long-term labor experience and direct observation. However, due to the wide variety of corn leaf diseases and the similar characteristics of different diseases, direct manual identification of disease categories is prone to errors, and the judgment is somewhat subjective. With the development of machine learning, corn leaf disease classification and identification has gradually combined with classification methods related to machine learning. Classification methods based on machine learning can effectively classify crop diseases with high classification accuracy. However, when classifying crop diseases based on machine learning methods, it is necessary to manually extract features and input them into the classifier training model, which is a complicated process. Therefore, there are still some defects in using machine learning to classify similar corn leaf diseases. Therefore, deep learning has also been continuously applied to the agricultural field. Deep learning breaks the limitations of traditional methods and machine learning methods, and can automatically learn the feature representation of complex images from a large amount of data, process the nonlinear relationship of high-dimensional data, and thus train efficient and accurate models to solve complex image classification problems. However, most of the above research on the identification of corn leaf diseases is based on public data sets, which mainly target several common corn leaf diseases such as large leaf spot, gray leaf spot, and rust. There are relatively few studies on the classification between diseases with different similarities and the classification of similar diseases in different periods.

[0006] In view of the above, this application conducts research on the classification and identification of two major types of diseases, corn spot (large spot, small spot, gray spot) and rust (southern rust, common rust), and provides a lightweight identification method for crop diseases to solve the above problems. Summary of the invention

[0007] In view of the above situation, in order to overcome the defects of the prior art, the present invention provides a lightweight identification method for crop diseases. The present invention takes two similar diseases of corn leaf spot (large spot, small spot, gray spot) and rust (southern rust, common rust) as the research objects, and divides each type of disease into three periods: early, middle and late. The YOLOv8 classification model and its improved model are used to classify and identify similar diseases of corn leaves, aiming to improve the classification accuracy of similar diseases.

[0008] A lightweight identification method for crop diseases, characterized in that it comprises the following steps:

[0009] S1: The acquired corn spot and rust image datasets are expanded using offline data enhancement combined with randaugment online data enhancement;

[0010] S2: Use a convolution structure AKConv with a convolution kernel of arbitrary shape and arbitrary number of parameters to replace the standard Conv structure in the YOLOv8 classification model;

[0011] S3: By using the compute_class_weight function to calculate the weights of various unbalanced samples of Rust, a certain weight is given to the loss function of different categories of Rust, so that it pays more attention to the minority sample class;

[0012] S4: Finally, in order to improve the accuracy of model recognition, a lightweight attention mechanism Shuffle Attention, referred to as SA, is added to the end position of the last variable kernel convolution on the basis of the YOLOv8 classification model based on the variable kernel convolution structure. It combines spatial and channel information to improve the model classification accuracy while keeping the model as lightweight as possible.

[0013] The above technical solution has the following beneficial effects:

[0014] (1) This study verified the proposed lightweight identification method for crop diseases, which can better classify the categories and corresponding periods of similar diseases. Therefore, it can be applied to the classification of similar diseases in different periods of corn leaves, identify the category of the disease and assist in determining the period of the disease, which helps to take reasonable and accurate countermeasures in time for the occurrence of existing diseases.

[0015] (2) The standard convolution structure in YOLOv8s-cls was replaced with the AKConv structure, and the classification accuracy under unit parameter was further evaluated. Finally, the classification accuracy of the model under unit parameter for spot and rust was improved;

[0016] (2) The cost-sensitive learning method is applied to the rust imbalance sample category, and the weighted loss function is used to increase the model's attention to the minority sample category. The overall parameter volume of the model does not change before and after weighting, but the accuracy is improved, and the classification accuracy per unit parameter volume is increased;

[0017] (3) Based on the YOLOv8s-cls-AKConv model, for rust, a model based on weighted loss function and AKConv is used, and the ShuffleAttention mechanism is added for classification. The final accuracy is improved, and the classification accuracy per unit parameter is improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] Figure 1 It is the overall technical roadmap for the specific implementation of the present invention;

[0019] Figure 2 It is a schematic diagram of the proportion of different disease levels of similar lesions of different types on corn leaves to the leaf area in a specific embodiment of the present invention;

[0020] Figure 3 Schematic diagram of the enhancement effect of different online data enhancement methods in a specific implementation manner of the present invention;

[0021] Figure 4 This is a complete diagram of the YOLO model structure;

[0022] Figure 5 This is a comparison diagram between C2f module and C3 module;

[0023] Figure 6 This is a schematic diagram of the YOLOv8 classification model structure;

[0024] Figure 7 This is a schematic diagram of the initial sampling shape of the convolution kernel and the corresponding convolution kernel size;

[0025] Figure 8 Schematic diagram of AKConv convolution structure and process;

[0026] Fig. 9 Schematic diagram of possible sampling shapes of the convolution kernel that can be adjusted when kernel_size=2 according to the present invention;

[0027] Fig.10 This is a schematic diagram of the Conv structure of replacing YOLOv8s-cls with AKConv of the present invention;

[0028] Fig.11 Schematic diagram of the SA attention mechanism principle of the present invention;

[0029] Fig.12 This is a schematic diagram of the change in accuracy and loss before and after replacing the convolution structure with two types of similar lesions in a specific embodiment of the present invention;

[0030] Fig.13 This is a schematic diagram of the accuracy and loss changes of the YOLOv8s-cls-AKConv model before and after weighting in a specific implementation manner of the present invention;

[0031] Fig.14 This is a schematic diagram of the accuracy and loss changes of the model before and after the SA attention mechanism is inserted in a specific implementation manner of the present invention;

[0032] Fig.15 Add a location diagram for the SA attention mechanism in the specific implementation of the present invention;

[0033] Fig.16 This is a schematic diagram of the classification prediction of spot and rust by the optimal improved model in a specific embodiment of the present invention;

[0034] Fig.17 This is a schematic diagram of the optimal model predicting similar lesion categories in a specific embodiment of the present invention. DETAILED DESCRIPTION

[0035] The aforementioned and other technical contents, features and effects of the present invention will be clearly presented in the following detailed description of the embodiments with reference to the drawings of the present application. The contents mentioned in the following embodiments are all based on the drawings of the specification as reference.

[0036] 1. Research content and technical route

[0037] 1.1 Research content

[0038] This paper takes two similar diseases of corn leaf spot (large leaf spot, small leaf spot, gray leaf spot) and rust (southern rust, common rust) as the research objects, and divides each disease into three stages: early, middle and late stages. The YOLOv8 classification model and its improved model are used to classify and identify similar diseases of corn leaves, aiming to improve the classification accuracy of similar diseases.

[0039] The specific research contents are as follows:

[0040] (1) Obtain data and preprocess data, collect public corn spot and rust data from different websites, filter out inappropriate images, find professional pest and disease websites and authoritative disease classification standards, and divide each type of disease into different periods;

[0041] (2) Construct a data set and use offline data enhancement methods such as rotation, noise addition, and flipping to expand the data set so that the number of images at different disease stages is relatively balanced. Compare the effects of offline data enhancement before and after data enhancement and online and offline data enhancement methods on disease classification, and select the optimal enhancement method to expand the data set.

[0042] (3) Model training: Based on the YOLOv8 classification model and the YOLOv8 model with different improvements, classification experiments were conducted on spot disease and rust respectively, and the classification results were compared. Ablation experiments were conducted to obtain the models with the best classification effects for the two diseases under different improvements.

[0043] (4) Model comparison and classification: use the above optimal model to compare with other models to prove the effect of the above optimal improvement experiment, and use the optimal improved model to evaluate the classification effect of each type of disease;

[0044] (5) Model testing and analysis: Use the above optimal model to perform classification and recognition on the test set, and observe and analyze the classification effect.

[0045] 1.2 Technical route

[0046] The present invention mainly uses the YOLOv8 classification model and its improved model to classify similar diseases of corn leaves, aiming to improve the classification accuracy of the model in two similar diseases, spot disease and rust disease, and to lighten the model structure. The research technical route of the present invention is as follows: Figure 1 shown.

[0047] 2. YOLO Model

[0048] The present invention is mainly aimed at the classification of similar diseases. Compared with YOLO target detection, although target detection can obtain the object category and specific location in the image, and has more information, the target detection data set needs to include the location annotation information file of the target object in the image, and the overall target detection model parameter volume is larger than the classification model, and the recognition accuracy is not as high as the classification model. The similar disease data sets used in this study come from various sources, and the main task of this study is to classify similar diseases of corn leaves, without locating specific disease location information. Therefore, the present invention chooses to use the YOLOv8 classification model to conduct classification research on similar diseases of corn leaves.

[0049] 3. Dataset Construction

[0050] 3.1 Data Source

[0051] The experimental data set selects large spot disease, small spot disease, gray spot disease, southern rust, and common rust from corn leaf diseases. There are three different sources of experimental data, namely: Kaggle public data set, PlantPAD data set, and data set of Hefei Institute of Intelligent Machinery, Chinese Academy of Sciences. Data characteristics are also different from different data sources: the image size of Kaggle public data set is mostly 256×256, and most of the leaves are local images, with very few whole leaf images. The background of large spot disease and gray spot disease images is mostly white background, and the background of rust disease is mostly black background. There is only a small amount of actual field background for spot disease and rust disease; the image size in the PlantPAD data set is not uniform, and most of the leaves are local images, with a small number of whole leaf images. The background of large spot disease, gray spot disease, and rust disease is the same as Kaggle, all of which are a small amount of actual field background; this experiment mainly uses small spot disease and southern rust disease in the corn data set of Hefei Institute of Intelligent Machinery, Chinese Academy of Sciences. Disease and common rust images. The characteristic of this dataset is that there are multiple images belonging to disease images at different positions on the same leaf. Among them, the size of small spot disease images is mostly 720×480, and a very small number of images are 720×478. The leaf images are all local images, and the backgrounds are all images under the actual field background; southern rust is mostly local images, with a small number of whole leaf images, and the image size is 720×480, and the backgrounds are all images under the actual field background; common rust is all local images, and the image size is 720×480, and the backgrounds are all images under the actual field background. The specific sources of various disease image data are shown in Table 1:

[0052] Table 1 Data sources of different diseases

[0053]

[0054] Table 2 Classification of different diseases on corn leaves

[0055]

[0056] According to the 1st, 2nd, 11th and 14th parts of the Agricultural Industry Standards of the People's Republic of China NY / T 1248.1-2006, NY / T 1248.2-2006, NY / T1248.11-2006 and NY / T 1248.14-2006 Technical Specifications for Identification of Disease and Insect Resistance of Corn, the field disease classification and corresponding symptom descriptions of four corn leaf diseases (large leaf spot, small leaf spot, gray leaf spot and southern rust) and previous studies on common rust diseases, most of the disease images in this study are local disease images of leaves. Therefore, the classification of disease levels also takes into account the possible proportion of diseases in the entire leaf. The disease classification of leaf spot and rust and the simple description of corresponding symptoms are shown in Table 2. Schematic diagram of the proportion of leaf area occupied by similar disease spots of corn leaves with different disease levels is shown in Table 2. Figure 2 shown.

[0057] After consulting professional pest and disease websites such as the agricultural pest and disease information cloud database and the agricultural pest and disease graphic database, the disease characteristics of different selected diseases at different stages were compared again, and the above five types of diseases were divided into categories according to the disease characteristics at different stages. The unbalanced data set after division is shown in Table 3.

[0058] Table 3 Disease data statistics at different periods

[0059]

[0060] 3.2 Data Augmentation and Dataset Expansion

[0061] Data augmentation is a deep learning technique that can generate new data from an existing dataset to expand the original dataset. Commonly used data augmentation methods can be divided into two categories: offline data augmentation and online data augmentation.

[0062] Offline data enhancement mainly involves offline expansion of the original data set through various geometric transformations and noise addition methods such as translation, rotation, scaling, adding Gaussian noise, salt and pepper noise, etc., to actually increase the amount of data.

[0063] Online data enhancement is to enhance data while training, and adopt random data enhancement method for each batch. Compared with offline data enhancement, online data enhancement has greater randomness and is less prone to overfitting.

[0064] 3.2.1. Offline data augmentation method to expand data

[0065] For this experimental data, the disease data set is divided into two groups of similar disease classification experiments. The first group is spot disease, including the early, middle and late classification experiments of large spot disease, small spot disease and gray spot disease; the second group is rust disease, including the early, middle and late classification experiments of southern rust and common rust.

[0066] Due to the imbalance of categories in the initial data set, this section of the experiment chooses to use offline data enhancement to expand the data set. Before expansion, in order to ensure that similar data samples will not be distributed in the training set, validation set or test set at the same time after the data is expanded by offline data enhancement, resulting in similar sample distributions in different sets, leading to model overfitting, for spot disease images, if the imbalanced data images are greater than 400, 20 images are randomly selected from each type of disease at different periods, and for disease categories with imbalanced data images less than 250, 10 images are randomly selected from each type of disease at different periods. A total of 130 spot disease images are reserved as a test set for spot disease classification. For rust images, since the number of common rust categories is small and the number of categories is quite different from that of southern rust, among rust images, if the imbalanced data images are greater than 200, 20 images of each disease category are randomly selected at different periods. If the imbalanced data images are less than 200, 8 images of each disease category are randomly selected at different periods. A total of 84 disease images are reserved as the test set for rust classification.

[0067] According to the difference in the number of different categories, several offline data enhancement methods such as rotation, translation, salt and pepper noise, horizontal or vertical flipping, and brightness change were selected in combination. The unbalanced data of the remaining spot and rust were expanded using offline data enhancement to make the number of each category after expansion more balanced. The number of images of various diseases before and after expansion is shown in Table 4. Finally, the data before and after enhancement were divided into training set and validation set according to the ratio of 9:1.

[0068] Table 4 Disease data statistics at different periods before and after offline data enhancement

[0069]

[0070] 3.2.2 Online data augmentation method to expand data

[0071] In the YOLO model, online data enhancement methods have been integrated, and the online data enhancements implemented mainly include: mosaic enhancement (Mosaic), mixed enhancement (Mixup), random perturbation (Random Perspective) and color perturbation (HSVaugment) and other data enhancement methods. Mosaic enhancement can be turned off in the last 10 epochs to ensure that the model achieves a good training effect. During the training process of the YOLOv8 classification model, occlusion, brightness, contrast, sharpness, color balance and other methods are mainly used to perform real-time data enhancement operations on the data in each batch to ensure the diversity of the data set and improve the generalization ability of the model.

[0072] During model training, YOLOv8 can choose different data enhancement methods: randaugment (default), autoaugment, augmix, and None. When randaugment performs data enhancement, it randomly selects the above-mentioned image transformation methods and the strength of data enhancement; autoaugment predefines the image transformation method and the probability of each method, and selects the optimal data enhancement operation and strength according to different data sets; augmix realizes the mixing of the original image and the enhanced image according to certain weights to achieve online data enhancement. When a batch of images is input, three enhancement methods will be combined during the training of the YOLOv8 classification model: first, horizontal flipping or vertical flipping is used with probability p; second, one of the methods of randaugment (default), autoaugment, augmix, and None is selected; finally, the probability of erasing is set in the form of hyperparameters to erase the original image.

[0073] 3.2.3 Comparison of different data enhancement methods

[0074] In order to determine whether to use data augmentation and what data augmentation method to use to expand the number of corn leaf images with similar diseases, a comparative experiment of four data sets was first conducted. During the training process, except for using different data sets and different data augmentation methods, the other experimental parameters remained the same. The model epoch = 200, batchsize = 16, and the YOLOv8 classification model and the official pre-training weights were used for training and testing. The experimental results are shown in Table 5. The enhancement effects of several different online data augmentation methods during the training process are shown in the figure below. Figure 3 As shown in the figure, top1_acc is the accuracy of the YOLOv8 classification model on the validation set. Setting patience = 50 means that the model will stop training early if the training effect does not improve within 50 rounds, so some experiments have less than 200 epochs of training.

[0075] The details of the data set are shown in Table 5. There are 4 different data sets as follows:

[0076] Dataset 1 (data-1): balanced data after spot disease offline data enhancement;

[0077] Dataset 2 (data-2): unbalanced data before offline data enhancement for spot disease;

[0078] Dataset 3 (data-3): balanced data after rust offline data enhancement;

[0079] Dataset 4 (data-4): Unbalanced data before offline data augmentation in Rust.

[0080] Table 5 Classification effects of different data enhancement methods on different datasets (a) Spot disease balanced and unbalanced datasets

[0081]

[0082] (b) Rust balanced and unbalanced datasets

[0083]

[0084] In Table 5, None means that no online data enhancement is used. data-1 and data-3 represent the datasets after offline data enhancement of spot disease and rust disease, respectively. In Table 5, the comparison between data-1 and data-2, and between data-3 and data-4, shows that the top1_acc classification accuracy of the datasets after offline data enhancement is higher than that of the original unbalanced datasets of data-2 and data-4 before enhancement, and the top1_acc of spot disease increases by 7.8% and that of rust disease by 4.6%. However, the training time will increase correspondingly when the accuracy is improved.

[0085] Secondly, after combining the balanced dataset with the unbalanced dataset using different online enhancement methods, the classification accuracy of the two enhancement methods is significantly improved. However, due to the increase in image changes during the training process, a lot of time overhead is added.

[0086] Finally, we compared the effects of different online data augmentation methods. For spot disease, the top1_acc was the highest when using autoaugment training, and augmix and randaugment were second only to autoaugment. In comparison, the top1_acc of autoaugment increased by 0.4% and 0.6%, and randaugment had the shortest training time. The others were more than 1.74 times that of randaugment, and the number of training rounds exceeded that of randaugment by more than twice. For rust, the online augmentation method using randaugment was significantly better than other online augmentation methods. With the same top1_acc, the number of training rounds was the least and the training time was the shortest.

[0087] This experiment aims to improve the classification accuracy of similar diseases on corn leaves. The above experimental results show that the model accuracy top1_acc is higher after using offline data enhancement, but offline data enhancement is easy to generate similar samples, causing model overfitting. Therefore, different online data enhancement methods are used in combination with offline data enhancement to improve the randomness of samples. After measuring the top1_acc and time cost of the online enhancement method, in the classification experiments of two similar diseases, spot disease and rust, the use of offline data enhancement combined with the randaugment online data enhancement method can ensure the minimum time cost under high classification accuracy. Therefore, the subsequent experiments of this study use offline data enhancement combined with YOLOv8's randaugment online data enhancement method for the enhancement of spot disease and rust data sets for model training.

[0088] 4. Classification model of similar diseases of corn leaves based on lightweight improved YOLOv8

[0089] 4.1YOLOv8 classification model structure

[0090] The complete YOLOv8 model structure mainly consists of three parts: Backbone (backbone network), Neck (neck network) and Head (head network). Taking the target detection task structure diagram as an example, the functions of each part are summarized. The model structure is as follows Figure 4 shown.

[0091] The Backbone part is responsible for extracting features from the input image and using feature maps to represent the information of the input image. These features are the basis for subsequent network layers. Compared with YOLOv5, YOLOv8 uses the C2f (CSPLayer_2Conv) module to replace the C3 module of YOLOv5. The comparison chart is as follows: Figure 5As shown in the figure, C2f adds a split structure and more cross-layer connections, mainly learning residual features, so that the model has a richer gradient flow, forming a neural network module with stronger feature representation capabilities, thereby enhancing the model's ability to extract features. Neck is located between the backbone network and the head network. It is an intermediate layer that mainly performs feature fusion and enhancement. By aggregating features at multiple scales, feature map information at different levels is captured to improve the detection performance of the target. The head part is the decision-making part of the target detection model and is also the last layer. In target detection, bounding box regression and classifiers are used to predict bounding boxes, categories, confidence levels and other information. In image classification tasks, a softmax classifier is usually used to obtain classification results.

[0092] According to the introduction of the YOLO series model in Section 2, the main purpose of this study is to classify similar diseases of corn leaves, so the YOLOv8 classification model (i.e., YOLOv8-cls model) is selected. For the YOLOv8-cls model, there are four network structures with different depths and widths to choose from, namely YOLOv8n-cls, YOLOv8s-cls, YOLOv8m-cls, and YOLOv8l-cls. These models differ in many aspects such as parameter quantity, accuracy, processing speed, and model complexity. Different models can be selected according to the target tasks and data sets. The present invention uses the YOLOv8s-cls model as the basic model. Compared with the other three models, the model can provide higher accuracy and lower parameter quantity while maintaining a faster processing speed, and is more suitable for computing devices with medium capabilities. The YOLOv8-cls structure is relatively simple compared to the YOLOv8 target detection model structure. The classification model only has the backbone part and the head part. The backbone is directly connected to the head part, that is, the backbone is directly connected to the classification head of Classify to obtain the final classification result probability. Figure 6 shown.

[0093] 4.2 Variable Kernel Convolution Structure

[0094] Convolutional Kernel with Arbitrary Sampled Shapes and Arbitrary Number of Parameters (AKConv) is a convolution layer in CNN. It is a variant of the standard convolution with a convolution kernel of k×k. It allows the convolution kernel to have arbitrary sampling shapes and arbitrary number of parameters. Compared with standard convolution and deformable convolution (DConv), standard convolution generally uses a convolution kernel with a fixed window size for feature extraction. The sampling points covered on the input image are arranged regularly, generally in a k×k standard square grid. Deformable convolution (Deformable Conv) is based on standard convolution, but is not limited by the fixed sampling points of standard convolution. It learns the offset of the next sampling point by adding additional convolution layers, thereby changing the shape of the convolution kernel. However, for different convolution kernel sizes, the number of convolution parameters of the two increases quadratically, while the parameters of AKConv increase linearly. In terms of the size of parameters, the AKConv convolution structure has great advantages. Therefore, using AKConv instead of standard Conv can provide a good improvement direction for lightweight models.

[0095] The initial convolution kernel shape of AKConv is similar to that of standard convolution, with different convolution kernel sizes (kernel_size) such as Figure 7 shown. Figure 8 Taking the initial kernel_size = 5 as an example to show the specific convolution structure of AKConv, the convolution process is described as follows:

[0096] (1) First, input a feature map of size C×H×W. The initial convolution kernel size is a priori knowledge and is predefined artificially.

[0097] (2) Calculate the convolution kernel offset and change the shape of the convolution kernel. The offset is obtained through convolution calculation, and the average offset (OA) is used to represent the average change of each sampling point. The shape of the convolution kernel is changed to adapt to the characteristics of the image and the new sampling point coordinates are determined. The calculation is shown in formula (1).

[0098]

[0099] N represents the convolution kernel size, that is, the number of sampling points, and 2N means it includes both horizontal and vertical directions;

[0100] (3) Obtain image feature information of new sampling points using bilinear interpolation and resampling;

[0101] (4) To facilitate other subsequent convolution operations, the feature map obtained by AKConv is reshaped to change its dimension;

[0102] (5) Finally, after normalization and activation function, the final feature map after AKConv convolution is obtained.

[0103] Since the initial convolution kernel size and replacement position of AKConv are prior knowledge, when using AKConv to replace the standard convolution in YOLOv8s-cls, the convolution kernel size of AKConv and the different replacement positions need to be considered. According to the above AKConv convolution process and the relationship between the convolution kernel size and the initial sampling shape, if kernel_size=1, the initial sampling shape of AKConv is equivalent to the standard 1×1 structure, except that randomness is added during the convolution process; if kernel_size=2, such as Fig. 9 As shown in the figure, the convolution kernel can achieve a small number of sampling shapes. After replacing Conv, the transformable shapes do not change significantly compared with the original standard sampling points. If kernel_size=9, it is the same as the initial sampling shape of 3×3 Conv. Consider comparing convolution kernels of the same size. During the convolution process, the impact of the convolution kernel shape change on the original model or target task. Therefore, combined with the introduction of the YOLOv8-cls model structure in Section 4.1, because the original input image size is larger than the feature map size after a layer of convolution, in addition to the target features, there will be a large number of other irrelevant pixels interfering. If the AKConv structure is used directly to start the convolution, the image will be too large, resulting in more parameters required for the convolution process. Therefore, in this study, the 0th layer convolution structure of the YOLOv8s-cls model is not replaced, and the original 3×3 standard convolution structure is maintained. Four different kernel_sizes are used, namely 3, 5, 6, and 9. Fig. 9 There are four standard convolution positions: 1, 3, 5, and 7. The convolution structure is replaced in the following way: layer 1, layer 1 and 3, layer 1, 3 and 5, layer 1, 3, 5 and 7. The number of replaced layers is increased in sequence. When the number of layers increases, the same size of convolution kernel is replaced in different layers in the same way. Fig.10 shown.

[0104] 4.3 Methods to solve the imbalance of sample category quantity

[0105] In real-world classification tasks, datasets often have the problem of unbalanced sample distribution. Directly using unbalanced data for machine learning or deep learning model training will cause the model to learn the prior information about the sample ratio in the training set, resulting in a focus on the majority class in actual prediction, with higher accuracy for the majority class and lower accuracy for the minority class. Commonly used methods to solve sample class imbalance

[35] There are the following:

[0106] (1) Data samples: directly adjust the number of samples through random oversampling, undersampling, data enhancement and other methods;

[0107] (2) Model algorithm: Use models that are less sensitive to imbalanced categories, such as logistic regression models, decision trees, random forests, etc.

[0108] (3) Loss function: Through cost-sensitive learning, different penalties are given to different classification losses, that is, different weights are set for different categories. For example, the FocalLoss loss function can adjust the weight of the loss function through two different parameters to solve the problems of class imbalance and difficult classification. The compute_class_weight function of the scikit library calculates the weights of different categories. The size of the weight is set according to the sample distribution to increase the weight of the minority sample category in the loss function. The weight factor is added to the original loss function to balance the distribution of the loss function.

[0109] (4) Evaluation indicators: Select more convincing evaluation indicators such as PR curve, F1 score, ROC curve, etc., select a better performance threshold, adjust the classifier decision threshold, and conduct a more accurate evaluation of the classification results.

[0110] Based on the above methods for solving sample imbalance at different levels, in actual application, different levels of methods are combined according to different tasks and data to make model training more accurate.

[0111] The amount of common rust data in the original data set of the present invention is too small compared with that of southern rust, and the number of each category of the two is seriously unbalanced. When the YOLOv8s-cls model is used for classification training, although the two types of data enhancement methods are combined, the randomness of the online data enhancement method alleviates the problem that the offline data enhancement method easily causes model overfitting, but because deep learning relies heavily on samples, and the YOLOv8s-cls model uses a cross entropy loss function to calculate the loss, the loss function does not distinguish between weight tendencies for each category, and all categories have the same weight, which leads to less attention to category imbalance data, and the final classification result is greatly affected by the majority class.

[0112] Therefore, based on the above-mentioned different-level category balancing strategies, this paper uses a cost-sensitive learning method to study rust. In the YOLOv8s-cls model improved by AKConv, different categories of the loss function are weighted. By using the compute_class_weight function of the scikit library, the balanced function is specified to automatically calculate the weights of different categories. The minority class has a higher weight and the majority class has a lower weight. The weight calculation is shown in formula (2).

[0113]

[0114] n_samples represents the total number of samples in training, n_classes is the number of categories, and n_samples_i is the number of samples in the ith category. Then, corresponding weights are assigned to the calculation of cross entropy loss for different categories, so that the model pays more attention to minority categories and improves the credibility of classification results.

[0115] 4.4Shuffle Attention Mechanism

[0116] Commonly used attention mechanisms include spatial attention mechanism, channel attention mechanism and the combination of the two. They can focus on target features from different levels, thereby locating information of interest and ignoring or suppressing other irrelevant regional information. Therefore, they are widely used in computer vision, natural language processing and other fields. Commonly used attention mechanisms include SA (Spatial Attention), SE (Squeeze-and-Excitation), CBAM (Convolutional Block Attention Module), etc., but when using different attention mechanisms, specific goals and task requirements need to be considered, such as: model complexity, model convergence difficulty, computing resources, etc.

[0117] For the classification task in this paper, this paper chooses to use the SA (Shuffle Attention) attention mechanism to improve the model, aiming to improve the accuracy of the existing model and lighten the model structure. The SA (Shuffle Attention) attention mechanism combines spatial attention and channel attention. The SA attention mechanism uses the idea of ​​SGE channel grouping and the advantages of the lightweight network ShuffleNetV2 to efficiently build a multi-branch structure and different branches can be processed in parallel. It combines spatial attention and channel attention to become a lightweight and efficient attention mechanism. Compared with other attention mechanisms that have problems such as convergence difficulties and large computational complexity, the SA attention mechanism has fewer parameters and lower computational complexity. The structure of the SA attention mechanism is as follows: Fig.11 As shown, the specific principles are as follows:

[0118] (1) Feature grouping: The input feature map c×h×w is divided into g groups along the channel dimension c. Each group is a sub-feature map of the original feature map with a channel size of c / 2g. Then, the sub-feature map with the number of channels c / g is further divided into two branches along the channel dimension c / g. The branch channels are c / 2g respectively. The two branches generate channel attention and spatial attention weight information respectively.

[0119] (2) Channel attention, Fig.11The upper middle branch is the channel attention branch. First, GAP (global average pooling) is used for the c / 2g channels of this branch to calculate the pixel average of the sub-feature map on each channel. The size of each pixel average is 1×1×1, and there are c / 2g pixel averages in total. Therefore, a statistic s of c / 2g×1×1 is obtained, which contains the global information of each channel in the c / 2g channels. Then, a single-layer simple transformation Wx+b is used on s. Since W and x are both matrices, the two are matrix multiplied. The dimension of W determines the dimension of the space that the input sub-feature map can learn. Therefore, this transformation actually performs nonlinear mapping on each channel, which helps the model learn more complex feature representations. Compared with SE attention, the single-layer simple transformation Wx+b simplifies the double-layer fully connected layer transformation of SE attention and reduces the number of model parameters. Finally, the Sigmoid activation function is used to convert the feature vector into an attention weight to obtain the channel attention map of the branch. The attention map is used as a weight matrix to fuse with the original feature map, that is, matrix multiplication, to obtain a weighted sub-feature map. The new sub-feature map adds information about the importance of different positions.

[0120] (3) Spatial attention, Fig.11 The middle and lower branches are spatial attention branches. This branch first performs GN (Group Normalization) on the sub-feature map, the same as channel attention, and then performs a single-layer simple transformation Wx+b and Sigmoid activation function processing to obtain a spatial attention map. It is fused with the original feature map of this branch to obtain a weighted sub-feature map, and the weighted sub-feature maps of the two attention branches are concat spliced ​​to ensure that they have the same size as the input;

[0121] (4) Feature aggregation and channel shuffling. Each group of sub-feature maps is channel aggregated. At this time, the feature map already contains information that strengthens or suppresses different information in the original feature map. Then, the channel shuffle operation of ShuffleNetV2 is used to rearrange the channels and realize the interaction of information between channel groups.

[0122] In the whole process of implementing the SA attention mechanism, there are only 4 parameters W 1 , b 1 , W 2 , b 2 , respectively represent the weight coefficient and offset of the simple transformation of the feature map before two Sigmoids. Compared with other attention mechanisms, the SA attention mechanism does not add a large number of additional parameters and is a lightweight attention mechanism. Therefore, combined with the YOLOv8s-cls-AKconv model structure and the cross-layer connection structure of C2f, we choose Fig.10 Add SA attention mechanism between the 7th and 8th layers.

[0123] 5 Experimental results and analysis

[0124] 5.1 Experimental environment parameter settings

[0125] This study was completed on the GPU cloud platform. The specific operating environment required for the experiment is shown in Table 6.

[0126] Table 6 Experimental environment parameters

[0127]

[0128] 5.2 Experimental evaluation indicators

[0129] 5.2.1 Confusion Matrix

[0130] Taking binary classification as an example, the confusion matrix of classification results is shown in Table 7.

[0131] Table 7 Confusion matrix of binary classification results

[0132]

[0133] Among them, TP (True Positive) means that the true category of the sample is a positive example, and the model predicts it to be a positive example, that is, the number of diseases correctly classified by the model. TN (True Negative) means that the true category of the sample is a negative example, and the model predicts it to be a negative example; in disease classification, it means the number of samples that the model identifies as having no disease; FP (False Positive) means that the true category of the sample is a negative example, and the model predicts it to be a positive example; FN (False Negative) means that the true category of the sample is a positive example, and the model predicts it to be a negative example, and in disease classification, it means the number of samples that have not been identified as having a disease.

[0134] 5.2.2 Accuracy

[0135] Accuracy evaluates the classification effect of the classification model. Its calculation is shown in formula (3), that is, the proportion of samples correctly classified by the model to the total number of samples. Combined with the above confusion matrix, the calculation of accuracy can be expressed as formula (4).

[0136]

[0137] 5.2.3 Loss Function

[0138] Cross entropy describes the distribution distance between two probabilities. The smaller the cross entropy, the closer the two probability distributions are. In machine learning and deep learning, cross entropy loss is often used in classification tasks to calculate losses and measure the distance between model predictions and true labels. The calculation is shown in formula (5), where p(xi) is the true distribution of a category and q(xi) is the predicted category distribution.

[0139]

[0140] 5.3 Experiment of replacing the standard Conv structure with AKConv

[0141] 5.3.1 Effects of different convolution kernel sizes and different replacement positions on the AKConv model

[0142] Based on the different convolution kernel sizes and convolution replacement positions of AKConv introduced in Section 4.2, Table 8 makes a simple comparison of the overall model parameters and complexity (GFLOPs) after AKConv uses convolution kernels of different sizes and replaces different positions (location) Conv in the YOLOv8s-cls model, providing a reference for subsequent improvement experiments. Table 8 focuses on the parameters and GFLOPs model complexity.

[0143] Table 8 Comparison of parameters at different replacement positions in the YOLOv8s-cls classification model

[0144]

[0145] Note: Different replacement positions in the table are for Fig.10 The corresponding number of layers in the YOLOv8s-cls model is AKConv instead of Conv. The rest of the YOLOv8s-cls model structure is kept, and the convolution kernel is kept 3×3. Parameters represents the overall parameter quantity of the YOLOv8s-cls model. GFLOPs (floating point operations) represents the number of floating point operations, which measures the complexity of the model. It is different from GFLOPS (floating point operations per second), which is the number of floating point operations per second, which theoretically measures the hardware performance. Layers represents the number of layers of the overall model after replacement.

[0146] From the analysis of Table 8, we can see that:

[0147] (1) Except for the AKConv with the same kernel_size as Conv, which has a larger number of parameters than the structure before replacement, the other AKConv replacement methods all reduce model parameters (parameters) and reduce model complexity (GFLOPs);

[0148] (2) Under the same location, when AKConv is used to replace Conv, the overall model parameters and model complexity GFLOPs increase as the convolution kernel size increases;

[0149] (3) When the AKConv structure has the same kernel_size, as the number of AKConv replacing standard Conv increases, the overall parameters and GFLOPs of the model gradually decrease. When the number of replaced layers and convolution kernels increases to a certain extent, as shown in Table 8, when the Conv standard convolution at 4 positions is replaced and the initial sampling shape of the variable kernel convolution is 9, the model parameters and GFLOPs are higher than the YOLOv8s-cls model with the standard Conv structure before replacement. The main reason is that when the kernel_size of AKConv is k×k, AKConv and standard Conv have convolution kernels of the same size and shape. After using AKConv, the number of model layers increases and the convolution kernel shape is adjusted during the convolution process, which leads to additional parameters for calculating offsets, resampling, reshaping, etc. during the model training process. Therefore, when the two have the same convolution kernel size, the overall model parameter amount and complexity increase. When AKConv is used to replace Conv at 4 positions, the model has the least number of parameters and the lowest complexity;

[0150] (4) In addition, the last two rows of Table 8 also consider replacing the Conv structure of the higher layer of Conv with kernel_size=3 of AKConv. As shown in Table 8, the experimental results also prove that replacing 4 positions at the same time has a better effect.

[0151] Therefore, based on the above analysis, when the present invention uses AKConv to replace the Conv standard convolution in YOLOv8s-cls, the convolution kernel kernel_size=3 is used to replace Fig.10 The standard Conv structure at the 1st, 3rd, 5th, and 7th layers has the best effect on model improvement.

[0152] 5.3.2 Effect of replacing Conv structure with AKConv on classification of similar diseases on corn leaves

[0153] The experiments in this section are divided into two groups for the improvement of spot and rust. Experiment 1: spot, epoch = 150, batchsize = 64; Experiment 2: rust, epoch = 150, batchsize = 64. The accuracy and loss curves of the model before and after the improvement are shown in the figure. Fig.12 The comparison of model parameters before and after improvement is shown in Table 9.

[0154] Depend on Fig.12 It can be seen that before and after replacing the standard Conv structure with AKConv, the accuracy curves of spot and rust in Figures (a) and (c) are lower than the accuracy before replacement, and the overall loss curves in Figures (b) and (d) are higher than the model loss before replacement. Before and after the spot replacement, the accuracy and loss curves of the original model in Figures (a) and (b) tend to be stable at around 40 rounds, and the model converges quickly. The improved model YOLOv8s-cls-AKConv gradually converges after around 120 rounds. Although its final accuracy is close to that of the original model, the number of model convergence rounds increases; before and after the rust replacement convolution structure, the changes in the accuracy and loss curves of the original model in Figures (c) and (d) are similar to those of the spot curve, and the model gradually converges at around 40 rounds. The improved model YOLOv8s-cls-AKConv gradually converged after 140 rounds, and the final model accuracy was lower than that of the original model. In addition, in Figures (c) and (d), the curves changed greatly and the accuracy dropped sharply around rounds 15 to 40. The reason for this is that the rust categories are seriously unbalanced, and the model pays more attention to the categories with a large number and pays less attention to the categories with a small number, resulting in low recognition accuracy for the categories with few samples. Separate analysis of the accuracy and loss changes of the models before and after the improvement for spot and rust shows that the accuracy of the improved model has not improved, and is even lower than the accuracy before the improvement.

[0155] Table 9 Comparison of model accuracy and parameter quantity before and after replacing the convolution structure

[0156]

[0157] The first column of indicators in Table 9, accuracy, reflects the classification accuracy of the model on the validation set. During the training process, the model uses the training set to train the model, adjusts the model parameters to learn the existing data features, and continuously evaluates the accuracy and loss on the validation set to reflect the changes in the model recognition accuracy and loss, and monitor the model changes. The changes in the accuracy value before and after the improvement are consistent with the changes in the above accuracy curve; compared with the second column of indicators in Table 9, parameters, the number of model parameters after the improvement is significantly lower than the number of model parameters before the improvement, with a difference of more than 1.01 million.

[0158] After a comprehensive analysis of the balance between the model's classification accuracy and the number of parameters, the improved model YOLO v8s-cls-AKConv has a lower accuracy and loss value than the original model in the classification task of spot and rust, but the number of parameters of the improved model is significantly reduced compared to the original model. Therefore, the model classification accuracy under unit parameters is used as an evaluation indicator to comprehensively evaluate the effect of the improved model. According to the analysis results, the model classification accuracy of the improved model under unit parameters is higher than that of the YOLOv8s-cls model before the improvement. Therefore, when the model has the same number of parameters, the optimized YOLO v8s-cls-AKConv model achieves better classification performance in terms of unit parameter efficiency.

[0159] 5.4 Weighted Loss Function Experiment

[0160] Depend on Fig.12 Figures (c) and (d) show that the accuracy and loss curves of the YOLOv8s-cls-AKConv model before and after rust training are extremely unstable. Fig.12 In (a) and (b), the curves without rust change greatly. By comparing the number of categories of spot disease and rust disease, we can conclude that the reason is that the number of categories in the original rust disease dataset is seriously unevenly distributed. Therefore, based on the weighted loss function strategy proposed in Section 4.3, we set epoch=150 and batchsize=64, and conduct experiments on rust disease. Based on the YOLOv8s-cl s-AKConv model, we compare the classification accuracy and loss changes of the models before and after weighting for rust disease. Fig.13 The changes in model parameters before and after weighting are shown in Table 10.

[0161] Table 10 Comparison of model accuracy and parameter quantity before and after weighting based on the loss function of the YOLOv8s-cls-AKConv model

[0162]

[0163] observe Fig.13 It can be seen that the accuracy and loss changes of the model YOLOv8s-cls-AKConv-Balanced on the validation set after the weighted loss function are more stable than before the weighting, and the model can better learn the category information of the few samples. Comparing Table 10, it can be seen that the number of model parameters remains unchanged after weighting, the model accuracy is improved by 1%, and the model classification accuracy under the unit parameter number is improved by 1.082%. Therefore, subsequent research experiments on rust will use the model YOLOv8s-cls-AKConv-Balanced combined with the weighted loss function.

[0164] 5.5 Adding Shuffle Attention Mechanism Experiment

[0165] According to the location of adding the SA attention mechanism proposed in Section 4.4, epoch=150, batchsize=64 are set, and the classification of two groups of similar lesions is further improved based on the YOLOv8s-cls-AKConv model. The classification accuracy and loss curves of the model before and after adding the SA attention mechanism are shown in the figure below. Fig.14 The comparison of model parameters and model accuracy before and after adding the SA attention mechanism is shown in Table 11.

[0166] observe Fig.14 The four figures show that the improved model YOLOv8s-cls-AKConv-SA after adding the SA attention mechanism has no obvious improvement effect on the two groups of similar lesions. The accuracy and loss curves of the two groups of experiments are relatively overlapping, and the difference is not obvious. Fig.14 In the middle (c) and (d), the accuracy and loss of the graphs are slightly improved around 130 rounds compared to before the SA attention mechanism was added. Fig.14 In (a) and (b), the two curves before and after adding the SA attention mechanism almost completely overlap, and the changes are not obvious.

[0167] Table 11 Comparison of model accuracy and parameters before and after adding SA attention

[0168]

[0169] Analyzing Table 11, for the classification of rust, the classification accuracy of the model YOLOv8s-cls-AKConv-Balanced-SA after adding the SA attention mechanism is 0.6% higher than that of the model YOLOv8s-cls-AKConv-Balanced, and the classification accuracy per unit parameter is increased by 1.706%. Compared with before adding the SA attention mechanism, the accuracy of the model after adding the SA attention mechanism for the classification of rust has been improved. For the classification of spot, after adding the SA attention mechanism, the accuracy has dropped by 0.1%, the parameters have increased, and the classification accuracy of the model per unit parameter has not been improved.

[0170] Considering the impact of different positions of the SA attention mechanism or the number of model training rounds on the model effect, an experiment of adding the SA attention mechanism to the spot disease is added here: changing the position where the SA attention mechanism is added, and appropriately increasing the number of training rounds, and comparing the effect of adding the SA attention mechanism. Fig.15 As shown, epoch=150, batchsize=64 are set, and the comparative experiments are shown in Table 12.

[0171] Table 12 Comparison of SA attention mechanism models added at different positions

[0172]

[0173] Note: The first line in the table is the model YOLOv8s-cls-AKConv before adding the SA attention mechanism.

[0174] From the analysis of Table 12, we can see that in the second and third rows of the table, before and after the SA attention mechanism is added at the same position, when the number of training rounds increases by 50 rounds, the model classification accuracy increases by 0.1%, the parameters do not change, and the time consumption increases by 1.706h. Compared with the first row before the SA attention mechanism is added, the same classification accuracy can be achieved only when the time consumption is increased. It can be seen that after the addition, the model effect becomes worse; compared with the third and fourth rows in the table, under the same epoch, the time consumption of the SA attention mechanism at position 1 and position 2 is not significantly different, the parameters are only reduced by 105, and the model accuracy decreases, and the model effect becomes worse. In addition, comparing the second and fourth rows in Table 12, although the number of training rounds and the position of the SA attention mechanism are different at this time, the accuracy of the two different positions does not change. Compared with position 1, the number of parameters at position 2 only decreases by 96, and the classification accuracy under the unit parameter amount is only increased by 0.00005 (×10 -5 ), but it increases the training time cost.

[0175] Therefore, for the improved experiment of adding SA attention mechanism based on YOLOv8s-cls-AKConv for spot disease, the model accuracy is only slightly improved when the epoch is increased and additional time is required, and after the improvement, the classification accuracy of the model is only the same as that before the SA attention mechanism is added. The classification effect of the model is not improved after the SA attention mechanism is added. Therefore, in subsequent research, the classification of spot disease will use the YOLOv8s-cls-AKConv model instead of the YOLOv8s-cls-AKConv-SA model.

[0176] 5.6 Ablation Experiment

[0177] In view of the different improvement methods mentioned above, in order to verify the effectiveness of various improvement methods in this paper, the YOLOv8s-cls model is taken as the baseline model, and the accuracy, parameters, GFLOPs, epochs, and model classification accuracy under unit parameters (accuracy×100 / parameters) are used as evaluation indicators to compare the effects of different combinations of different improvement methods on the model. The ablation experiment is carried out, and the experimental results are shown in Table 13.

[0178] Table 13 Ablation experiment

[0179]

[0180] From the analysis of Table 13, we can see that for the classification of spot diseases, after using YOLOv8s-cls-AKConv to improve the original YOLOv8s-cls model convolution structure, the overall parameters and GFLOPs of the model are significantly reduced. Although the accuracy is reduced by 1.1%, the parameters are reduced by more than 1.01 million and the GFLOPs are reduced by 2.4. The reason is that after using AKConv to replace the standard Conv structure of the original YOLOv8s-cls model, the arbitrary change of the convolution kernel shape leads to a significant reduction in the overall number of model parameters compared to the original fixed k×k convolution structure, and the model is more lightweight. However, due to the arbitrariness of the change of the convolution kernel shape, some relevant and important feature information is ignored in the convolution process, which reduces the final classification accuracy. Subsequently, in order to improve the classification accuracy of the model, the SA attention mechanism was added to the YOLOv8s-cls-AKConv model. However, the model effect was not improved after the addition. The experiments on increasing the number of training rounds and changing the position of the SA attention mechanism for spot disease in the previous article also confirmed the above conclusion. Therefore, adding the SA attention mechanism to the YOLOv8s-cls-AKConv model has no improvement effect on the classification and recognition of spot disease.

[0181] For rust classification, after using YOLOv8s-cls-AKConv to improve the original YOLOv8s-cls model convolution structure, the changes in model parameters and classification accuracy are similar to those of rust. In addition, due to the obvious difference in the number of categories in the original rust data set, even if different data enhancement methods are used for data balancing, the processed data has a certain degree of similarity, and the model is easy to learn the features of categories with a large number and pay less attention to categories with few samples, which leads to a decrease in the classification accuracy of the YOLOv8s-cls-AKConv model. Therefore, the ablation experiment in Table 13 then uses the strategy of weighting the loss function to alleviate the sample imbalance phenomenon, and adds a lightweight SA attention mechanism to improve the model recognition accuracy. After using the weighted loss function, the accuracy of the YOLOv8s-cls-AKConv-Balanced model is 1% higher than before weighting, which increases the model's learning ability for small sample categories and has an improvement effect on the model. Then, based on YOLOv8s-cls-AKConv-Balanced, the SA attention mechanism is added before the last C2f module of YOLOv8s-cls. From the last row in Table 13, it can be seen that after adding the SA attention mechanism, the classification accuracy of the model is improved by 1.6% compared with before adding it.

[0182] In summary, compared with the original YOLOv8s-cls model, the improved model based on YOLOv8s-cls-AKConv has a lower classification accuracy of 0.1% and 2% for spot disease and rust disease, respectively, but the number of parameters is reduced by 20.005% and 20.016%, respectively, and GFLOPs is reduced by 19.2%; the classification accuracy of the model under the unit parameter amount for spot disease and rust disease is increased by 23.558% and 22.443%, respectively. Therefore, the effectiveness of the improved method proposed in this paper is shown. According to the above analysis, for spot disease, the optimal improved model is YOLOv8s-cls-AKConv, and for rust disease, the optimal improved model is

[0183] YOLOv8s-cls-AKConv-Balanced-SA.

[0184] The confusion matrix of the above two optimal improved models for classification prediction of spot and rust at different stages is as follows: Fig.16 The classification accuracy for each type of disease is shown in Table 14.

[0185] Table 14 Comparison of the classification accuracy of each type of disease by the optimal improved model

[0186]

[0187] analyze Fig.16 It can be seen that Fig.16In the confusion matrix of spot disease (a), for the classification of the three types of spots, the average accuracy of the optimal model for the classification of different spots in different stages is 93.667%, and there is less than 8% possibility that the disease characteristics of the adjacent stages are similar to the stage to which the disease belongs, and the stage to which it belongs is misclassified. In addition, combined with the similar characteristics of large spot disease and gray spot disease in the early stage, there is a possibility that the early and middle gray spot disease is classified as early large spot disease in the figure, but the optimal model has better classification effect on other stages of gray spot disease and large spot disease and small spot disease that are similar to it in other stages; Fig.16 In (b), for the classification of rust, there is a 3% and 2% possibility of confusing the middle stage of southern rust with the middle stage of common rust, and the early stage of southern rust with the middle stage of common rust, respectively. However, the average classification accuracy of the optimal model for different stages of rust is 95.167%. Combined with Table 14, for different stages of various similar diseases on corn leaves, the classification accuracy of the model is between 91% and 96%, but the characteristics of the early and middle stages of gray spot disease and the early and middle stages of large spot disease are similar. This experimental model needs to be improved to more accurately distinguish the different stages of these two lesions.

[0188] 5.7 Comparison with other models

[0189] The above optimal improved model is compared and analyzed with the original YOLOv8s-cls, YOLOv5s-cls (v6.2 version), Res Net34, and MobileNetV3 models. The classification accuracy, parameter quantity, and model classification accuracy under unit parameters of the model are shown in Table 15.

[0190] Table 15 Comparison of different models

[0191]

[0192] From the analysis of Table 15, it can be seen that when considering the model classification accuracy and parameter changes respectively, the YOLOv8s-cls model has the highest accuracy. The classification accuracy of the optimal improved models YOLOv8s-cls-AKConv and YOLOv8s-cls-AKConv-Balanced-AKConv-SA in this experiment is the second highest, with classification accuracy rates of 93.8% and 95.0% for spot and rust respectively, and the two improved optimal models have the lowest parameter volume, realizing a lightweight model structure; while the ResNes34 model has the lowest classification accuracy and the highest model parameter volume. Compared with the four models compared here, ResNet34 is a deep residual network commonly used for image classification, and its network structure is deeper, resulting in a more complex network and more parameters. The YOLO series models are mainly used for target detection, so their network structure is more suitable for real-time needs, so their network structure is simpler than the ResN et34 network structure; MobileNetV3 is proposed based on a lightweight model structure, so it has fewer parameters. When comprehensively analyzing the above comparison model accuracy and parameter changes, the model classification accuracy under unit parameter amount is used to further evaluate the classification effects of various models. As shown in the last column of Table 15, the optimal improved model in this experiment has the best implementation effect and can ensure the highest model classification accuracy when the model has the same parameter amount.

[0193] Therefore, compared with the classic classification model ResNet34, YOLOv5s-cls (version 6.2) of the YOLO series, the baseline model YOLOv8s-cls of the present invention and the lightweight model MobileNetV3, the improved model YOLOv8s-cls-AKConv for spot classification and the improved model YOLOv8s-cls-AKConv-Balanced-AKConv-SA for rust classification of the present invention are better than other comparison models. Therefore, in the final test experiment, the improved model YOLOv8s-cls-AKConv is used to classify the spot, and the YOLOv8s-cls-AKConv-Balanced-AKConv-SA is used to classify the rust.

[0194] 5.8 Test the classification effect based on the improved optimal model

[0195] In this section, we randomly select the YOLOv8s-cls-AKConv model to test the classification effect of 4 spot disease images based on the previous experiment, and select the YOLOv8s-cls-AKConv-Balanced-SA model to randomly test the classification effect of 4 rust disease images. The test results of the two categories of similar spots are shown in the figure. Fig.17 shown.

[0196] Fig.17 For each image, the five most likely categories and corresponding predicted probabilities will be generated, which can be used as a reference for the final model test classification.

[0197] Fig.17 (a) is classified as the early stage of big spot disease, and the predicted probability of the early stage of big spot disease is 1; Fig.17 Middle (b) is classified as the late stage of large spot disease, with a predicted probability of 67% and a predicted probability of 33% for the middle stage of large spot disease. The lesion features presented in this image include both the large spindle-shaped lesions of the middle stage and the lesions of the late stage with significantly darkened edges that will be fused. Fig.17 (c) is classified as the early stage of small spot disease, and the predicted probability of the early stage of small spot disease is 1; Fig.17 Middle (d) is classified as early stage of gray spot disease, with a predicted probability of 84% for early stage of gray spot disease, 14% for early stage of large spot disease, 1% for early stage of gray spot disease, and 1% for early stage of gray spot disease, because the image shows the obvious rectangular edge characteristics of the middle stage of gray spot disease, and the spindle-shaped enlarged lesions characteristics of the early to middle stage of large spot disease; Fig.17 (e) is classified as the early stage of common rust, and the probability of predicting the early stage of common rust is 98%. Because the image shows the herpes-like ridges of the early stage of common rust, which is similar to the characteristics of the spore pile before the rupture of the early to middle stage of southern rust, there is a 1% probability of predicting it as the middle stage of southern rust and the middle stage of common rust; Fig.17 Middle (f) is classified as the late stage of southern rust, and the probability of being predicted as the late stage of southern rust is 99%. Because the spore piles on the leaves are densely distributed and the color of the spore piles is darker, it shows the state of the middle and late stage of southern rust. The probability of being predicted as the middle stage of southern rust is 1%; Fig.17 The middle (g) is classified as the early stage of southern rust, and the predicted probability of the early stage of southern rust is 1; Fig.17 The middle (h) is classified as the late stage of common rust, with a predicted probability of 94% for the late stage of common rust and 6% for southern rust. Because the spore piles on the leaves are densely distributed and the layers are thick, the predicted probability of common rust is higher.

[0198] The above test results show that the two optimal models can better classify the categories and corresponding periods of similar diseases. Therefore, they can be applied to the classification of similar diseases in different periods of actual corn leaves, identify the category of the disease and assist in judging the period of the disease, which is helpful to take reasonable and accurate response measures in time for the occurrence of existing diseases.

[0199] The above description is only for illustrating the present invention. It should be understood that the present invention is not limited to the above embodiments, and various variations that conform to the concept of the present invention are within the protection scope of the present invention.

Claims

1. A lightweight identification method for crop diseases, characterized in that: The following steps are involved: S1: The acquired corn spot and rust image datasets are expanded using offline data enhancement combined with randaugment online data enhancement; S2: Use a convolution structure AKConv with a convolution kernel of arbitrary shape and arbitrary number of parameters to replace the standard Conv structure in the YOLOv8 classification model; S3: By using the compute_class_weight function to calculate the weights of various unbalanced samples of Rust, a certain weight is given to the loss function of different categories of Rust, so that it pays more attention to the minority sample class; S4: Finally, in order to improve the accuracy of model recognition, a lightweight attention mechanism Shuffle Attention, referred to as SA, is added to the end position of the last variable kernel convolution on the basis of the YOLOv8 classification model based on the variable kernel convolution structure. It combines spatial and channel information to improve the model classification accuracy while keeping the model as lightweight as possible.

2. A lightweight identification method for crop diseases according to claim 1, characterized in that: The offline data enhancement method in step S1 specifically includes translation, rotation, scaling, adding Gaussian noise, salt and pepper noise geometric transformation and adding noise to first expand the original data set offline to increase the data volume.

3. A lightweight identification method for crop diseases according to claim 1, characterized in that: The randaugment online data enhancement method in step S1 specifically includes mosaic enhancement, mixed enhancement, random perturbation and color perturbation data enhancement methods, among which the mosaic enhancement can be turned off in the last 10 epochs to ensure that the model achieves better training results.

4. A lightweight identification method for crop diseases according to claim 1, characterized in that: The specific process of replacing the standard Conv structure in the YOLOv8 classification model with AKConv in the step S2 includes: not replacing the 0th layer convolution structure of the YOLOv8s-cls model, keeping the original 3×3 standard convolution structure, using four different kernel_sizes, namely 3, 5, 6, and 9, wherein the four standard convolution positions are 1, 3, 5, and 7, and the convolution structure is replaced in the following manner: the 1st layer, the 1st and 3rd layers, the 1st, 3, and 5th layers, the 1st, 3, 5, and 7th layers, and the number of replaced layers is increased successively. When the number of layers increases, the convolution kernels of the same size are replaced with different layers in the same manner.

5. A lightweight identification method for crop diseases according to claim 4, characterized in that: The specific process of step S3 includes using a cost-sensitive learning method for the study of rust, weighting different categories of the loss function in the improved model of AKConv, namely YOLOv8s-cls-AKconv, and automatically calculating the weights of different categories by specifying balanced using the compute_class_weight function of the scikit library, where the minority class has a higher weight and the majority class has a lower weight. The weight calculation is shown in formula (1): Among them, n_samples represents the total number of samples in training, n_classes is the number of categories, and n_samples_i is the number of samples in the i-th category. Then, corresponding weights are assigned to the calculation of cross entropy losses of different categories, so that the model pays more attention to minority categories and improves the credibility of classification results.

6. A lightweight identification method for crop diseases according to claim 4, characterized in that: The process of S4 includes combining the YOLOv8s-cls-AKconv model structure and the cross-layer connection structure of C2f, and adding the lightweight attention mechanism SA before the last C2f module.

Citation Information

Cited By

  • Railway infrastructure crack segmentation method, readable storage medium and computer equipment

    CN121147919A