Classification method and device for apple leaf diseases, terminal, medium and program product

Through the improved ConvNeXt network and Enhanced CBAM attention mechanism, the problem of time-consuming and poor accuracy of traditional apple leaf disease diagnosis is solved, and fast and accurate disease identification is achieved.

CN119600370APending Publication Date: 2025-03-11XINJIANG UNIVERSITY
View PDF 0 Cites 5 Cited by

Patent Information

Application Number
CN202411767385.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-04
Publication Date
2025-03-11

AI Technical Summary

Technical Problem

Traditional diagnosis of apple leaf disease depends on manual experience, which has problems such as time-consuming and poor accuracy.

Method used

By collecting image data of apple leaves, pre-processing, an improved ConvNeXt network was constructed, and the Enhanced CBAM attention mechanism was introduced, and an apple leaf disease classification model was trained to identify the apple leaf pictures to be detected.

Benefits of technology

It realizes rapid identification of apple leaf diseases and improves the accuracy of identification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119600370A_ABST
    Figure CN119600370A_ABST
Patent Text Reader

Abstract

The invention discloses an apple leaf disease classification method and device, a terminal, a storage medium and a computer program product, and the method comprises the steps: collecting image data of apple leaves as a sample, and carrying out the preprocessing of the image data to obtain a training set and a test set; the method comprises the following steps: introducing an EnhancedCBAM attention mechanism, and constructing an improved ConvNeXt network as a new ConvNeXt network; training by using the training set to obtain a trained apple leaf disease classification model; testing by using the test set to obtain a corrected apple leaf disease classification model; acquiring image data of apple leaves to be detected; and detecting by using the corrected apple leaf disease classification model to obtain the disease type of the to-be-detected apple leaf. According to the scheme, the apple leaf disease classification model is obtained based on the improved ConvNeXt training to identify the to-be-detected apple leaf picture, the apple leaf disease can be rapidly identified, and the accuracy is good.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of computer technology, and specifically relates to a classification method, device, terminal, storage medium and computer program product for apple leaf diseases, and in particular to a classification method, device, terminal, storage medium and computer program product for apple leaf diseases based on improved ConvNeXt. Background Art

[0002] In the current apple planting management, timely and accurate identification of leaf diseases is an important link to ensure apple yield and quality. However, traditional disease diagnosis methods often rely on manual experience, and have disadvantages such as strong subjectivity, time-consuming and labor-intensive, and easy misdiagnosis.

[0003] The above contents are only used to assist in understanding the technical solution of the present invention and do not constitute an admission that the above contents are prior art. Summary of the invention

[0004] The purpose of the present invention is to provide a classification method, device, terminal, storage medium and computer program product for apple leaf diseases, so as to solve the problem that traditional apple leaf disease diagnosis relies on manual experience, is time-consuming, labor-intensive and has poor accuracy, and can achieve the effect of quickly identifying apple leaf diseases with good accuracy by obtaining an apple leaf disease classification model based on improved ConvNeXt training to identify apple leaf images to be detected.

[0005] The present invention provides a classification method for apple leaf diseases, comprising: collecting image data of apple leaves as samples; preprocessing the samples to obtain a training set and a test set; introducing an EnhancedCBAM attention mechanism to construct an improved ConvNeXt network as a new ConvNeXt network; using the training set to train the new ConvNeXt network to obtain a trained apple leaf disease classification model; using the test set to test the trained apple leaf disease classification model to obtain a revised apple leaf disease classification model; acquiring image data of apple leaves to be detected; and using the revised apple leaf disease classification model to perform detection to obtain the disease type of the apple leaves to be detected.

[0006] In some implementations, preprocessing the samples to obtain a training set and a test set includes: performing a data enhancement operation on the samples to obtain an enhanced data set; and dividing the enhanced data set to obtain the training set and the test set.

[0007] In some embodiments, data enhancement operations are performed on the samples to obtain an enhanced data set, including: using a preset mask shape function to randomly add a mask to the samples to obtain a mask data set; wherein the parameters of the mask shape function are different disease types obtained by analyzing preset apple leaf features; wherein the apple leaf features include at least one of the following: the shape, size and distribution of lesions; using a preset filling function to fill in the pattern program and detail loss of the image data of apple leaves at different shooting distances in the mask data set to obtain a filled data set; using a weighted average method to grayscale the filled data set according to the degree of influence of different color channels on the disease characteristics of apple leaves to obtain the enhanced data set.

[0008] In some embodiments, an EnhancedCBAM attention mechanism is introduced to construct an improved ConvNeXt network as a new ConvNeXt network, including: based on the original ConvNeXt network, constructing an improved 3223 architecture in ConvNeXt; based on the 3223 architecture in the improved ConvNeXt, constructing a G-ConvNeXtBlock module; in the G-ConvNeXtBlock module, introducing an EnhancedCBAM attention mechanism to obtain the improved ConvNeXt network as the new ConvNeXt network.

[0009] In some embodiments, based on the original ConvNeXt network, an improved 3223 architecture in ConvNeXt is constructed, including: based on the original ConvNeXt network, sequentially performing ConvNeXtBlock number adjustment, jump connection setting, position encoding and spatial pyramid pooling processing to construct the improved 3223 architecture in ConvNeXt; and / or, based on the improved 3223 architecture in ConvNeXt, a G-ConvNeXtBlock module is constructed, including: based on the improved 3223 architecture in ConvNeXt, a Gabor filter is introduced, and the connection mode and weight are set to construct the G-ConvNeXtBlock module.

[0010] In some embodiments, the EnhancedCBAM attention mechanism includes: a channel attention mechanism and a spatial attention mechanism; in the G-ConvNeXtBlock module, the EnhancedCBAM attention mechanism is introduced to obtain the improved ConvNeXt network as the new ConvNeXt network, including: in the G-ConvNeXtBlock module, the channel attention mechanism is introduced to analyze the channel information of the feature maps of different disease types to obtain a communication information network; in the channel information model, the spatial attention mechanism is introduced to analyze the spatial position information of the feature maps of different disease types to obtain a spatial position information network, the new ConvNeXt network.

[0011] Matching the above method, the present invention provides an apple leaf disease classification device on the other hand, comprising: an acquisition unit, configured to collect image data of apple leaves as samples; a control unit, configured to preprocess the samples to obtain a training set and a test set; the control unit is also configured to introduce an EnhancedCBAM attention mechanism to construct an improved ConvNeXt network as a new ConvNeXt network; the control unit is also configured to use the training set to train the new ConvNeXt network to obtain a trained apple leaf disease classification model; the control unit is also configured to use the test set to test the trained apple leaf disease classification model to obtain a revised apple leaf disease classification model; the acquisition unit is also configured to acquire image data of apple leaves to be detected; the control unit is also configured to use the revised apple leaf disease classification model for detection to obtain the disease type of the apple leaves to be detected.

[0012] Matching the above-mentioned device, the present invention further provides a terminal on the other hand, including: the classification device for apple leaf diseases mentioned above.

[0013] In accordance with the above method, the present invention provides a storage medium on the other hand, wherein the storage medium includes a stored program, wherein when the program is running, the device where the storage medium is located is controlled to execute the above-mentioned classification method for apple leaf diseases.

[0014] In accordance with the above method, the present invention further provides a computer program product, comprising a computer program, which, when executed by a processor, implements the steps of the above-mentioned method for classifying apple leaf diseases.

[0015] Therefore, the scheme of the present invention collects image data of apple leaves as samples, and obtains a training set and a test set after preprocessing the samples; constructs a 3223 architecture in the improved ConvNeXt, constructs a G-ConvNeXtBlock module, introduces the EnhancedCBAM attention mechanism, and builds a new ConvNeXt network; uses the training set to train the new ConvNeXt network to obtain an apple leaf disease classification model; uses the test set to test the trained apple leaf disease classification model, and according to the test result, the trained apple leaf disease classification model is corrected to obtain a corrected apple leaf disease classification model; uses the corrected apple leaf disease classification model to identify the apple leaf image to be detected, and obtains a classification recognition result; thus, by using the apple leaf disease classification model obtained by training based on the improved ConvNeXt to identify the apple leaf image to be detected, it is possible to quickly identify apple leaf diseases with good accuracy.

[0016] Other features and advantages of the present invention will be set forth in the description which follows, and in part will be apparent from the description, or may be learned by practice of the present invention.

[0017] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] Figure 1 A schematic diagram of a flow chart of an embodiment of a method for classifying apple leaf diseases of the present invention;

[0019] Figure 2 A schematic diagram of a flow chart of an embodiment of pre-processing the sample in the method of the present invention;

[0020] Figure 3 It is a flowchart of an embodiment of performing data enhancement operation on the sample in the method of the present invention;

[0021] Figure 4 A schematic diagram of a flow chart of an embodiment of constructing an improved ConvNeXt network in the method of the present invention;

[0022] Figure 5 A flow chart of an embodiment of introducing the EnhancedCBAM attention mechanism into the method of the present invention;

[0023] Figure 6 It is a structural schematic diagram of an embodiment of a device for classifying apple leaf diseases of the present invention;

[0024] Figure 7 A flowchart of a classification method for apple leaf diseases based on improved ConvNeXt;

[0025] Figure 8 A schematic diagram of the model structure of a classification method for apple leaf diseases based on improved ConvNeXt and a schematic diagram of the G-ConvNeXt structure;

[0026] Fig. 9 Schematic diagram of the structure of the enhanced attention mechanism designed for an apple leaf disease classification method based on improved ConvNeXt.

[0027] In conjunction with the accompanying drawings, the reference numerals in the embodiments of the present invention are as follows:

[0028] 102 - acquisition unit; 104 - control unit. DETAILED DESCRIPTION

[0029] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the specific embodiments of the present invention and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0030] Considering that the traditional diagnosis of apple leaf diseases relies on manual experience, it is time-consuming, labor-intensive and has poor accuracy. In addition, with the expansion of apple planting scale and the increase in the number of diseases, traditional methods can no longer meet the needs of large-scale and efficient disease monitoring.

[0031] Although deep learning technology has made significant progress in the field of image recognition in recent years, its application in apple leaf disease classification still faces some challenges: first, there are many types of apple leaf diseases, and different diseases manifest themselves in different ways on the leaves. For example, the shape, size, color and other characteristics of the lesions vary significantly, which places high demands on the recognition accuracy of the disease classification model; second, apple leaf images are affected by factors such as lighting, shooting angle, and background, which can easily lead to a decrease in image quality, further increasing the difficulty of disease identification; finally, existing disease classification models may have limitations in feature extraction and classification algorithms, making it difficult to fully capture the subtle features of the disease, resulting in poor classification results.

[0032] For example, existing disease classification models have the following limitations in feature extraction and classification algorithms: traditional CNN models are difficult to effectively capture the subtle texture features of diseases, and have poor recognition effects on small and dispersed lesions; they lack effective capture of the spatial distribution characteristics of diseases and have poor adaptability to lesions of different scales; existing attention mechanisms do not pay enough attention to small-scale diseases and have limited ability to extract local detail features.

[0033] Therefore, it is particularly important to develop a more accurate, efficient and adaptable classification method for apple leaf diseases. Therefore, the scheme of the present invention proposes a classification method for apple leaf diseases, specifically a classification method for apple leaf diseases based on improved ConvNeXt. CALDNet enhances texture feature extraction by introducing Gabor filters, designs 3223Network structure and spatial pyramid pooling to improve spatial feature processing capabilities, and optimizes the attention mechanism to enhance the ability to identify small-scale diseases.

[0034] According to an embodiment of the present invention, a classification method for apple leaf diseases is provided, such as Figure 1 The flowchart of an embodiment of the method of the present invention is shown in FIG. The classification method of apple leaf diseases may include: steps S110 to S170.

[0035] In step S110 , image data of apple leaves (such as pictures of apple leaves) are collected as samples.

[0036] In step S120, the samples are preprocessed to obtain a training set and a test set.

[0037] At step S130, the EnhancedCBAM attention mechanism is introduced to construct an improved ConvNeXt network as a new ConvNeXt network.

[0038] In step S140, the new ConvNeXt network is trained using the training set to obtain a trained apple leaf disease classification model.

[0039] In step S150, the trained apple leaf disease classification model is tested using the test set to obtain a revised apple leaf disease classification model.

[0040] In step S160, image data of the apple leaf to be detected is obtained.

[0041] In step S170, the modified apple leaf disease classification model is used to perform detection to obtain the disease type of the apple leaf to be detected.

[0042] The apple leaf disease classification scheme based on improved ConvNeXt proposed in the solution of the present invention significantly improves the accuracy and efficiency of disease identification. Through refined sample preprocessing, optimized network architecture (such as 3223 architecture, G-ConvNeXtBlock module) and introduction of EnhancedCBAM attention mechanism, it can more accurately capture disease characteristics and enhance the model's recognition ability for multi-scale and multi-type diseases; at the same time, through quantitative analysis and parameter optimization, the stability and generalization of the model in the training process are ensured, and ultimately the accuracy and practicability of disease classification are improved, providing strong support for the precise prevention and control of apple leaf diseases.

[0043] In some implementations, the specific process of preprocessing the samples to obtain the training set and the test set in step S120 is described in the following exemplary embodiments.

[0044] Combine the following Figure 2 The flowchart of an embodiment of pre-processing the sample in the method of the present invention further illustrates the specific process of pre-processing the sample in step S120, including: step S210 to step S220.

[0045] Step S210, performing data enhancement operation on the sample to obtain an enhanced data set.

[0046] Step S220, dividing the enhanced data set to obtain the training set and the test set.

[0047] In the solution of the present invention, the data augmentation operation needs to be performed before the data set is divided to ensure that the augmented data can be reasonably distributed in the training set, the validation set, and the test set.

[0048] In some implementations, the specific process of performing a data enhancement operation on the sample in step S210 to obtain an enhanced data set is described in the following exemplary embodiments.

[0049] Combine the following Figure 3 The flowchart of an embodiment of performing data enhancement operation on the sample in the method of the present invention further illustrates the specific process of performing data enhancement operation on the sample in step S210, including: steps S310 to S330.

[0050] Step S310, using a preset mask shape function, randomly add a mask to the sample to obtain a mask data set; wherein the parameters of the mask shape function are different disease types obtained by analyzing preset apple leaf characteristics; wherein the apple leaf characteristics include at least one of the following: shape, size and distribution of lesions; the expression of the preset mask shape function is as shown in formula (1).

[0051] Step S320, using a preset filling function, fills in the pattern program and detail loss of the image data of the apple leaf at different shooting distances in the mask data set to obtain a filled data set; the expression of the preset filling function is as shown in formula (2).

[0052] Step S330, using a weighted average method, grayscale processing is performed on the filled data set according to the degree of influence of different color channels on the disease characteristics of apple leaves to obtain the enhanced data set.

[0053] The solution of the present invention provides a classification method for apple leaf diseases based on improved ConvNeXt, and relates to the technical field of application of deep learning in agricultural image recognition. Figure 7 The figure is a flow chart of a classification method for apple leaf diseases based on improved ConvNeXt. Figure 7 As shown in the figure, the classification method of apple leaf diseases based on improved ConvNeXt includes:

[0054] Step 1: Sample preprocessing: including data enhancement operations and data set division; wherein the data enhancement operations include randomly adding masks, image filling and grayscale conversion.

[0055] Randomly add masks: The mask shape function is M(x,y), and its parameters are determined according to the analysis of the characteristics of apple leaf diseases. For different disease types, the characteristics of the shape, size and distribution of the lesions are analyzed, and these characteristics are quantified as the parameters of the mask function. The lesions of a certain disease are elliptical, with the major semi-axis a and the minor semi-axis b. The mask shape function can be expressed as:

[0056]

[0057] Where (x0, y0) is the center position of the lesion, which is determined by the distribution law of the lesions.

[0058] Image filling: The filling function is F(x,y), and its parameters are determined based on the study of the image characteristics of apple leaves at different shooting distances. By analyzing the characteristics of the blur degree and detail loss of the image at different shooting distances, these characteristics are quantified as the parameters of the filling function. In the simulation of long-distance shooting, the image blur degree is proportional to the distance. Assuming the distance is d and the blur coefficient is k, the filling function can be expressed as:

[0059] F(x,y)=k·d·f(x,y) (2).

[0060] Where f(x,y) is the original image function.

[0061] Grayscale: Use weighted average method, assuming that the color channels are R, G, and B, and the weights are w R ,wG ,w B , and w R +w G +w B =1, the weight is determined according to the influence of different color channels on the disease characteristics. The disease is more obvious in the red channel, so w R Relatively large, the grayscale pixel value P gray The calculation formula is:

[0062] P gray =w R ×R+w G ×G+w B ×B (3).

[0063] The data set division: the apple leaf disease data set is divided into a test set and a training set according to a set ratio, and the size of the training set is changed to a set size. The data set label types include healthy leaves, black spot, black rot, mosaic disease, gray spot, brown spot, and rust.

[0064] In step one, in the sample preprocessing step, for the random mask addition operation, the parameter determination of the mask shape function M(x, y) is based on the quantitative analysis of the disease characteristics of apple leaves. By measuring the shape parameters of lesions of different disease types and the distribution law of the center position of the lesions, these data are converted into parameters of the mask function to ensure that the mask can accurately simulate the disease occlusion. For the image filling operation, the parameter determination of the filling function F(x, y) is based on the quantitative analysis of the image characteristics of apple leaves at different shooting distances. By measuring the blurring degree and detail loss of the image at different shooting distances, these data are converted into parameters of the filling function to ensure that the filling can accurately simulate the long-distance shooting effect. For the grayscale operation, the weight w R ,w G ,w B The determination is based on the quantitative analysis of the influence of different color channels on disease characteristics. By analyzing the performance of different disease types in different color channels, these analysis results are converted into weight values ​​to ensure that grayscale can better highlight the disease characteristics.

[0065] In the scheme of the present invention, three data enhancement operations are adopted, namely, randomly adding masks, image filling and graying. Randomly adding masks simulates the situation where leaves are blocked in the actual environment by adding occluded areas to the original image, thereby improving the model's recognition ability of partial occlusion; image filling enhances the model's adaptability to different shooting distances by simulating the effect of long-distance shooting; graying strengthens the learning of texture features by reducing the dependence on color features. The three operations cooperate with each other to jointly improve the generalization ability and robustness of the model in complex actual environments.

[0066] The solution of the present invention adopts data enhancement technology in the sample preprocessing stage, including randomly adding masks and image filling. These operations simulate the occlusion and blur that may be encountered in actual shooting, thereby enhancing the generalization ability of the model. In addition, the reasonable setting of weights in the grayscale process enables the model to better highlight the characteristics of the disease, further improving the adaptability of the model under different lighting conditions. Through these measures, the method can not only perform well on the training set, but also maintain a high classification accuracy on the unseen test set, showing good generalization performance.

[0067] In some embodiments, the EnhancedCBAM attention mechanism is introduced in step S130 to construct an improved ConvNeXt network. For the specific process of the new ConvNeXt network, please refer to the following exemplary description.

[0068] Combine the following Figure 4 The flowchart of an embodiment of constructing an improved ConvNeXt network in the method of the present invention further illustrates the specific process of constructing the improved ConvNeXt network in step S130, including: step S410 to step S430.

[0069] Step S410, based on the original ConvNeXt network, construct the 3223 architecture in the improved ConvNeXt.

[0070] Step S420: construct a G-ConvNeXtBlock module based on the 3223 architecture in the improved ConvNeXt.

[0071] Step S430, introducing the EnhancedCBAM attention mechanism into the G-ConvNeXtBlock module to obtain the improved ConvNeXt network as the new ConvNeXt network.

[0072] The G-ConvNeXtBlock module and 3223 structure constructed by the solution of the present invention form an organic coordination with the sample preprocessing step: G-ConvNeXtBlock introduces Gabor filter as convolution kernel, which enhances the texture feature extraction capability of the preprocessed image, especially has a stronger capture capability of edge and texture information in the grayscaled sample; the 3223 structure improves the context information retention capability of the random mask occluded area through skip connection and spatial pyramid pooling, and enhances the adaptive feature extraction capability under different filling scales; at the same time, the point convolution design in G-ConvNeXtBlock cooperates with the streamlined design of the 3223 structure, which jointly avoids overfitting of the enhanced data and ensures the generalization performance of the model on a rich preprocessing data set.

[0073] In the scheme of the present invention, the EnhancedCBAM attention mechanism forms a systematic coordination with the preceding steps: for the feature changes caused by masking, filling and graying in sample preprocessing, the convolution layer is used to replace the MLP through the improved channel attention mechanism (Enhanced CAM) to enhance the nonlinear expression ability of the preprocessed features; for the multi-scale features extracted by the jump connection and SPP module in the 3223 structure, parallel average pooling and maximum pooling operations are designed to capture richer spatial information; for the texture features extracted by the Gabor filter in the G-ConvNeXtBlock, the spatial attention mechanism is optimized based on the output of the channel attention by serial connection, thereby improving the model's recognition ability for small and scattered lesions in the preprocessed data while maintaining lightweight.

[0074] In some embodiments, in step S410, based on the original ConvNeXt network, an improved 3223 architecture in ConvNeXt is constructed, including: based on the original ConvNeXt network, sequentially performing ConvNeXtBlock quantity adjustment, skip connection setting, position encoding and spatial pyramid pooling processing to construct the improved 3223 architecture in ConvNeXt.

[0075] like Figure 7 As shown, the classification method of apple leaf diseases based on the improved ConvNeXt also includes:

[0076] Step 2: Build the improved 3223 architecture in ConvNeXt: including ConvNeXtBlock number adjustment, skip connection setting, position encoding and spatial pyramid pooling, such as Figure 8 shown. Figure 8 A schematic diagram of the model structure of an apple leaf disease classification method based on improved ConvNeXt and a schematic diagram of the G-ConvNeXt structure.

[0077] The ConvNeXtBlock number adjustment: the number of ConvNeXtBlocks in the four stages of the original ConvNeXt is adjusted from (3, 3, 9, 3) to (3, 2, 2, 3).

[0078] The jump connection setting: five jump connections are integrated in the 3223 architecture. The starting layer and the end layer of the jump connection are determined based on the analysis of the impact on model information transmission and feature extraction. The starting layer of the jump connection is set to The end layer is The connection weight matrix is The connection weight matrix elements are continuously adjusted and optimized through the back propagation algorithm during the model training process, with the goal of minimizing the model loss function, that is, where y ij is the true label, is the predicted label.

[0079] The position encoding: integrates absolute position encoding, which is obtained through learning and can be dynamically adjusted to match the size of the input feature map. Let the position encoding function be PE(x,y), and its parameters are determined by learning the size and position information of the input feature map. For an n×m input feature map, the position encoding function can be expressed as:

[0080]

[0081] where a kl and b kl are the learned parameters.

[0082] Position encoding is achieved by generating a unique code for each spatial position, which is then directly added to the corresponding feature map, dynamically generating a position encoding tensor for each feature map that matches its size. Unlike the traditional sine and cosine function generation method, the position encoding tensor is randomly initialized through a Gaussian distribution and has a shape of (C, H, W), where C represents the number of channels, H represents the height, and W represents the width. The introduction of position encoding can embed spatial coordinate information directly into the feature map, allowing the model to better understand the positional dependency and spatial layout in the image. In this way, even if the disease appears in different locations, the model can effectively distinguish them.

[0083] The spatial pyramid pooling: The spatial pyramid pooling layer can perform pooling at different scales (set to S1, S2, S3), and the spatial pyramid pooling operation function is set to SPP (f, S), where f is the input feature map, S is the pooling scale, and for scale S i , let the pooling area be R ij (j represents different area numbers), weight is w ij , and∑ j w ij =1, the feature map after pooling is:

[0084] SPP(f,S i )=∑ j w ij ×Pooling(f,R ij ,S i ) (5).

[0085] Pooling refers to the pooling operation. The pooling area division method and weight allocation are determined by the optimization algorithm to maximize the model's ability to capture features of different scales.

[0086] The core idea of ​​the SPP layer is to capture the multi-scale spatial information of the input feature map through multi-scale pooling operations. The SPP layer receives a feature map as input, and then divides the feature map into grids of different sizes through multiple parallel max pooling operations. These grid sizes usually follow a pyramid structure, such as 1×1, 2×2, and 4×4. The maximum pooling operation is performed within each grid to obtain feature representations of different resolutions. This multi-scale pooling mechanism enables the SPP layer to extract local and global features at the same time: smaller pooling grids (such as 1×1) retain more local detail information. Larger pooling grids (such as 4×4) capture global context information. In the 3223 structure, the SPP layer is placed in the deeper layers of the network to enhance feature expression. The model can focus on disease features of different sizes at the same time, improving the model's ability to recognize complex disease patterns.

[0087] In step 2, in the step of constructing the 3223 architecture in the improved ConvNeXt, the starting layer of the jump connection and the end point layer The selection is based on the quantitative analysis of information transfer and feature extraction of the model. By analyzing the feature correlation between different layers and the importance of information transfer, these analysis results are converted into the starting and ending layers of the jump connection, and the connection weight matrix The element adjustment is based on the minimization goal of the model loss function. By calculating the model loss function and adjusting the elements of the connection weight matrix according to its changing trend, it is ensured that the jump connection can better promote the transmission of internal information and feature extraction of the model. The parameter determination of the position encoding function PE (x, y) is based on the learning of the size and position information of the input feature map. By continuously learning the size and position information of the input feature map during the training process, these learning results are converted into parameters of the position encoding function to ensure that the position encoding can be dynamically adjusted to match the size of the input feature map. The pooling area division method and weight distribution of the spatial pyramid pooling layer are based on the goal of maximizing the model's ability to capture features of different scales. Through the optimization algorithm, the analysis results are converted into pooling area division methods and weight distribution to ensure that the spatial pyramid pooling layer can better enhance the model's ability to capture features of different scales.

[0088] In the scheme of the present invention, the 3223 architecture design is closely related to the sample preprocessing step: in order to solve the partial occlusion problem caused by randomly adding masks in the preprocessing, a jump connection mechanism is designed to maintain the continuity of context information; in order to solve the distance difference caused by image filling, spatial pyramid pooling (SPP) is introduced to enhance the adaptability to features of different scales; for the feature expression after grayscale, position encoding is used to enhance spatial information perception, and the streamlined 3223 structure is used to avoid overfitting of enhanced data, thereby realizing the complementary advantages of preprocessed data and network architecture.

[0089] In some embodiments, in step S420, a G-ConvNeXtBlock module is constructed based on the 3223 architecture in the improved ConvNeXt, including: based on the 3223 architecture in the improved ConvNeXt, a Gabor filter is introduced, and a connection method and weight are set to construct a G-ConvNeXtBlock module.

[0090] like Figure 7 As shown, the classification method of apple leaf diseases based on improved ConvNeXt also includes: Step three, constructing a G-ConvNeXtBlock module: including the introduction of Gabor filters and the connection method and weight setting.

[0091] The Gabor filter is introduced as follows: a two-dimensional Gabor filter is introduced as a convolution kernel. The two-dimensional Gabor filter g(x, y) is a complex transformation of a two-dimensional Gaussian function multiplied by a sine and cosine function, that is:

[0092]

[0093] Where σ is the variance of the Gaussian function, and f is a fixed spatial frequency. For different disease types and image features, these parameters are further adjusted. For a disease with finer texture, it is necessary to reduce σ and increase f. Different Gabor filter kernels can be obtained by transforming parameters σ1, σ2, f1, and f2. Suppose the convolution kernel is K Gabor (x,y), which is obtained by adjusting g(x,y) according to the parameters.

[0094] The connection method and weight setting: The connection method with the output feature map of the previous layer adopts a specific weighted summation method. Let the output feature map of the previous layer be f prev , the connection weight is w conn , then the G-ConvNeXtBlock module input is f in =w conn ×f prev The connection weights are continuously adjusted and optimized through the back propagation algorithm in the model training process, with the goal of maximizing the model's ability to capture image texture information, namely:

[0095] max∑ x,y Texture(x,y)·f in (x,y), (7).

[0096] Where Texture(x,y) is the image texture feature function.

[0097] In step 3, in the step of constructing the G-ConvNeXtBlock module, the determination of the parameters σ1, σ2, f1 and f2 of the two-dimensional Gabor filter is based on the quantitative analysis of the texture characteristics of the apple leaf image. By analyzing the texture characteristics of lesions of different disease types, these analysis results are converted into parameters of the Gabor filter to ensure that the filter can better capture the texture information. The connection weight w conn The adjustment is based on maximizing the model's ability to capture image texture information. By calculating the model's ability to capture image texture information and adjusting the connection weights w according to its changing trend, conn , ensuring that the Gabor filter can effectively pass texture information to subsequent layers for processing.

[0098] In the scheme of the present invention, in the 3223 architecture step of constructing the improved ConvNeXt, the pooling area division method and weight distribution of the spatial pyramid pooling layer are based on the quantitative analysis of the characteristics of the apple leaf disease image. By analyzing the shape, size and distribution characteristics of lesions of different disease types, these analysis results are converted into pooling area division methods and weight distribution, ensuring that the spatial pyramid pooling layer can better enhance the model's ability to capture features of different scales.

[0099] The solution of the present invention significantly improves the accuracy of apple leaf disease classification by introducing an improved ConvNeXt architecture, especially adjusting the number of ConvNeXtBlocks and setting jump connections. The reasonable setting of jump connections promotes the effective transmission of information within the model and feature extraction, so that the model can capture disease characteristics more comprehensively. At the same time, the introduction of the spatial pyramid pooling layer enhances the model's ability to capture features of different scales, further improving the accuracy of classification. These improvements enable the method to more accurately identify disease types in complex and changeable disease images, providing strong support for the timely prevention and control of apple leaf diseases.

[0100] The solution of the present invention introduces a two-dimensional Gabor filter as a convolution kernel when constructing the G-ConvNeXtBlock module. The filter can more effectively capture the texture information in the image, which is particularly important for the disease classification task. At the same time, the introduction of the EnhancedCBAM attention mechanism enables the model to pay more attention to the features useful for the classification task, reducing the interference of useless information, thereby speeding up the training speed of the model. In addition, by optimizing hyperparameters such as learning rate, momentum and regularization parameters, the method ensures the performance of the model while also achieving rapid convergence of the training process, thereby improving the overall efficiency of model training. These improvements enable the method to be deployed and iterated faster in practical applications, providing a strong guarantee for real-time monitoring and early warning of apple leaf diseases.

[0101] In some embodiments, the EnhancedCBAM attention mechanism includes: a channel attention mechanism and a spatial attention mechanism;

[0102] In step S430, the EnhancedCBAM attention mechanism is introduced into the G-ConvNeXtBlock module to obtain the improved ConvNeXt network. For the specific process of the new ConvNeXt network, please refer to the following exemplary description.

[0103] Combine the following Figure 5 The flowchart of an embodiment of introducing the EnhancedCBAM attention mechanism in the method of the present invention is shown, which further illustrates the specific process of introducing the EnhancedCBAM attention mechanism in step S430, including: step S510 to step S520.

[0104] Step S510, in the G-ConvNeXtBlock module, the channel attention mechanism is introduced to analyze the channel information of the feature maps of different disease types to obtain a communication information network.

[0105] Step S520, introducing the spatial attention mechanism into the channel information model, analyzing the spatial position information of the feature maps of different disease types, and obtaining a spatial position information network, the new ConvNeXt network.

[0106] like Figure 7 As shown, the classification method of apple leaf diseases based on the improved ConvNeXt also includes:

[0107] Step 4: Introduce EnhancedCBAM attention mechanism: including channel attention mechanism and spatial attention mechanism, such as Fig. 9 shown. Fig. 9Schematic diagram of the structure of the enhanced attention mechanism designed for an apple leaf disease classification method based on improved ConvNeXt.

[0108] The channel attention mechanism: After each feature extraction stage, an enhanced channel attention mechanism is introduced. By performing global average pooling (AvgPool) and global maximum pooling (MaxPool) on the feature map, the feature map after global average pooling is set as f avg , the feature map after global maximum pooling is f max , and then process the pooled result through two fully connected layers (MLP). Suppose the weight matrix of the first fully connected layer is W1, the number of neurons is n1, the activation function is ReLU, and the output is f1=ReLU(W1×f avg +b1)(b1 is the bias, which can be optimized through training), the weight matrix of the second fully connected layer is W2, the number of neurons is n2, the activation function is Sigmoid, and the output is f2=Sigmoid(W2×f max +b2), and finally output the weight of each channel through a Sigmoid function, and set the final channel weight to w channel , then w chanenel =Sigmoid(f1+f2), the elements of weight matrices W1 and W2 are continuously adjusted and optimized through the back propagation algorithm in the model training process, with the goal of maximizing the model's ability to extract feature map channel information, that is, max∑ c ChannelInfo(c)·w channel (c), where ChannelInfo(c) is the channel information function.

[0109] The standard CBAM mainly consists of two sub-modules: Channel Attention Module (CAM) and Spatial Attention Module (SAM). In CAM, the input feature map F∈R^(C×H×W) is subjected to global average pooling and global maximum pooling, and then the channel attention weight is generated through a shared multi-layer perceptron (MLP). SAM generates the spatial attention weight by performing average pooling and maximum pooling on the feature map output by CAM in the channel dimension, and then performing a convolution operation.

[0110] Enhanced CBAM improves both CAM and SAM. The improved channel attention mechanism (Enhanced CAM) replaces the fully connected layer in MLP with a 1×1 convolution layer, effectively learning the complex relationship between channels while keeping the number of parameters low. Adding a ReLU activation function after the 1×1 convolution layer enhances the nonlinear expression ability of the model. The mathematical expression is:

[0111] MC(F)=σ(Conv1×1(AvgPool(F))+Conv1×1(MaxPool(F))) (8).

[0112] Among them, σ represents the Sigmoid activation function and Conv1×1 represents a 1×1 convolution operation.

[0113] Improved spatial attention mechanism (enhanced SAM): uses parallel average pooling and maximum pooling operations to capture richer spatial information. 3×3 Convolution Alternative 7×7 Convolution reduces the number of parameters and maintains the receptive field. The mathematical expression is:

[0114] MS(F)=σ(Conv3×3([AvgPool(F); MaxPool(F)])) (9).

[0115] Among them, ; represents the splicing operation in the channel dimension.

[0116] Connecting CAM and SAM in series allows the spatial attention mechanism to be optimized based on the output of channel attention. The overall mathematical expression is:

[0117]

[0118] in, Represents element-wise multiplication.

[0119] Through these improvements, enhanced CBAM can more effectively capture the subtle features of apple leaf diseases. By retaining spatial information, enhancing nonlinear expression capabilities, and optimizing the serial structure of the attention mechanism, enhanced CBAM significantly improves the model's ability to recognize small scattered lesions. Experimental results show that compared with standard CBAM, enhanced CBAM not only achieves higher accuracy in the apple leaf disease classification task, but also shows better generalization performance.

[0120] The spatial attention mechanism: by calculating the average and maximum value of the feature map, let the average value be m avg , the maximum value is m max After merging these two statistics, a convolution layer (with a convolution kernel size of d and no bias, the value of d is determined according to the need to capture spatial position information) is used to process the merged features. Assuming the convolution layer weight matrix is ​​W3, the feature map after convolution is f conv =W3×(m avg +m max )+b3 (b3 is bias, which can be optimized through training), and finally the weight of the spatial position is output through the Sigmoid function. Let the spatial position weight be wspace , then w space =Sigmoid(f conv ), the elements of the weight matrix W3 are continuously adjusted and optimized through the back propagation algorithm in the model training process, with the goal of maximizing the model's ability to capture spatial location information, that is:

[0121] max∑ x,y SpaceInfo(x,y)·w space (x,y), (11).

[0122] Where SpaceInfo(x,y) is the spatial information function.

[0123] In step 4, in the step of introducing the EnhancedCBAM attention mechanism, the number of neurons n1 and elements of the weight matrix W1 of the first fully connected layer in the channel attention mechanism are determined based on the quantitative analysis of the channel information of the feature map. By analyzing the channel information of the feature maps of different disease types, these analysis results are converted into the number of neurons and elements of the weight matrix of the first fully connected layer, ensuring that the first fully connected layer can better process the channel information. The number of neurons n2 and elements of the weight matrix W2 of the second fully connected layer are determined based on the quantitative analysis of the channel information of the feature map. By analyzing the channel information of the feature maps of different disease types, these analysis results are converted into the number of neurons and elements of the weight matrix of the second fully connected layer, ensuring that the second fully connected layer can better process the channel information; the elements of the convolutional layer weight matrix W3 in the spatial attention mechanism are determined based on the quantitative analysis of the spatial position information. By analyzing the spatial position information of the feature maps of different disease types, these analysis results are converted into elements of the convolutional layer weight matrix W3, ensuring that the convolutional layer can better process the spatial position information.

[0124] Step 5. Network construction: Using the original ConvNeXt network structure as a prototype, a new ConvNeXt network is built. During the construction process, the original network structure is modified and adjusted, including but not limited to adjusting the size, step size and padding parameters of the convolution kernel. These parameters are determined based on the characteristics and demand analysis of the apple leaf disease classification task.

[0125] In step five, in the network building step, the adjustment parameters of the original ConvNeXt network structure are based on the quantitative analysis of the apple leaf disease classification task. By analyzing the characteristics of the shape, size and distribution of lesions of different disease types, these analysis results are converted into network structure adjustment parameters to ensure that the network structure can better adapt to the apple leaf disease classification task.

[0126] Step 6. Network training: Use the training set to train the newly built ConvNeXt network. The back propagation gradient descent method is used in the training process. The learning rate is α and the momentum is β. The learning rate and momentum are determined through multiple experiments and optimizations, with the goal of minimizing the model loss function, that is, where y ij is the true label, In order to predict the label, the regularization method can be used to prevent the model from overfitting. The regularization parameter is set to λ, and its type and parameter selection are determined according to the analysis of model performance and overfitting. After training, the apple leaf disease classification and recognition model is obtained, and the trained apple leaf disease classification model is tested using an independent test set.

[0127] In step six, in the network training step, the determination of the learning rate α and the momentum β is based on the minimization target of the model loss function. By analyzing the loss function value of the model under different learning rate and momentum values, these analysis results are converted into learning rate and momentum values ​​to ensure that the learning rate and momentum can better promote model convergence. The selection of the regularization parameter λ is based on the quantitative analysis of the model performance and overfitting. By analyzing the performance and overfitting of the model under different regularization parameter values, these analysis results are converted into regularization parameter values ​​to ensure that the regularization parameter can better prevent model overfitting.

[0128] Step 7: Input the image to be detected into the apple leaf disease classification model for identification to obtain the classification identification result.

[0129] In step seven, in the step of inputting the image to be detected into the apple leaf disease classification model for identification, the preprocessing operation of the image before inputting the model is based on a quantitative analysis of the model input requirements and the image characteristics of apple leaf disease. By analyzing the model input requirements and the image characteristics of apple leaf disease, these analysis results are converted into image preprocessing operation parameters to ensure that the image preprocessing operation can better meet the model input requirements.

[0130] In the scheme of the present invention, in the entire classification method of apple leaf diseases based on improved ConvNeXt, the collaborative working mode between various modules and steps is based on the quantitative analysis of the overall performance of the model. By analyzing the impact of different modules and steps on the overall performance of the model, these analysis results are converted into a collaborative working mode to ensure that the various modules and steps can cooperate better and improve the overall performance of the model.

[0131] The following experiment is conducted on the classification of apple leaf diseases caused by black spot.

[0132] Step 1: Sample preprocessing includes: data enhancement operation.

[0133] Randomly add mask: By analyzing the characteristics of black spot disease, the parameters of the mask shape function M(x,y) are determined. Black spot disease lesions are usually circular or nearly circular. Assuming that their average diameter is D = 3mm, the mask shape function can be expressed as Where x0, y0) is the center position of the lesion, which can be determined according to the distribution law of the lesions. Assuming that the lesions are mostly concentrated in the edge area of ​​the leaf, set x0 = ±10mm (symmetric on the left and right edges), y0 = 0mm (along the long axis of the leaf). For each image in the training set, the specific position of the mask in the image is determined according to the corresponding lesion position information on the leaf, and then the mask is applied to the image to obtain the image data I after adding the mask masked , this image data I masked Will be passed to subsequent image fill operations.

[0134] Image filling: Analyze the characteristics of the image of the black spot leaf taken at a long distance and determine the parameters of the filling function F(x,y). Assume that the shooting distance is d = 5m, the image blur is proportional to the distance, and the blur coefficient is k = 0.05. Then the filling function can be expressed as F(x,y) = 0.05 × 5 × f(x,y) = 0.25f(x,y), where f(x,y) is the original image function. masked The image data is filled with the filling function F(x,y) to obtain the filled image data I filled =F(I masked ), I filled Will continue to be passed to the grayscale operation.

[0135] Grayscale: Since black spot disease may have specific manifestations in certain color channels, its influence on different color channels is analyzed to determine the weights. Let w R =0.4, w G =0.3, w B =0.3, then the grayscale pixel value P gray =0.4×R+0.3×G+0.3×B. filled , apply the grayscale formula pixel by pixel to obtain the grayscale image data I gray =Gray(I filled ), where Gray represents the grayscale operation, I gray The final data after sample preprocessing is passed to the dataset partitioning step.

[0136] Dataset division: The apple leaf disease dataset containing black spot is divided into training set, test set and validation set in a ratio of 7:2:1, and the image size in the training set is uniformly adjusted to 224×224; grayAfter the above data augmentation operation, it is passed to the subsequent model building and training steps. Specifically, during the training process, each image data will be passed in batches to the 3223 architecture step in building the improved ConvNeXt.

[0137] Step 2: Build the 3223 architecture in the improved ConvNeXt.

[0138] Adjustment of the number of ConvNeXtBlocks: The number of ConvNeXtBlocks in the four stages of the original ConvNeXt is adjusted from (3, 3, 9, 3) to (3, 2, 2, 3). The adjusted architecture will receive the training set image data I passed from the dataset partitioning step. gray , and process it.

[0139] Skip connection settings: Determine the starting and ending layers of the five skip connections. For example, the first skip connection starts from the middle layer in the first layer that is related to the texture features of the lesions. Connect to the third layer which further processes these features more effectively Let the connection weight matrix be Its initial value is set randomly. During the model training process, for each forward propagation of data, when the data is passed from the starting layer to the end layer, the connection weight matrix is ​​adjusted using the back propagation algorithm according to the current model prediction error (obtained by comparing the predicted label and the true label). elements to minimize the model loss function

[0140] where y ij is the true label, To predict the label, the data is transmitted according to the set connection method when passing through the jump connection, and the weight matrix is ​​continuously updated to optimize information transmission.

[0141] Position encoding: The position encoding function is where a kl and b kl To learn the parameters, during the model training process, for each input feature map (size is 224×224), its position code PE(x,y) is calculated, and the position code is added to the pixel value of the corresponding position of the input feature map to obtain the feature map data after adding the position code. This data will continue to be passed to the next layer for processing, that is, the spatial pyramid pooling operation.

[0142] Spatial pyramid pooling: The spatial pyramid pooling layer performs pooling on three scales S1 = 4 × 4, S2 = 8 × 8, and S3 = 16 × 16. For scale S1, the pooling area division method and weight distribution are optimized. Suppose the pooling area is R1j (j represents different area numbers), weight is w 1j , and∑ j w 1j =1;

[0143] For each feature map data processed in the previous step (feature map data after adding position encoding), a spatial pyramid pooling operation is performed on it according to the size of its feature map and the set pooling scale. For example, for scale S1, calculate SPP(f,S i )=∑ j w 1j ×Pooling(f,R 1j ,4×4), where f is the input feature map data, Pooling represents the pooling operation, and the pooled feature map data is passed to the next layer for processing. This data will be used as the input of the step of building the G-ConvNeXtBlock module.

[0144] Step 3: Build the G-ConvNeXtBlock module.

[0145] Introduction of Gabor filter: For the black spot leaf image, the lesion texture is relatively regular, and the parameters of the two-dimensional Gabor filter are determined as σ1 = 2.0, σ2 = 2.5, f1 = 0.1, f2 = 0.15. Different Gabor filter kernels K are obtained through these parameters. Gabor (x,y), which is given by According to the parameter adjustment, the module receives the feature map data transmitted from the spatial pyramid pooling step and performs filtering on it.

[0146] Connection method and weight setting: The output feature map of the previous layer is connected using a specific weighted summation method. Suppose the output feature map of the previous layer is f prev , the connection weight is w conn =0.8, then the G-ConvNeXtBlock module input is f in =0.8×f prev ; During the model training process, for each forward propagation of data, when the data is from f prev Passed to f in When the connection weight w is adjusted according to the current model prediction error, the back propagation algorithm is used conn , with the goal of maximizing the model's ability to capture image texture information, that is, max∑ x,y Texture(x,y)·f in (x, y), where Texture(x, y) is the image texture feature function, and the processed feature map data will be passed to the step of introducing the EnhancedCBAM attention mechanism.

[0147] Step 4: Introduce EnhancedCBAM attention mechanism.

[0148] Channel attention mechanism: By performing global average pooling (AvgPool) and global maximum pooling (MaxPool) on the feature map, let the feature map after global average pooling be f avg , the feature map after global maximum pooling is f max ; For each input feature map data (feature map data from the G-ConvNeXtBlock module after processing), first calculate the global average pooling and global maximum pooling results. Suppose the weight matrix of the first fully connected layer is W1, the number of neurons is n1=64, and the activation function is ReLU, then the output f1=ReLU(W1×f avg +b1)(b1 is the bias, which can be optimized through training), the weight matrix of the second fully connected layer is W2, the number of neurons is n2=32, and the activation function is Sigmoid, then the output f2=Sigmoid(W2×f max +b2); Finally, a Sigmoid function is used to output the weight of each channel, and the final channel weight is set to w channel , then w chanenel =Sigmoid(f1+f2). During the model training process, the back propagation algorithm is used to adjust the elements of the weight matrices W1 and W2 according to the current model prediction error, with the goal of maximizing the model's ability to extract feature map channel information, that is, max∑ c ChannelInfo(c)·w channel (c), where ChannelInfo(c) is the channel information function, and the processed feature map data (the feature map data after considering the channel weight adjustment) will be passed to the spatial attention mechanism step.

[0149] Spatial attention mechanism: By calculating the average and maximum value of the feature map, let the average value be m avg , the maximum value is m max After merging these two statistics, a convolutional layer (with a kernel size of d = 7 and no bias) is used to process the merged features. Assuming the convolutional layer weight matrix is ​​W3, the feature map after convolution is f conv =W3×(m avg +m max )+b3 (b3 is bias, which can be optimized through training); for each input feature map data (feature map data after channel attention mechanism processing), calculate the result of the spatial attention mechanism, and finally output the weight of the spatial position through the Sigmoid function. Let the spatial position weight be w space , then w space=Sigmoid(f conv ), during the model training process, the back propagation algorithm is used to adjust the elements of the weight matrix W3 according to the current model prediction error, with the goal of maximizing the model's ability to capture spatial location information, that is, max∑ x,y SpaceInfo(x,y)·w space (x, y), where SpaceInfo(x, y) is the spatial information function, and the processed feature map data (the feature map data after considering the spatial weight adjustment) will be passed to the network construction and training steps.

[0150] Step 5: Network construction and training.

[0151] Network construction: A new ConvNeXt network is constructed based on the original ConvNeXt network structure. During the construction process, the original network structure is modified and adjusted, such as adjusting the size of the convolution kernel, step size, padding and other parameters. These parameters are determined based on the characteristics and demand analysis of the black spot classification task; the data processed by the previous steps (such as the feature map data processed by the EnhancedCBAM attention mechanism) is passed to the corresponding layer for network construction.

[0152] Network training: The new ConvNeXt network was trained using the training set. The back-propagation gradient descent method was used during the training process, with a learning rate of α = 0.001 and a momentum of β = 0.9. The L2 regularization method was used to prevent the model from overfitting, and the regularization parameter λ = 0.0001. In each training iteration, for each image data in the training set, it was forward-propagated through each layer of the network to obtain a predicted label, and then the model loss function was calculated based on the predicted label and the true label. The back-propagation algorithm was used to adjust the parameters of each layer of the network according to the model loss function (including the parameters after the number of ConvNeXtBlocks was adjusted, the jump connection weight matrix, the position encoding parameters, the spatial pyramid pooling parameters, the G-ConvNeXtBlock module connection weights, the weight matrix of the EnhancedCBAM attention mechanism, etc.), until the loss function of the model converged, and a trained apple leaf disease classification and recognition model was obtained.

[0153] Step 6: Classify identification results and monitor.

[0154] Classification and recognition: The black spot leaf images to be detected are first subjected to the same data preprocessing operations as the training set images (including random addition of masks, image filling and grayscale, and resizing to 224×224), and then the preprocessed image data are input into the trained model for recognition.

[0155] Monitoring: During the training process, the model performance was evaluated by monitoring the accuracy, recall and F1 value of the model on the validation set. For each image in the validation set, it was input into the model for prediction after the same data preprocessing operation as the training set image to obtain the predicted label. Then, the accuracy, recall and F1 value were calculated based on the predicted label and the true label. As the training progressed, the accuracy gradually improved. When it reached a stable state, the final accuracy on the validation set was 95%, the recall was 90%, and the F1 value was 94.5%, indicating that the model had a good classification and recognition effect on black spot disease.

[0156] Similarly, experiments were conducted on the classification of apple leaf diseases such as black spot, brown spot, gray spot, healthy, mosaic, and rust, which also verified that the model has good classification and recognition effects. The experimental data are shown in Table 1. The disease types from top to bottom are black spot, black star, brown spot, gray spot, healthy, mosaic, and rust. The experimental data from left to right are precision, recall, F1 score, average precision, average recall, average F1 score, parameter quantity, and FPS frame / s.

[0157] Table 1

[0158]

[0159] In the scheme of the present invention, starting from sample preprocessing, data enhancement (including random mask addition, image filling and graying) is performed on the black scab apple leaf image and the data set is divided. Then, the 3223 architecture in the improved ConvNeXt is constructed, which includes the adjustment of the number of ConvNeXtBlocks, the setting of jump connections, position encoding and spatial pyramid pooling. The data are transmitted sequentially between each step and the relevant parameters are continuously optimized during the training process. Then, the Gabor filter is introduced through the G-ConvNeXtBlock module to further process the image texture information. The data is then passed to the EnhancedCBAM attention mechanism to analyze the features from the two dimensions of channel and space. The image is processed to improve the ability to extract disease features. Finally, a trained model is obtained after network construction and training, which is used to classify and identify the preprocessed images to be detected, and the model performance is evaluated by monitoring the accuracy, recall rate and F1 value on the verification set. The innovation of this embodiment is that according to the characteristics of black spot disease, parameters and processing methods are carefully designed in each step. For example, in sample preprocessing, parameters such as mask are determined according to the characteristics of black spot disease spots, and reasonable settings and parameter optimization of each component in the 3223 architecture are constructed, as well as the targeted design of G-ConvNeXtBlock module and EnhancedCBAM attention mechanism, which improves the model's ability to classify and identify black spot disease on leaves.

[0160] In the scheme of the present invention, CALDNet enhances texture feature extraction by introducing Gabor filters, designs 3223Network structure and spatial pyramid pooling to improve spatial feature processing capabilities, and optimizes the attention mechanism to enhance the ability to identify small-scale diseases. The experimental results (see Table 2 for details) show that the scheme significantly improves the model performance, with an accuracy rate of 97.58%, an increase of 5.29% over the original model, and a reduction of 23.9% in the number of parameters, effectively solving the limitations of the existing model.

[0161] Table 2

[0162]

[0163] Among them, from top to bottom, the first model convnext is the original model, the middle model is other comparison models, and the last model CALDnet model is the model of the solution of the present invention (ie, the improved model). Obviously, the CALDnet model has the best experimental effect.

[0164] By adopting the technical solution of this embodiment, image data of apple leaves are collected as samples, and the samples are pre-processed to obtain a training set and a test set; the 3223 architecture in the improved ConvNeXt is constructed, the G-ConvNeXtBlock module is constructed, the EnhancedCBAM attention mechanism is introduced, and a new ConvNeXt network is constructed; the new ConvNeXt network is trained with the training set to obtain an apple leaf disease classification model; the trained apple leaf disease classification model is tested with the test set, and the trained apple leaf disease classification model is corrected according to the test results to obtain a corrected apple leaf disease classification model; the corrected apple leaf disease classification model is used to identify the apple leaf image to be detected, and the classification recognition result is obtained; thus, by identifying the apple leaf image to be detected with the apple leaf disease classification model obtained by training based on the improved ConvNeXt, apple leaf diseases can be quickly identified with good accuracy.

[0165] According to an embodiment of the present invention, a classification device for apple leaf diseases corresponding to the classification method for apple leaf diseases is also provided. Figure 6 The schematic diagram of the structure of an embodiment of the device of the present invention is shown. The device for classifying apple leaf diseases may include: an acquisition unit 102 and a control unit 104 .

[0166] The acquisition unit 102 is configured to collect image data of apple leaves (such as pictures of apple leaves) as samples. The specific functions and processing of the acquisition unit 102 refer to step S110.

[0167] The control unit 104 is configured to pre-process the samples to obtain a training set and a test set. The specific functions and processing of the control unit 104 refer to step S120.

[0168] The control unit 104 is also configured to introduce the EnhancedCBAM attention mechanism to construct an improved ConvNeXt network as a new ConvNeXt network. The specific functions and processing of the control unit 104 refer to step S130.

[0169] The control unit 104 is further configured to train the new ConvNeXt network using the training set to obtain a trained apple leaf disease classification model. The specific functions and processing of the control unit 104 refer to step S140.

[0170] The control unit 104 is further configured to test the trained apple leaf disease classification model using the test set to obtain a revised apple leaf disease classification model. The specific functions and processing of the control unit 104 refer to step S150.

[0171] The acquisition unit 102 is further configured to acquire image data of the apple leaf to be detected. The specific functions and processing of the acquisition unit 102 are also shown in step S160.

[0172] The control unit 104 is further configured to use the modified apple leaf disease classification model to perform detection to obtain the disease type of the apple leaf to be detected. The specific functions and processing of the control unit 104 refer to step S170.

[0173] The apple leaf disease classification scheme based on improved ConvNeXt proposed in the solution of the present invention significantly improves the accuracy and efficiency of disease identification. Through refined sample preprocessing, optimized network architecture (such as 3223 architecture, G-ConvNeXtBlock module) and introduction of EnhancedCBAM attention mechanism, it can more accurately capture disease characteristics and enhance the model's recognition ability for multi-scale and multi-type diseases; at the same time, through quantitative analysis and parameter optimization, the stability and generalization of the model in the training process are ensured, and ultimately the accuracy and practicability of disease classification are improved, providing strong support for the precise prevention and control of apple leaf diseases.

[0174] Since the processing and functions implemented by the device of this embodiment basically correspond to the embodiments, principles and examples of the aforementioned method, for the details not fully described in this embodiment, please refer to the relevant descriptions in the aforementioned embodiments, and no further elaboration will be made here.

[0175] According to an embodiment of the present invention, a terminal corresponding to the classification device for apple leaf diseases is also provided. The terminal may include: the classification device for apple leaf diseases described above.

[0176] Since the processing and functions implemented by the terminal of this embodiment basically correspond to the embodiments, principles and examples of the aforementioned devices, for the details not fully described in this embodiment, please refer to the relevant descriptions in the aforementioned embodiments, and no further elaboration will be made here.

[0177] According to an embodiment of the present invention, a storage medium corresponding to a classification method for apple leaf diseases is also provided, wherein the storage medium includes a stored program, wherein when the program is running, the device where the storage medium is located is controlled to execute the above-mentioned classification method for apple leaf diseases.

[0178] Since the processing and functions implemented by the storage medium of this embodiment basically correspond to the embodiments, principles and examples of the aforementioned method, for the details not fully described in this embodiment, please refer to the relevant descriptions in the aforementioned embodiments, and no further elaboration will be made here.

[0179] According to an embodiment of the present invention, a computer program product corresponding to the classification method of apple leaf diseases is also provided, including a computer program, which implements the steps of the classification method of apple leaf diseases described above when executed by a processor.

[0180] Since the processing and functions implemented by the product of this embodiment basically correspond to the embodiments, principles and examples of the aforementioned method, for the details not fully described in this embodiment, please refer to the relevant descriptions in the aforementioned embodiments, and no further elaboration will be made here.

[0181] In summary, it is easy for those skilled in the art to understand that, under the premise of no conflict, the above-mentioned advantageous methods can be freely combined and superimposed.

[0182] The above description is only an embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent substitution, improvement, etc. made within the spirit and principle of the present invention shall be included in the scope of the claims of the present invention.

Claims

1. A method for classifying apple leaf diseases, characterized in that: include: Collect image data of apple leaves as samples; Preprocessing the samples to obtain a training set and a test set; Introduce the EnhancedCBAM attention mechanism and build an improved ConvNeXt network as a new ConvNeXt network; Using the training set, training the new ConvNeXt network to obtain a trained apple leaf disease classification model; Using the test set, testing the trained apple leaf disease classification model to obtain a revised apple leaf disease classification model; Acquire image data of an apple leaf to be detected; The modified apple leaf disease classification model is used for detection to obtain the disease type of the apple leaf to be detected.

2. The method for classifying apple leaf diseases according to claim 1, characterized in that: The samples are preprocessed to obtain a training set and a test set, including: Performing a data augmentation operation on the sample to obtain an augmented data set; The enhanced data set is divided into the training set and the test set.

3. The method for classifying apple leaf diseases according to claim 2, characterized in that: Performing data augmentation operations on the samples to obtain augmented data sets includes: Using a preset mask shape function, the sample is randomly masked to obtain a mask data set; wherein the parameters of the mask shape function are different disease types obtained by analyzing preset apple leaf features; wherein the apple leaf features include at least one of the following: shape, size and distribution of lesions; Using a preset filling function, the pattern program and detail loss of the image data of the apple leaf at different shooting distances in the mask data set are filled to obtain a filled data set; The weighted average method is used to grayscale the filled data set according to the influence of different color channels on the disease characteristics of apple leaves to obtain the enhanced data set.

4. The method for classifying apple leaf diseases according to any one of claims 1 to 3, characterized in that: Introduce the EnhancedCBAM attention mechanism and build an improved ConvNeXt network as a new ConvNeXt network, including: Based on the original ConvNeXt network, an improved 3223 architecture in ConvNeXt is constructed; Based on the 3223 architecture in the improved ConvNeXt, a G-ConvNeXtBlock module is constructed; In the G-ConvNeXtBlock module, the EnhancedCBAM attention mechanism is introduced to obtain the improved ConvNeXt network as the new ConvNeXt network.

5. The method for classifying apple leaf diseases according to claim 4, characterized in that: in, Based on the original ConvNeXt network, an improved ConvNeXt 3223 architecture is constructed, including: Based on the original ConvNeXt network, the number of ConvNeXtBlocks is adjusted, the skip connection is set, the position encoding and the spatial pyramid pooling are processed in sequence to construct the 3223 architecture in the improved ConvNeXt; and / or, Based on the improved 3223 architecture in ConvNeXt, a G-ConvNeXtBlock module is constructed, including: Based on the 3223 architecture in the improved ConvNeXt, Gabor filter is introduced, and the connection mode and weight are set to construct a G-ConvNeXtBlock module.

6. The method for classifying apple leaf diseases according to claim 4 or 5, characterized in that: The EnhancedCBAM attention mechanism includes: channel attention mechanism and spatial attention mechanism; In the G-ConvNeXtBlock module, the EnhancedCBAM attention mechanism is introduced to obtain the improved ConvNeXt network as the new ConvNeXt network, including: In the G-ConvNeXtBlock module, the channel attention mechanism is introduced to analyze the channel information of the feature graphs of different disease types to obtain a communication information network; In the channel information model, the spatial attention mechanism is introduced to analyze the spatial position information of the feature maps of different disease types to obtain a spatial position information network, the new ConvNeXt network.

7. A classification device for apple leaf diseases, characterized in that: include: an acquisition unit configured to collect image data of an apple leaf as a sample; A control unit, configured to pre-process the samples to obtain a training set and a test set; The control unit is further configured to introduce an EnhancedCBAM attention mechanism to construct an improved ConvNeXt network as a new ConvNeXt network; The control unit is further configured to train the new ConvNeXt network using the training set to obtain a trained apple leaf disease classification model; The control unit is further configured to test the trained apple leaf disease classification model using the test set to obtain a revised apple leaf disease classification model; The acquisition unit is further configured to acquire image data of the apple leaf to be detected; The control unit is further configured to use the modified apple leaf disease classification model to perform detection to obtain the disease type of the apple leaf to be detected.

8. A terminal, characterized in that: include: The classification device for apple leaf diseases as described in claim 7.

9. A storage medium, characterized in that: The storage medium includes a stored program, wherein when the program is executed, the device where the storage medium is located is controlled to execute the classification method for apple leaf diseases according to any one of claims 1 to 6.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method for classifying apple leaf diseases described in any one of claims 1 to 6 are implemented.

Citation Information

Cited By

  • Apple leaf disease multi-classification method based on complex environment background

    CN120411618A

  • Apple leaf disease multi-classification method based on complex environment background

    CN120411618B

  • Method for identifying various citrus diseases based on diffusion model

    CN120411678A

  • Wheat stripe rust grading identification method based on improved YOLOv11 and ConvNeXtV2 models

    CN121236543A

  • Wheat stripe rust grading recognition method based on improved YOLOv11 and ConvNeXtV2 model

    CN121236543B