Deep learning for apple leaf disease diagnosis: a comparative study with convolutional neural networks and transformers Authors: Soroush Toutounchian, Amirhosein Zobeiri, Alireza Rezaee, Farshid Hajati, Raymond Chiong Published: 2026 ABSTRACT Plant diseases pose a major threat to global food security, significantly reducing agricultural yields. Therefore, timely diagnosis of plant diseases can help prevent food losses and support economic stability. This study explores the use of eight Convolutional Neural Networks and two Vision Transformers for apple leaf disease diagnosis. The feature extraction layers of each model were modified to incorporate DropBlock layers, while preserving pretrained weights from the ImageNet dataset. Images from the Plant Pathology 2021 dataset were used to fine-tune the models for multi-label classification, targeting five disease categories and a healthy label. Three experiments were conducted to evaluate model performance on the test set. First, the ResNet50 model was used to determine optimal Dropout and DropBlock probabilities. Second, these parameters were applied across all models to identify those with the best performance. Finally, twenty-three Swarm Optimization Algorithms were used to optimize classifier thresholds, improving accuracy and F1-scores. A DropBlock probability of 0.05 and a Dropout probability of 0.2 yielded superior results. Among the models, SwinV2T attained an accuracy of 90.7%, while SwinV2S achieved the highest F1-score of 91.7%, slightly outperforming the ConvNeXtT and ConvNeXtS architectures. The results demonstrated the effectiveness of DropBlock regularization and optimized classifier thresholds, highlighting the superior performance of recent architectures and optimization algorithms over their older counterparts. These findings suggest that such networks hold substantial promise for accurately identifying and diagnosing apple leaf diseases. Introduction Agriculture, one of the earliest foundations of human civilization and settlement, remains a vital industry that continues to shape societal development and ensure global stability1,2. Ensuring food security is of paramount importance, particularly given the rapidly growing global population. United Nations projections estimate that the world population will surpass 9 billion by 2050, with 80% residing in developing countries3,4. To meet this escalating demand, agricultural productivity must increase by at least 70%3. However, food security is continuously threatened by environmental pressures, including global warming, the decline of pollinator populations, pests, and pathogenic microorganisms5,6. Research has demonstrated that early detection of abnormal spots and lesions on plant leaves can facilitate the identification of microorganism-induced diseases7,8. Among the factors threatening plant health, pathogenic microorganisms and pests pose particularly significant risks9. The damage caused by these organisms manifests as symptoms such as blight, wilt, rot, and discoloration, ultimately resulting in substantial yield losses10–12. Therefore, rapid and accurate diagnosis of plant leaf conditions is essential for effective disease management13,14. Historically, the diagnosis of plant diseases caused by microorganisms has relied on manual inspection performed by experts, horticulturalists, and field laborers15. However, like many human-dependent processes, these methods are inherently susceptible to subjective bias and human error16. Furthermore, access to horticultural expertise is often limited, particularly for smallholder farmers in underprivileged regions, and such expertise may be prohibitively expensive120,121,122,123. In addition, the large number of plants and leaves in agricultural fields renders manual inspection a labor-intensive and time-consuming task, even for experienced practitioners. This inefficiency not only increases the likelihood of misdiagnosis but also elevates the risk of excessive and unnecessary pesticide application17. Recent advancements in artificial intelligence (AI) and image processing have enabled the development of sophisticated systems for detecting and identifying plant leaf diseases. These systems can achieve high accuracy in tasks such as disease classification12,18–20. Consequently, automated diagnostic systems have the potential to substantially reduce both the time and cost associated with plant disease assessment21. A variety of techniques have been employed for plant disease diagnosis, including polymerase chain reaction, chromatography, mass spectrometry, DNA barcoding, thermography, and hyperspectral imaging22–24. Among these approaches, image processing, an important branch of digital signal processing, has emerged as a particularly effective and widely adopted tool in this domain25. Over the past two decades, image processing techniques have played a pivotal role in advancing the automation of plant leaf disease diagnosis26,27. These approaches typically employ thresholding methods to generate masks that isolate regions of interest, such as diseased areas, while excluding irrelevant components, including the background and healthy tissue. By applying multiple thresholds and masks, various features can be extracted from the images124. These features are subsequently analyzed by classification algorithms, which assign labels (e.g., specific disease categories) to the samples. Such features are fundamental to tasks such as classification, pattern recognition, and broader machine learning (ML) applications. Currently, deep learning (DL) techniques in image processing have enabled a high degree of automation, eliminating the need for handcrafted feature engineering. Advances in hardware capabilities and neural network architectures have further expanded the applicability of DL-based computer vision across diverse domains, including medical imaging, autonomous driving, and agriculture28–30. Among these approaches, Convolutional Neural Networks (CNNs) are particularly prominent due to their strong performance in image classification tasks, primarily driven by their ability to automatically learn hierarchical feature representations through convolutional operations31,32. CNN-based models perform disease classification by propagating input data through multiple convolutional layers during training. This process involves iterative forward and backward passes over the dataset, enabling the network to progressively optimize its parameters and improve predictive performance. In this study, several CNNs and two Vision Transformer (ViT) architectures are proposed for the multi-label classification of apple leaf diseases. The ViT models leverage attention mechanisms to enhance feature representation and learning, offering a complementary paradigm to conventional image classification approaches. These developments underscore the potential of ViTs to augment and extend the capabilities of traditional CNN-based architectures. The main contributions of this study are summarized as follows: A dataset containing images of leaves in complex, natural backgrounds is employed, distinguishing this work from prior studies that rely on datasets with images captured in controlled lab conditions with simple backgrounds, such as the PlantVillage dataset33.While most existing studies adopt single-label classification frameworks, this study investigates a multi-label classification approach to address challenges associated with class imbalance and the co-occurrence of multiple diseases on a single leaf.To improve model robustness, various regularization techniques are incorporated during training, including DropBlock34, Dropout31, and Label Smoothing35.Swarm Optimization Algorithms (SOAs) are utilized to fine-tune model parameters with the aim of enhancing classification performance.State-of-the-art computer vision models are implemented and systematically compared with commonly used architectures in related studies. A dataset containing images of leaves in complex, natural backgrounds is employed, distinguishing this work from prior studies that rely on datasets with images captured in controlled lab conditions with simple backgrounds, such as the PlantVillage dataset33. A dataset containing images of leaves in complex, natural backgrounds is employed, distinguishing this work from prior studies that rely on datasets with images captured in controlled lab conditions with simple backgrounds, such as the PlantVillage dataset33. While most existing studies adopt single-label classification frameworks, this study investigates a multi-label classification approach to address challenges associated with class imbalance and the co-occurrence of multiple diseases on a single leaf. While most existing studies adopt single-label classification frameworks, this study investigates a multi-label classification approach to address challenges associated with class imbalance and the co-occurrence of multiple diseases on a single leaf. To improve model robustness, various regularization techniques are incorporated during training, including DropBlock34, Dropout31, and Label Smoothing35. To improve model robustness, various regularization techniques are incorporated during training, including DropBlock34, Dropout31, and Label Smoothing35. Swarm Optimization Algorithms (SOAs) are utilized to fine-tune model parameters with the aim of enhancing classification performance. Swarm Optimization Algorithms (SOAs) are utilized to fine-tune model parameters with the aim of enhancing classification performance. State-of-the-art computer vision models are implemented and systematically compared with commonly used architectures in related studies. State-of-the-art computer vision models are implemented and systematically compared with commonly used architectures in related studies. Related Work Prior to 2016, plant and leaf disease diagnosis predominantly relied on traditional ML approaches, in which both feature extraction and disease classification were performed using handcrafted descriptors. Although such methods are still occasionally applied in image classification tasks, deep neural networks have demonstrated superior performance across multiple evaluation criteria. Early studies employed relatively simple neural networks as classifiers36, while the majority utilized algorithms such as K-nearest neighbors37,38, support vector machines12,37–39, and random forests38. In 2016, the first large-scale, open-access dataset for plant disease classification, known as the PlantVillage dataset, was introduced, comprising over 50,000 images of plant leaves33. This dataset includes annotations spanning 38 plant–disease classes, making it a valuable benchmark for training and evaluating DL models. Since then, several additional datasets focusing on plant diseases have been published40–46. Nevertheless, PlantVillage remains the most widely utilized dataset in this domain. Table 1 provides a summary of datasets specifically related to apple leaf disease classification. Table 1Plant datasets containing images of apple leaf diseases.DatasetNumber of imagesNumber of apple imagesNumber of classesPlantVillage3354,3063,17139 (4 for apples)Plant Pathology 2020401,8211,8214Plant Pathology 20214118,63218,63212Northwest A&F422,9752,9756PDD27143220,592Not specified271 (Not specified for apples)Turkey Apple Disease444,4471,41615 (4 for apples)PlantDoc452,59827328 (3 for apples) Table 1Plant datasets containing images of apple leaf diseases.DatasetNumber of imagesNumber of apple imagesNumber of classesPlantVillage3354,3063,17139 (4 for apples)Plant Pathology 2020401,8211,8214Plant Pathology 20214118,63218,63212Northwest A&F422,9752,9756PDD27143220,592Not specified271 (Not specified for apples)Turkey Apple Disease444,4471,41615 (4 for apples)PlantDoc452,59827328 (3 for apples) Plant datasets containing images of apple leaf diseases. Over the past decade, CNNs have gained considerable attention due to their strong performance in image classification tasks. Mohanty et al33 trained AlexNet31 and GoogLeNet47using standard, background-removed, and grayscale images to evaluate model performance. They further compared models trained from scratch with those employing transfer learning, demonstrating that transfer learning not only accelerated convergence of training and validation F1-scores but also improved overall accuracy. Frentinos48 extended the PlantVillage dataset by incorporating images captured under realistic field conditions. Using transfer learning, they trained several architectures, including AlexNet31, VGG49, GoogLeNet47, and OverFeat50, with VGG16 achieving a maximum accuracy of 99.53%. Their findings revealed that models trained on images with complex, natural backgrounds significantly outperformed those trained on simplified backgrounds, achieving accuracies of 65% and 33%, respectively. In another study, Kunduracioglu51 employed six CNN architectures to classify apple leaf images from the PlantVillage dataset using pretrained models. They reported exceptionally high performance, with EfficientNetV2M52achieving 100% accuracy, precision, recall, and F1-score. Liu et al43 developed a hybrid framework combining CNNs with long short-term memory (LSTM) networks. They utilized the large-scale PDD271 dataset43, which contains 220,592 images across 271 classes, and achieved an accuracy of 85.58%. In a related study, Li et al53 introduced the “ConvViT” framework using a dataset of 2,029 images across five classes. Their model achieved an accuracy of 96.85%, outperforming Swin Transformer Tiny (SwinT)54. Ding et al77 applied data augmentation to the Plant Pathology 2021 dataset, expanding it to 97,062 images, and used this enriched dataset to train several DL models, including ResNet64, MobileNet125, DenseNet63, RegNet81, ShuffleNet126 and ConvNeXt73. Their proposed architecture, based on ResNet18 and incorporating a dual attention mechanism, achieved an accuracy of 89.61%. Similarly, Yadav et al78 developed a specialized framework, AFD-NET, by combining EfficientNetB3 and EfficientNetB460, using the Plant Pathology 2020 and 2021 datasets. Their model outperformed several pretrained architectures, including ResNet5064, ResNet15264, VGG1649, InceptionV335, and the base EfficientNet60, achieving accuracies of 98.7% and 92.6% on the 2020 and 2021 datasets, respectively. Additionally, Shafik et al44 utilized a dataset of 4,447 images across more than 15 classes to train multiple models, including ResNet10164, Xception70, InceptionResnetV269, VGG11949, InceptionV335, and AlexNet31. Their best-performing model, a CNN–LSTM ensemble, achieved an accuracy of 99.2%, outperforming all individual architectures. The CTPlantNet model, introduced by Nasser and Akhloufi55, combines a CNN block and a Transformer block. Its CNN module integrates SEResNeXt5056 and EfficientNetV2S52, while the Transformer module employs a Swin Transformer Large (SwinL)54 model. This hybrid architecture achieved an accuracy of 98.28% on the Plant Pathology 2020 dataset and 95.96% on the Plant Pathology 2021 dataset, outperforming competing methods. Ullah et al57 introduced a lightweight ViT model, AppViT, trained on the five most prevalent classes from the Plant Pathology 2021 dataset, comprising 16,093 images. By incorporating extensive data augmentation techniques, their model achieved an accuracy of 96.4% and an F1-score of 96.3%. PLA-ViT58 by Murugavalli and Gopi leverages multi-head self-attention and global average pooling to enhance feature extraction by capturing long-range dependencies and spatial hierarchies over conventional CNN architectures. Additionally, data augmentation and an adaptive learning rate scheduler were employed to improve generalization and training efficiency. Their experimental results demonstrated that PLA-ViT achieved an accuracy of 98.7%, representing a 23.4% improvement over the lowest-performing baseline model. Ali et al59 improved a pretrained EfficientNetB060 by replacing the global average pooling layer with a global max pooling layer, thereby emphasizing lesion and spot features for enhanced representation learning. The modified model achieved an accuracy and F1-score of 99.78% on the full dataset, outperforming competing approaches. OptiNet-B361 was trained on a combined fruit and leaf dataset. The leaf subset included 3,114 apple leaf images from the PlantVillage dataset across four classes, along with 8,085 banana and orange leaf images captured under complex background conditions. Knowledge Distillation62 was also applied during training. Under these settings, OptiNet-B3 achieved an accuracy of 99.23%, outperforming DenseNet12163, ResNet5064, MobileNetV365, and InceptionV335. Zhang et al66 constructed a comprehensive proprietary apple dataset consisting of three subsets: the Apple Fruit Varieties Collection, with 29,750 images across 85 classes; the Apple Fruit Quality Categorization, with 2,320 images labeled as fresh or rotten; and the Apple Diseases Extensive Collection, comprising 2,976 images spanning six disease classes and one healthy class. In experiments conducted on the Apple Diseases Extensive Collection dataset, pretrained InceptionV335 and their optimized CNN (OP-CNN) achieved accuracies of 95.83% and 91.23%, respectively, with OP-CNN demonstrating faster inference. In subsequent experiments, their transformer-based Optimized Apple Orchard Model (OAOM-VT) achieved superior performance, reaching an accuracy of 99.66%. OAOM-VT has consistently achieved the highest performance compared with baseline models across different datasets. The majority of the aforementioned studies employ multi-class, single-label classification frameworks, in which each image is assigned to a single class. In cases involving multiple co-occurring diseases, these are typically treated as a single combined class, limiting model flexibility and generalization. A promising alternative is multi-label classification, where each image can be associated with multiple disease categories simultaneously. This approach enables models to capture complex disease co-occurrence patterns, including combinations not explicitly represented in the training data. For instance, Kejriwal et al67 applied a multi-label classification framework using ResNet101V268, InceptionResnetV269, Xception70on the plant pathology 2021 to reach an F1-score of 96.25%. Similarly, Ji et al71 trained InceptionV335, ResNet5064, DenseNet12163 and NASNet72 on a subset of the PlantVillage dataset for both disease classification and severity estimation. They evaluated several approaches, including single-label CNNs (LP-CNNs), ensembles of multi-class CNNs (MLP-CNNs), and Binary Relevance CNNs (BR-CNNs). Their results indicated that the multi-label approach using a single model (BR-CNNs) achieved the highest performance, with DenseNet121 reaching 97.88% accuracy for disease classification and ResNet50 achieving 86.70% accuracy for severity estimation. Overall, existing studies demonstrated that DL models can achieve high accuracy in plant disease diagnosis. However, relatively few of them have explored multi-label classification, and many continue to rely on conventional CNN architectures such as VGG49, AlexNet31, and ResNet64. In contrast, the present study adopts a multi-label classification framework and leverages more recent architectures from the ConvNeXt73 and SwinV274 families to identify multiple apple leaf diseases, thereby aiming to achieve improved performance and generalization. Materials and methods The overall workflow for our plant leaf disease classification begins with the collection of an image dataset, followed by expert annotation to ensure accurate labeling of disease categories. Subsequently, preprocessing steps—such as resizing and normalization—are applied to standardize the input images. Once prepared, the data is used as input to CNNs and ViTs. In cases where the dataset is limited in size or exhibits high similarity among samples, data augmentation techniques are employed to improve model robustness and generalization performance. The next stage involves initializing vision models with pretrained weights derived from the ImageNet dataset75, which serves as a standard benchmark in computer vision research. These models are then fine-tuned on the training subset to adapt them to the specific task of leaf disease classification. During training, a validation subset is utilized to monitor model performance and mitigate overfitting. Final evaluation is conducted on a held-out test subset to assess classification accuracy. To further enhance performance, decision thresholds are optimized using SOAs. Figure 1 illustrates the overall architecture of our framework. Fig. 1The structure of the proposed method. The structure of the proposed method. Dataset The dataset used in this study is the Plant Pathology 2021 dataset from Cornell University, comprising 18,632 images of apple leaves categorized into 12 classes41. Among these, one class corresponds to healthy leaves, five classes represent single-disease cases, and six classes include images exhibiting multiple co-occurring diseases. In most images, the leaf and associated disease symptoms are centrally positioned. Figure 2 presents the distribution of disease classes, while representative samples for each category are shown in Fig. 3. The dataset is divided into training and test sets using an 80:20 split. To ensure robust performance evaluation, 5-fold cross-validation is applied to the training set. Fig. 2Distribution of classes in the Plant Pathology 2021 dataset. Distribution of classes in the Plant Pathology 2021 dataset. Fig. 3Sample images from the dataset. (a) Healthy, (b) Scab, (c) Frog eye leaf spot, (d) Rust, (e) Powdery mildew, and (f) Complex. Sample images from the dataset. (a) Healthy, (b) Scab, (c) Frog eye leaf spot, (d) Rust, (e) Powdery mildew, and (f) Complex. The main disease classes included in the dataset are described as follows: Scab: One of the most prevalent diseases affecting apple leaves, scab is characterized by dark brown lesions on both the upper and lower leaf surfaces. It is caused by the fungal pathogen Venturia inaequalis76.Frog eye leaf spot: Caused by the fungus Botryosphaeria obtusa, this disease manifests as cream-colored lesions with distinct brown margins, resembling “frog eyes.” Under severe conditions, it can lead to significant defoliation, thereby weakening the affected trees.Rust: This disease is caused by Gymnosporangium juniperi-virginianae and affects apples and cedar leaves, as well as fruits. It is characterized by orange to reddish spots on the upper leaf surface, with size varying according to disease severity. As the disease progresses, filamentous structures develop on the underside of the leaves.Powdery mildew: This disease presents as a white to grayish, powdery coating that spreads across the leaf surface. Unlike localized lesions observed in other diseases, powdery mildew typically covers the entire leaf, reducing photosynthetic efficiency and overall plant vitality.Complex: This category includes leaves exhibiting mixed or ambiguous symptoms that cannot be attributed to a single disease class. It encompasses cases with overlapping symptoms or simultaneous infections by multiple pathogens. Scab: One of the most prevalent diseases affecting apple leaves, scab is characterized by dark brown lesions on both the upper and lower leaf surfaces. It is caused by the fungal pathogen Venturia inaequalis76. Scab: One of the most prevalent diseases affecting apple leaves, scab is characterized by dark brown lesions on both the upper and lower leaf surfaces. It is caused by the fungal pathogen Venturia inaequalis76. Frog eye leaf spot: Caused by the fungus Botryosphaeria obtusa, this disease manifests as cream-colored lesions with distinct brown margins, resembling “frog eyes.” Under severe conditions, it can lead to significant defoliation, thereby weakening the affected trees. Frog eye leaf spot: Caused by the fungus Botryosphaeria obtusa, this disease manifests as cream-colored lesions with distinct brown margins, resembling “frog eyes.” Under severe conditions, it can lead to significant defoliation, thereby weakening the affected trees. Rust: This disease is caused by Gymnosporangium juniperi-virginianae and affects apples and cedar leaves, as well as fruits. It is characterized by orange to reddish spots on the upper leaf surface, with size varying according to disease severity. As the disease progresses, filamentous structures develop on the underside of the leaves. Rust: This disease is caused by Gymnosporangium juniperi-virginianae and affects apples and cedar leaves, as well as fruits. It is characterized by orange to reddish spots on the upper leaf surface, with size varying according to disease severity. As the disease progresses, filamentous structures develop on the underside of the leaves. Powdery mildew: This disease presents as a white to grayish, powdery coating that spreads across the leaf surface. Unlike localized lesions observed in other diseases, powdery mildew typically covers the entire leaf, reducing photosynthetic efficiency and overall plant vitality. Powdery mildew: This disease presents as a white to grayish, powdery coating that spreads across the leaf surface. Unlike localized lesions observed in other diseases, powdery mildew typically covers the entire leaf, reducing photosynthetic efficiency and overall plant vitality. Complex: This category includes leaves exhibiting mixed or ambiguous symptoms that cannot be attributed to a single disease class. It encompasses cases with overlapping symptoms or simultaneous infections by multiple pathogens. Complex: This category includes leaves exhibiting mixed or ambiguous symptoms that cannot be attributed to a single disease class. It encompasses cases with overlapping symptoms or simultaneous infections by multiple pathogens. Multi-label augmentation The original Plant Pathology 2021 dataset comprises images annotated into 12 distinct classes, each represented by a unique label. This annotation scheme corresponds to a single-label classification framework, in which each image is assigned to only one class. Most prior studies utilizing this dataset have adopted this formulation for model training55,77,78. However, given that some images exhibit multiple co-occurring diseases, a multi-label classification approach can provide a more appropriate representation. In this framework, each sample is encoded as a binary vector, where each element corresponds to a specific disease class; a value of 1 indicates the presence of the disease, while 0 denotes its absence. For example, an image containing both rust and complex disease characteristics would be represented with ones in the corresponding positions and zeros elsewhere. In this study, following a similar strategy to67, the original single-label annotations are transformed into multi-label representations, enabling the training of models under a multi-label classification paradigm. Figure 4 illustrates examples of this transformation from single-label to multi-label encoding. Fig. 4Sample images illustrating the conversion from multi-class labels to multi-label representations. Each element in the label vector corresponds to a specific disease class: scab, healthy, frog eye leaf spot, rust, complex, and powdery mildew, respectively. Sample images illustrating the conversion from multi-class labels to multi-label representations. Each element in the label vector corresponds to a specific disease class: scab, healthy, frog eye leaf spot, rust, complex, and powdery mildew, respectively. Data preprocessing The original images in the dataset have a resolution of 5,184 × 3,456 pixels, which imposes substantial computational demands for training both ViTs and CNNs. Moreover, most pretrained architectures require square-shaped inputs. Accordingly, all images in this study are resized to 400 × 400 pixels, providing a balance between preserving visual information and maintaining computational efficiency, compared to the commonly used 224 × 224 resolution. DL models typically require large-scale datasets, often on the order of millions of images, such as ImageNet75. However, plant pathology datasets are generally limited in size. Furthermore, repeatedly exposing the model to identical images may lead to overfitting, where the model memorizes specific patterns rather than learning generalizable features. To address this issue, data augmentation techniques are employed to introduce variability and improve model robustness. In this study, data augmentation is implemented using the Albumentations library79, incorporating the following transformations: Flipping: Images are flipped horizontally and vertically, effectively mirroring pixel positions to increase variability without altering semantic content.Sharpening: Edge features are enhanced by amplifying local intensity variations, improving the visibility of disease-related patterns.Shifting: Images are translated along horizontal or vertical axes, altering spatial positioning and providing additional contextual diversity.Rotation: Images are rotated within a range of 0° to 90°, enabling the model to learn invariant features under different orientations. Flipping: Images are flipped horizontally and vertically, effectively mirroring pixel positions to increase variability without altering semantic content. Flipping: Images are flipped horizontally and vertically, effectively mirroring pixel positions to increase variability without altering semantic content. Sharpening: Edge features are enhanced by amplifying local intensity variations, improving the visibility of disease-related patterns. Sharpening: Edge features are enhanced by amplifying local intensity variations, improving the visibility of disease-related patterns. Shifting: Images are translated along horizontal or vertical axes, altering spatial positioning and providing additional contextual diversity. Shifting: Images are translated along horizontal or vertical axes, altering spatial positioning and providing additional contextual diversity. Rotation: Images are rotated within a range of 0° to 90°, enabling the model to learn invariant features under different orientations. Rotation: Images are rotated within a range of 0° to 90°, enabling the model to learn invariant features under different orientations. During training, these augmentations are applied randomly, expanding the effective size of the training dataset to 357,720 images. Each transformation is applied with a probability ranging from 0.5 to 0.7, allowing for both augmented and occasionally repeated samples, which facilitates learning from subtle variations. When augmentation operations introduce empty pixel regions (e.g., after rotation or shifting), the Albumentations interpolation mechanism fills these areas using neighboring pixel values, thereby preserving image consistency and quality. Figure 5 illustrates examples of original and augmented images. Fig. 5Examples of data augmentation techniques applied to the dataset, including flipping, rotation, shifting, and sharpening. These transformations are applied randomly to increase data diversity. Examples of data augmentation techniques applied to the dataset, including flipping, rotation, shifting, and sharpening. These transformations are applied randomly to increase data diversity. Models In this study, eight CNN architectures and two ViT models from different architectural families are evaluated to identify the most effective approach for plant leaf disease classification. The following section provides an overview of these architectures and the rationale for their selection. ResNet64: Residual Networks introduce skip connections that allow gradients to bypass certain layers, effectively mitigating the vanishing gradient problem. This design enables the training of very deep networks and has served as a foundational architecture for numerous subsequent models.ResNeXt80: ResNeXt extends ResNet by introducing the concept of “cardinality”, which increases the number of parallel transformation paths within each block. Employing grouped convolutions enhances representational capacity more efficiently than simply increasing network depth or width.DenseNet63: DenseNet utilizes dense connectivity, where each layer receives feature maps from all preceding layers. This structure promotes feature reuse, improves gradient flow, and allows relatively compact models to achieve strong performance.RegNet81: RegNet models are designed through systematic exploration of a structured design space rather than manual architectural modifications. Their regular scaling patterns in width and depth result in efficient and scalable models across various computational budgets.EfficientNetV252: The EfficientNet family60 introduced compound scaling, which uniformly scales network depth, width, and input resolution. EfficientNetV2 improves upon this design by incorporating fused MBConv layers, progressive learning strategies (e.g., gradually increasing input resolution during training), and refined scaling rules, leading to faster training and improved performance.SwinV274 : ViTs82 introduced patch-based processing for image recognition tasks. The Swin Transformer54 improved upon this by employing a hierarchical structure with shifted windows. SwinV2 further enhances scalability through cosine attention mechanisms and continuous positional bias, enabling efficient handling of high-resolution inputs and large-scale models.ConvNeXt73: ConvNeXt modernizes CNN architectures by incorporating design principles inspired by transformers while retaining convolutional operations. By revisiting and refining components such as kernel sizes, normalization layers, and activation functions, ConvNeXt achieves competitive performance and has been shown to outperform earlier transformer-based models such as Swin Transformer (SwinV1). ResNet64: Residual Networks introduce skip connections that allow gradients to bypass certain layers, effectively mitigating the vanishing gradient problem. This design enables the training of very deep networks and has served as a foundational architecture for numerous subsequent models. ResNet64: Residual Networks introduce skip connections that allow gradients to bypass certain layers, effectively mitigating the vanishing gradient problem. This design enables the training of very deep networks and has served as a foundational architecture for numerous subsequent models. ResNeXt80: ResNeXt extends ResNet by introducing the concept of “cardinality”, which increases the number of parallel transformation paths within each block. Employing grouped convolutions enhances representational capacity more efficiently than simply increasing network depth or width. ResNeXt80: ResNeXt extends ResNet by introducing the concept of “cardinality”, which increases the number of parallel transformation paths within each block. Employing grouped convolutions enhances representational capacity more efficiently than simply increasing network depth or width. DenseNet63: DenseNet utilizes dense connectivity, where each layer receives feature maps from all preceding layers. This structure promotes feature reuse, improves gradient flow, and allows relatively compact models to achieve strong performance. DenseNet63: DenseNet utilizes dense connectivity, where each layer receives feature maps from all preceding layers. This structure promotes feature reuse, improves gradient flow, and allows relatively compact models to achieve strong performance. RegNet81: RegNet models are designed through systematic exploration of a structured design space rather than manual architectural modifications. Their regular scaling patterns in width and depth result in efficient and scalable models across various computational budgets. RegNet81: RegNet models are designed through systematic exploration of a structured design space rather than manual architectural modifications. Their regular scaling patterns in width and depth result in efficient and scalable models across various computational budgets. EfficientNetV252: The EfficientNet family60 introduced compound scaling, which uniformly scales network depth, width, and input resolution. EfficientNetV2 improves upon this design by incorporating fused MBConv layers, progressive learning strategies (e.g., gradually increasing input resolution during training), and refined scaling rules, leading to faster training and improved performance. EfficientNetV252: The EfficientNet family60 introduced compound scaling, which uniformly scales network depth, width, and input resolution. EfficientNetV2 improves upon this design by incorporating fused MBConv layers, progressive learning strategies (e.g., gradually increasing input resolution during training), and refined scaling rules, leading to faster training and improved performance. SwinV274 : ViTs82 introduced patch-based processing for image recognition tasks. The Swin Transformer54 improved upon this by employing a hierarchical structure with shifted windows. SwinV2 further enhances scalability through cosine attention mechanisms and continuous positional bias, enabling efficient handling of high-resolution inputs and large-scale models. SwinV274 : ViTs82 introduced patch-based processing for image recognition tasks. The Swin Transformer54 improved upon this by employing a hierarchical structure with shifted windows. SwinV2 further enhances scalability through cosine attention mechanisms and continuous positional bias, enabling efficient handling of high-resolution inputs and large-scale models. ConvNeXt73: ConvNeXt modernizes CNN architectures by incorporating design principles inspired by transformers while retaining convolutional operations. By revisiting and refining components such as kernel sizes, normalization layers, and activation functions, ConvNeXt achieves competitive performance and has been shown to outperform earlier transformer-based models such as Swin Transformer (SwinV1). ConvNeXt73: ConvNeXt modernizes CNN architectures by incorporating design principles inspired by transformers while retaining convolutional operations. By revisiting and refining components such as kernel sizes, normalization layers, and activation functions, ConvNeXt achieves competitive performance and has been shown to outperform earlier transformer-based models such as Swin Transformer (SwinV1). Given the strong performance of ResNet-based architectures in agricultural applications44,67,71,77, a model from the ResNet family is also included in this study. The model selection process is guided by two primary criteria. First, preference is given to architectures with relatively fewer parameters, as the Plant Pathology 2021 dataset is limited in size, and smaller models can help reduce the risk of overfitting. Second, emphasis is placed on novelty, prioritizing architectures that have not been extensively explored in plant pathology research. Several of the selected models remain underutilized in this domain. Table 2 summarizes the evaluated models, including their number of parameters, computational complexity (GFLOPs), and benchmark performance on ImageNet-1 K. Table 2Details of the models evaluated in this study, including the number of parameters, computational complexity (GFLOPs), and top-1 accuracy on ImageNet-1 K.ModelParametersGFlopsAccuracy (%)EfficientNetV2S5221.5 M8.3784.23EfficientNetV2M5254.1 M24.5885.11ResNet506425.6 M4.0976.13ReNeXt50-32 × 4d8025.0 M4.2377.62DenseNet2016320.0 M4.2976.89RegNetY3.2GF8119.4 M3.1878.94SwinV2T7428.4 M5.9482.07SwinV2S7449.7 M11.5583.71ConvNeXtT7328.6 M4.4682.52ConvNeXtS7350.2 M8.6883.61 Table 2Details of the models evaluated in this study, including the number of parameters, computational complexity (GFLOPs), and top-1 accuracy on ImageNet-1 K.ModelParametersGFlopsAccuracy (%)EfficientNetV2S5221.5 M8.3784.23EfficientNetV2M5254.1 M24.5885.11ResNet506425.6 M4.0976.13ReNeXt50-32 × 4d8025.0 M4.2377.62DenseNet2016320.0 M4.2976.89RegNetY3.2GF8119.4 M3.1878.94SwinV2T7428.4 M5.9482.07SwinV2S7449.7 M11.5583.71ConvNeXtT7328.6 M4.4682.52ConvNeXtS7350.2 M8.6883.61 Details of the models evaluated in this study, including the number of parameters, computational complexity (GFLOPs), and top-1 accuracy on ImageNet-1 K. Transfer learning Training deep computer vision models from scratch on large-scale datasets is computationally expensive and time-consuming, often requiring weeks or months for convergence. When applied to smaller datasets, such approaches are prone to overfitting, poor generalization, and unstable optimization. Transfer learning addresses these challenges by leveraging knowledge acquired from models pretrained on large datasets such as ImageNet75. In this paradigm, pretrained weights serve as an informed initialization, replacing random weight initialization and thereby accelerating convergence, reducing computational cost, and improving generalization performance. This approach is particularly advantageous when working with limited datasets, such as Plant Pathology 2021. In this study, a full fine-tuning strategy is adopted, whereby all network layers are updated during training. This contrasts with partial fine-tuning approaches that freeze early layers and update only the final classification layers. Swarm optimization algorithms SOAs are inspired by collective behaviors observed in natural systems, such as flocking, foraging, and social interaction among biological agents. In ML, SOAs are widely used as optimization strategies for feature selection and hyperparameter tuning39,83. For instance, while CNNs automatically extract features from input images, SOAs can be employed to identify and prioritize the most informative features for classification tasks83. They are also effective for optimizing hyperparameters, such as learning rates, when training deep neural networks84. The fundamental concept of SOAs involves modeling individual agents that interact within an environment according to predefined behavioral rules. Key components of these algorithms include agent representation, objective functions, neighborhood structures, and movement strategies85,86. Through iterative, nature-inspired search processes, SOAs are capable of efficiently solving complex, nonlinear optimization problems. Ongoing research continues to refine these methods and develop new variants for applications across engineering and scientific domains. In this study, SOAs are implemented using the Mealpy library87–89. Implementation In this work, all models are initialized with pretrained weights from ImageNetV175, and their classification heads are modified to suit the multi-label classification task. Specifically, a Dropout layer31 with a probability of 0.2 is incorporated, followed by a Sigmoid activation function. The final fully connected layer is adjusted to include six output neurons, each corresponding to a disease label. To further improve generalization, DropBlock regularization34 is integrated into the architectures. Unlike standard Dropout, which randomly removes individual activations, DropBlock eliminates contiguous regions within feature maps, encouraging the network to learn more robust and spatially distributed representations. Four DropBlock layers are strategically inserted between the main stages of each model. As feature maps typically increase in depth while decreasing in spatial resolution across layers, block sizes of 9, 7, 5, and 3 are applied to successive DropBlock layers. These configurations correspond to feature map sizes of approximately 100, 50, 25, and 13, respectively, ensuring consistency with the architectural hierarchy. Figure 6 illustrates the modified ResNet50 architecture, while Figure 7 presents the adapted Swin Transformer V2 Tiny (SwinV2T) model used in this study, highlighting the placement of DropBlock layers for enhanced performance. Fig. 6Overview of the modified ResNet50 architecture used in this study. Four DropBlock layers are strategically inserted between the main stages, with block sizes of 9, 7, 5, and 3 applied sequentially. The classification head is modified to include a Dropout layer (rate = 0.2) followed by a Sigmoid activation function, producing six outputs for multi-label classification. Overview of the modified ResNet50 architecture used in this study. Four DropBlock layers are strategically inserted between the main stages, with block sizes of 9, 7, 5, and 3 applied sequentially. The classification head is modified to include a Dropout layer (rate = 0.2) followed by a Sigmoid activation function, producing six outputs for multi-label classification. Fig. 7Overview of the modified SwinV2T architecture. Four DropBlock layers are incorporated, with the first (block size = 9) applied after the linear embedding layer and before the initial Swin Transformer blocks, while subsequent DropBlock layers are inserted after Patch MergingV2 stages. The classification head includes a Dropout layer (rate = 0.2) and a Sigmoid activation function, yielding six outputs for multi-label classification. Overview of the modified SwinV2T architecture. Four DropBlock layers are incorporated, with the first (block size = 9) applied after the linear embedding layer and before the initial Swin Transformer blocks, while subsequent DropBlock layers are inserted after Patch MergingV2 stages. The classification head includes a Dropout layer (rate = 0.2) and a Sigmoid activation function, yielding six outputs for multi-label classification. Figure 8 illustrates the impact of applying DropBlock regularization by presenting feature maps from each main layer before and after its application. The modified feature maps are then propagated to subsequent layers. Various Dropout and DropBlock probabilities were evaluated using the ResNet50 model to identify the most effective configuration, which was subsequently adopted for training all models. Fig. 8Effect of DropBlock regularization on feature maps. Block sizes of 9, 7, 5, and 3 are applied to feature maps with spatial dimensions of 100, 50, 25, and 13, respectively. The first and third rows display feature maps prior to DropBlock application, while the second and fourth rows illustrate the corresponding outputs after DropBlock, which are then used as inputs to the next layer. Effect of DropBlock regularization on feature maps. Block sizes of 9, 7, 5, and 3 are applied to feature maps with spatial dimensions of 100, 50, 25, and 13, respectively. The first and third rows display feature maps prior to DropBlock application, while the second and fourth rows illustrate the corresponding outputs after DropBlock, which are then used as inputs to the next layer. Prior to training, all images are resized to 400 × 400 pixels. Each model architecture is then initialized, and the dataset is divided into training and validation subsets using stratified 5-fold cross-validation to ensure robust evaluation. Data augmentation is applied exclusively to the training set, while validation and test sets remain unaltered. To improve generalization, label smoothing35 is applied with a smoothing factor of α = 0.2. Instead of binary labels, smoothed labels are computed as:1\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\:{y}_{ls}=\left(1-\alpha\:\right){y}_{hot}+\alpha\:/k$$\end{document} where α = 0.2 represents the smoothing ratio, and k = 6 indicates the number of classes or labels. Here, \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\:{y}_{hot}$$\end{document} is an element from the labels, taking the value of 0 or 1. For instance, a label array [0, 0, 1, 0, 1, 0] is transformed into [0.166, 0.166, 0.866, 0.166, 0.866, 0.166]. This formulation reduces model overconfidence and encourages better generalization. Binary Cross-Entropy (BCE) is used as the loss function. In the multi-label setting, accuracy is defined as the Exact Match Ratio, which considers a prediction correct only if all labels are correctly identified. During inference, a threshold is applied to the Sigmoid outputs: values exceeding the threshold are assigned 1, indicating the presence of a disease, while others are set to 0. After empirical evaluation, a threshold of 0.25 was selected. Model optimization is performed using the Adam optimizer with an initial learning rate of 0.00005. A cosine annealing learning rate scheduler90 is applied, gradually reducing the learning rate to 0.00001 over 25 epochs, followed by an additional five epochs at a constant rate. Batch sizes of 10, 12, 16, and 20 are selected based on the memory requirements of each model. During training, all network parameters are updated, except for the decision thresholds. To further enhance performance, label-specific thresholds are optimized using a genetic algorithm and 23 SOAs, including FOA91, GWO92, MFO93, ALO94, JA95, WOA96, DO97, SSO98, SRSR99, SLO100, PFA101, HHO102, AO103, GWO_WOA104, MPA105, HBA106, SCSO107, TSO108, ARO109, ESOA110, GJO111, MGO112, SeaHO113. Only SOAs with two tunable parameters are considered, using population sizes of 30 and 600 iterations. The fitness function is defined based on six label-specific thresholds. For each of the five folds, both F1-score and accuracy are computed, resulting in ten objective values. Optimization is performed using outputs from the training subset, after which the models are re-evaluated using the optimized thresholds, and the results are averaged. Three experimental phases are conducted. The first phase investigates the impact of varying Dropout and DropBlock probabilities to identify optimal configurations. The second phase trains all models using the selected parameters. The final phase evaluates different SOAs to determine the optimal threshold configuration that maximizes both accuracy and F1-score. The configurations for these experiments are summarized in Tables 3 and 4. Table 3Configuration setup for the first and second experiment.ParameterDetailsTransfer LearningUsing Pretrained weights from ImageNetV1Output layer Activation FunctionSigmoidDropout probability0.2 (for the second experiment)Block sizes of DropBlocks9, 7, 5, 3DropBlock Probability0.05 (for the second experiment)Input Image Size400 × 400Total Number of Images18,632Number of Labels6Data Augmentation TechniquesRandom Flip, Shift, Rotation, Sharpness, applied to all imagesCross ValidationStratified 5 FoldsTrain : Validation : Test Ratio64 : 16 : 20Label Smoothing Ratio0.2Default Label Threshold0.25Number of Epochs30Initial Learning Rate0.00005Learning Rate SchedulerCosine Annealing, until epoch 25Final Learning Rate0.00001OptimizerAdamLoss FunctionBinary Cross Entropy for training, Hamming for final evaluation Table 3Configuration setup for the first and second experiment.ParameterDetailsTransfer LearningUsing Pretrained weights from ImageNetV1Output layer Activation FunctionSigmoidDropout probability0.2 (for the second experiment)Block sizes of DropBlocks9, 7, 5, 3DropBlock Probability0.05 (for the second experiment)Input Image Size400 × 400Total Number of Images18,632Number of Labels6Data Augmentation TechniquesRandom Flip, Shift, Rotation, Sharpness, applied to all imagesCross ValidationStratified 5 FoldsTrain : Validation : Test Ratio64 : 16 : 20Label Smoothing Ratio0.2Default Label Threshold0.25Number of Epochs30Initial Learning Rate0.00005Learning Rate SchedulerCosine Annealing, until epoch 25Final Learning Rate0.00001OptimizerAdamLoss FunctionBinary Cross Entropy for training, Hamming for final evaluation Configuration setup for the first and second experiment. Table 4Configuration setup for the optimization process of the thresholds (The third experiment).ParameterDetailsOptimization algorithmsGenetic Algorithm and 23 SOAsSOA selection criteriaOnly SOAs with two parameters were selectedEpochs600Population size30Lower boundary for thresholds0.1Upper boundary for thresholds0.7Optimization goalMaximizing the Accuracy (Exact Match Ratio) and F1-ScoreArchitectures usedFor each architecture, results from all five models trained on all five folds were taken into accountObjective weights0.1 for both Accuracy and F1-Score for each model trained on a fold, totaling 0.1 × 10 Table 4Configuration setup for the optimization process of the thresholds (The third experiment).ParameterDetailsOptimization algorithmsGenetic Algorithm and 23 SOAsSOA selection criteriaOnly SOAs with two parameters were selectedEpochs600Population size30Lower boundary for thresholds0.1Upper boundary for thresholds0.7Optimization goalMaximizing the Accuracy (Exact Match Ratio) and F1-ScoreArchitectures usedFor each architecture, results from all five models trained on all five folds were taken into accountObjective weights0.1 for both Accuracy and F1-Score for each model trained on a fold, totaling 0.1 × 10 Configuration setup for the optimization process of the thresholds (The third experiment). Results Following data preprocessing and augmentation, the images are input into the pretrained and modified architectures. Model performance is monitored using validation accuracy, and the best-performing model in each fold is saved. Each model is trained for 30 epochs per fold under a 5-fold cross-validation scheme and subsequently evaluated on the test set. Final results are reported as the average across the five folds. Table 5Results from experiments on DropBlock and Dropout probabilities Using ResNet50.DropBlock ProbabilityDropout ProbabilityAccuracyRecallPrecisionF1 Score 0.2 0.0 0.8589 0.9431 0.86750.9037 0.1 0.0 0.86640.93920.87770.9074 0.05 0.0 0.87010.93570.88220.9081 0.0 0.2 0.87170.93140.88610.9082 0.0 0.0 0.86970.93170.88330.9069 0.1 0.2 0.86880.93780.87950.9077 0.05 0.2 0.8725 0.93540.8851 0.9096 Table 5Results from experiments on DropBlock and Dropout probabilities Using ResNet50.DropBlock ProbabilityDropout ProbabilityAccuracyRecallPrecisionF1 Score 0.2 0.0 0.8589 0.9431 0.86750.9037 0.1 0.0 0.86640.93920.87770.9074 0.05 0.0 0.87010.93570.88220.9081 0.0 0.2 0.87170.93140.88610.9082 0.0 0.0 0.86970.93170.88330.9069 0.1 0.2 0.86880.93780.87950.9077 0.05 0.2 0.8725 0.93540.8851 0.9096 Results from experiments on DropBlock and Dropout probabilities Using ResNet50. The initial experiments aimed to identify optimal Dropout and DropBlock probabilities using the ResNet50 model. As summarized in Table 5, a DropBlock probability of 0.05 and a Dropout probability of 0.2 yielded the best performance, achieving an accuracy of 87.25% and an F1-score of 90.96%. These values were adopted for all subsequent experiments. In the second phase, all pretrained architectures were trained using 5-fold cross-validation and evaluated on the test set, with DropBlock and Dropout probabilities fixed at 0.05 and 0.2, respectively. A uniform threshold of 0.25 was applied across all labels for evaluation. Training and validation accuracy curves are presented in Figs. 9 and 10. As reported in Table 6 (prior to threshold optimization), ConvNeXt Tiny (ConvNeXtT) achieved the highest accuracy (89.41%), while SwinV2T attained the highest F1-score (91.72%) on the test set. Fig. 9Training accuracy of the 10 models used in this study. Training accuracy of the 10 models used in this study. Fig. 10Validation accuracy of the 10 models used in this study. Validation accuracy of the 10 models used in this study. As illustrated in Fig. 10, validation accuracy increased rapidly during the initial training phase, rising from approximately 76–81% to 82–86% within the first seven epochs. By epoch 10, most models converged to around 85% validation accuracy, with the exception of DenseNet201. Beyond epoch 15, performance improvements became more gradual, coinciding with the effect of the cosine annealing learning rate scheduler90, which progressively reduced the learning rate. During the final training phase, models such as ResNet50, ResNeXt50, and EfficientNetV2S appeared to reach performance saturation, whereas EfficientNetV2M, SwinV2T, Swin Transformer V2 Small (SwinV2S), and ConvNeXtT continued to exhibit incremental improvements. In the final phase, class-specific thresholds were optimized using a genetic algorithm and 23 SOAs. Each architecture, across all five folds, was optimized to jointly maximize accuracy and F1-score. The results are summarized in Table 6, while Table 7 ranks the optimization algorithms based on performance improvements. Among the evaluated methods, the Aquila Optimizer (AO)103 consistently achieved superior threshold optimization compared to other SOAs. After optimization, SwinV2T and SwinV2S emerged as the top-performing models, achieving accuracies of 90.3% and F1-scores of 91.68%, respectively. Table 6Results from the second and third experiment sets. The evaluation of the trained models with thresholds of 0.25 are shown on the left and their final evaluation using their optimized thresholds are shown on the right.ModelWith thresholds of 0.25With optimized thresholdsAccuracyRecallPrecisionF1 ScoreAccuracyRecallPrecisionF1 ScoreResNet500.8725± 0.00380.9354± 0.00290.8851± 0.00470.9091± 0.00220.8914± 0.00410.9033± 0.00540.9162± 0.00290.9093± 0.0035ResNeXt5032 × 4D0.8775± 0.00360.9321± 0.00240.8907± 0.00480.9106± 0.0020.894± 0.00210.9029± 0.00320.9188± 0.00240.9106± 0.0022RegNetY3.2GF0.8777± 0.00390.9295± 0.00460.8869± 0.0020.9071± 0.00180.8929± 0.00170.9091± 0.0060.9081± 0.00310.9084± 0.0022DenseNet2010.8595± 0.0040.9388± 0.00190.8684± 0.00370.9008± 0.00260.8891± 0.00410.9048± 0.0030.9048± 0.00470.9045± 0.0035EfficientNetV2S0.883± 0.00620.9257± 0.00660.8938± 0.00570.9088± 0.00340.8962± 0.00420.9041± 0.00790.9122± 0.0030.9079± 0.0044EfficientNetV2M0.8873± 0.0110.9192± 0.00460.897± 0.00810.9074± 0.00630.895± 0.00720.8994± 0.00510.9119± 0.00620.9053± 0.0043ConvNeXtT 0.8941 ± 0.0014 0.9312± 0.0021 0.9027 ± 0.003 0.9165± 0.00220.9025± 0.00190.914± 0.0026 0.9189 ± 0.0023 0.9162± 0.002ConvNeXtS0.8895± 0.00230.9302± 0.00380.8982± 0.00380.9137± 0.00110.89910.00150.9152± 0.00370.9125± 0.0030.9137± 0.002SwinV2T0.8909± 0.0022 0.939 ± 0.0032 0.8969± 0.0024 0.9172 ± 0.0013 0.903 ± 0.0039 0.9138± 0.00420.9186± 0.00280.9161± 0.0028SwinV2S0.8929± 0.00390.9333± 0.00520.8995± 0.00490.9159± 0.0030.9013± 0.0019 0.9212 ± 0.004 0.9127± 0.0045 0.9168 ± 0.0028 Table 6Results from the second and third experiment sets. The evaluation of the trained models with thresholds of 0.25 are shown on the left and their final evaluation using their optimized thresholds are shown on the right.ModelWith thresholds of 0.25With optimized thresholdsAccuracyRecallPrecisionF1 ScoreAccuracyRecallPrecisionF1 ScoreResNet500.8725± 0.00380.9354± 0.00290.8851± 0.00470.9091± 0.00220.8914± 0.00410.9033± 0.00540.9162± 0.00290.9093± 0.0035ResNeXt5032 × 4D0.8775± 0.00360.9321± 0.00240.8907± 0.00480.9106± 0.0020.894± 0.00210.9029± 0.00320.9188± 0.00240.9106± 0.0022RegNetY3.2GF0.8777± 0.00390.9295± 0.00460.8869± 0.0020.9071± 0.00180.8929± 0.00170.9091± 0.0060.9081± 0.00310.9084± 0.0022DenseNet2010.8595± 0.0040.9388± 0.00190.8684± 0.00370.9008± 0.00260.8891± 0.00410.9048± 0.0030.9048± 0.00470.9045± 0.0035EfficientNetV2S0.883± 0.00620.9257± 0.00660.8938± 0.00570.9088± 0.00340.8962± 0.00420.9041± 0.00790.9122± 0.0030.9079± 0.0044EfficientNetV2M0.8873± 0.0110.9192± 0.00460.897± 0.00810.9074± 0.00630.895± 0.00720.8994± 0.00510.9119± 0.00620.9053± 0.0043ConvNeXtT 0.8941 ± 0.0014 0.9312± 0.0021 0.9027 ± 0.003 0.9165± 0.00220.9025± 0.00190.914± 0.0026 0.9189 ± 0.0023 0.9162± 0.002ConvNeXtS0.8895± 0.00230.9302± 0.00380.8982± 0.00380.9137± 0.00110.89910.00150.9152± 0.00370.9125± 0.0030.9137± 0.002SwinV2T0.8909± 0.0022 0.939 ± 0.0032 0.8969± 0.0024 0.9172 ± 0.0013 0.903 ± 0.0039 0.9138± 0.00420.9186± 0.00280.9161± 0.0028SwinV2S0.8929± 0.00390.9333± 0.00520.8995± 0.00490.9159± 0.0030.9013± 0.0019 0.9212 ± 0.004 0.9127± 0.0045 0.9168 ± 0.0028 Results from the second and third experiment sets. The evaluation of the trained models with thresholds of 0.25 are shown on the left and their final evaluation using their optimized thresholds are shown on the right. 0.8725 ± 0.0038 0.9354 ± 0.0029 0.8851 ± 0.0047 0.9091 ± 0.0022 0.8914 ± 0.0041 0.9033 ± 0.0054 0.9162 ± 0.0029 0.9093 ± 0.0035 0.8775 ± 0.0036 0.9321 ± 0.0024 0.8907 ± 0.0048 0.9106 ± 0.002 0.894 ± 0.0021 0.9029 ± 0.0032 0.9188 ± 0.0024 0.9106 ± 0.0022 0.8777 ± 0.0039 0.9295 ± 0.0046 0.8869 ± 0.002 0.9071 ± 0.0018 0.8929 ± 0.0017 0.9091 ± 0.006 0.9081 ± 0.0031 0.9084 ± 0.0022 0.8595 ± 0.004 0.9388 ± 0.0019 0.8684 ± 0.0037 0.9008 ± 0.0026 0.8891 ± 0.0041 0.9048 ± 0.003 0.9048 ± 0.0047 0.9045 ± 0.0035 0.883 ± 0.0062 0.9257 ± 0.0066 0.8938 ± 0.0057 0.9088 ± 0.0034 0.8962 ± 0.0042 0.9041 ± 0.0079 0.9122 ± 0.003 0.9079 ± 0.0044 0.8873 ± 0.011 0.9192 ± 0.0046 0.897 ± 0.0081 0.9074 ± 0.0063 0.895 ± 0.0072 0.8994 ± 0.0051 0.9119 ± 0.0062 0.9053 ± 0.0043 0.8941 ± 0.0014 0.9312 ± 0.0021 0.9027 ± 0.003 0.9165 ± 0.0022 0.9025 ± 0.0019 0.914 ± 0.0026 0.9189 ± 0.0023 0.9162 ± 0.002 0.8895 ± 0.0023 0.9302 ± 0.0038 0.8982 ± 0.0038 0.9137 ± 0.0011 0.8991 0.0015 0.9152 ± 0.0037 0.9125 ± 0.003 0.9137 ± 0.002 0.8909 ± 0.0022 0.939 ± 0.0032 0.8969 ± 0.0024 0.9172 ± 0.0013 0.903 ± 0.0039 0.9138 ± 0.0042 0.9186 ± 0.0028 0.9161 ± 0.0028 0.8929 ± 0.0039 0.9333 ± 0.0052 0.8995 ± 0.0049 0.9159 ± 0.003 0.9013 ± 0.0019 0.9212 ± 0.004 0.9127 ± 0.0045 0.9168 ± 0.0028 Table 7Rankings of top SOAs for each trained model after finding the optimized thresholds.ModelBest algorithm2nd best algorithm3rd best algorithmResNet50 AO TSOSRSRResNeXt5032 × 4DJAMGOSSORegNetY3.2GFGWOALOHBADenseNet201GWO_WOA AO WOAEfficientNetV2S AO WOAHHOEfficientNetV2MSLOALOGJOConvNeXtTSRSRHBAALOConvNeXtSDOGJOSRSRSwinV2T AO SSOTSOSwinV2SSSOSCSOSRSR Table 7Rankings of top SOAs for each trained model after finding the optimized thresholds.ModelBest algorithm2nd best algorithm3rd best algorithmResNet50 AO TSOSRSRResNeXt5032 × 4DJAMGOSSORegNetY3.2GFGWOALOHBADenseNet201GWO_WOA AO WOAEfficientNetV2S AO WOAHHOEfficientNetV2MSLOALOGJOConvNeXtTSRSRHBAALOConvNeXtSDOGJOSRSRSwinV2T AO SSOTSOSwinV2SSSOSCSOSRSR Rankings of top SOAs for each trained model after finding the optimized thresholds. Overall, the application of SOA-based threshold optimization led to consistent performance improvements across all models. Notably, DenseNet201 exhibited the largest gain in accuracy, potentially due to its initial underfitting behavior, which resulted in higher output variance prior to threshold adjustment. The optimized thresholds effectively refined decision boundaries for disease presence. The Exact Match Ratio (accuracy), F1-score, mean Average Precision (mAP), and Hamming Loss, along with their standard deviations, are presented in Figs. 11, 12, 13 and 14. Fig. 11Exact match ratio (Accuracy) diagrams obtained by the ten models with optimized thresholds. Exact match ratio (Accuracy) diagrams obtained by the ten models with optimized thresholds. Fig. 12F1-score diagrams obtained by ten models with optimized thresholds. F1-score diagrams obtained by ten models with optimized thresholds. Fig. 13Mean Average Precision (mAP) diagrams obtained by the ten models with optimized thresholds. Mean Average Precision (mAP) diagrams obtained by the ten models with optimized thresholds. Fig. 14Hamming Loss diagrams obtained by ten models with optimized thresholds. Hamming Loss diagrams obtained by ten models with optimized thresholds. Among the evaluated architectures, ConvNeXtT, SwinV2T, and SwinV2S consistently ranked among the top performers across Hamming Loss, Exact Match Ratio, and macro F1-score. These results indicate their superior ability to capture label co-occurrence patterns and global contextual information. Architectural features such as large-kernel convolutions, patch-based processing, shifted-window attention, and layer scaling likely contribute to these improvements over traditional residual and densely connected networks. Interestingly, ResNet50 and ResNeXt50 32 × 4 d achieved the highest mAP scores despite comparatively lower performance in Exact Match Ratio and Hamming Loss. This discrepancy suggests that mAP, which emphasizes ranking quality, is less sensitive to precise multi-label prediction and label interaction modeling. It also reflects the strong representational capabilities of these well-established architectures, benefiting from extensive pretraining and architectural refinement. Despite these advancements, the highest Exact Match Ratio remained below 91%, highlighting the inherent difficulty of achieving fully correct multi-label predictions. This limitation may be attributed to factors such as complex backgrounds, label ambiguity, and potential annotation noise, which remain challenging even for state-of-the-art architectures. Label-wise analysis As shown in Table 8, disease-specific evaluation based on per-class recall, precision, and F1-score reveals consistent performance patterns across the six categories. Both ConvNeXtT and SwinV2T achieved excellent results for the Healthy and Powdery Mildew classes, with F1-scores exceeding 0.99 and 0.96, respectively. This indicates a strong capability to distinguish healthy leaves from those exhibiting clear disease symptoms. In particular, Powdery Mildew, characterized by distinctive white textures and leaf deformation, presents visually salient features that are readily captured by both human observers and learning-based models. Detection performance for Scab and Rust was also robust, with F1-scores of approximately 0.93 for both architectures. In contrast, Frog eye leaf spot yielded moderate performance, with F1-scores of 0.9022 and 0.9052 for ConvNeXtT and SwinV2T, respectively. The Complex category, which includes images with multiple or ambiguous disease symptoms, proved to be the most challenging, with the lowest F1-scores (0.768 for ConvNeXtT and 0.767 for SwinV2T). This reflects the inherent difficulty of distinguishing overlapping or co-occurring disease patterns. Overall, SwinV2T exhibited marginal advantages over ConvNeXtT in four out of six classes. However, these differences were minimal (absolute F1 differences < 0.003), indicating comparable per-class discriminative performance despite their fundamentally different architectural paradigms—modernized convolutional design versus shifted-window self-attention. The consistently high precision and recall observed for Healthy, Scab, Powdery Mildew, and Rust suggest effective feature extraction for well-defined visual patterns. Conversely, the lower performance on the Complex class highlights a shared limitation in modeling composite and ambiguous symptom representations. Addressing this challenge may require more advanced strategies, such as explicit modeling of label dependencies or the incorporation of contrastive and multi-task learning objectives in future work. Table 8Performance comparison of individual labels for ConvNeXtT and SwinV2T with optimized thresholds.ModelLabelRecallPrecisionF1 ScoreConvNeXtTScab0.92880.93970.9341Healthy0.99240.99170.9921Frog eye leaf spot0.90270.90230.9022Rust0.93990.92580.9327Complex0.75540.78230.7680Powdery Mildew0.96450.97150.9679SwinV2TScab0.93290.93520.9341Healthy0.99370.98710.9904Frog eye leaf spot0.90410.90660.9052Rust0.93260.93360.9331Complex0.75730.77750.7672Powdery Mildew0.96220.97140.9667 Table 8Performance comparison of individual labels for ConvNeXtT and SwinV2T with optimized thresholds.ModelLabelRecallPrecisionF1 ScoreConvNeXtTScab0.92880.93970.9341Healthy0.99240.99170.9921Frog eye leaf spot0.90270.90230.9022Rust0.93990.92580.9327Complex0.75540.78230.7680Powdery Mildew0.96450.97150.9679SwinV2TScab0.93290.93520.9341Healthy0.99370.98710.9904Frog eye leaf spot0.90410.90660.9052Rust0.93260.93360.9331Complex0.75730.77750.7672Powdery Mildew0.96220.97140.9667 Performance comparison of individual labels for ConvNeXtT and SwinV2T with optimized thresholds. Computational deployment comparison All models in this study were trained, validated, and tested on a personal workstation equipped with an Intel i7-7700 CPU, 16 GB of RAM, and an NVIDIA GTX 1080 Ti GPU with 11 GB of VRAM. The system operated on Windows 10, with CUDA Toolkit v11.7 installed to enable GPU acceleration. Python was used as the programming language, and PyTorch served as the primary DL framework for model implementation. The computational efficiency of the evaluated models was assessed using three standard metrics. Floating Point Operations (FLOPs) quantify the total number of arithmetic operations—primarily multiplications and additions—required to process a single input through the network. The number of parameters reflects the total count of trainable weights and biases, serving as an indicator of model capacity and architectural complexity. Inference time measures the latency required to process a single image and can also be expressed in frames per second (FPS) to indicate real-time performance. The comparative results are summarized in Table 9. Table 9Computational performance of trained models.ModelParameter CountFLOPsInference Time (s)Inference Time (FPS)ResNet5023,520,32613,359,457,2800.0076130ResNeXt5032 × 4D22,992,19813,839,951,8720.0094105RegNetY3.2GF17,932,41610,316,087,8640.015564DenseNet20118,104,45413,907,047,4240.029733EfficientNetV2S20,185,1749,394,521,0240.020548EfficientNetV2M52,866,04217,785,164,6720.030332ConvNeXtT27,824,74214,043,361,152 0.0069 144 ConvNeXtS49,459,30227,543,361,1520.013474SwinV2T27,587,1849,644,957,1840.023442SwinV2S48,973,05618,534,710,7840.041124 Table 9Computational performance of trained models.ModelParameter CountFLOPsInference Time (s)Inference Time (FPS)ResNet5023,520,32613,359,457,2800.0076130ResNeXt5032 × 4D22,992,19813,839,951,8720.0094105RegNetY3.2GF17,932,41610,316,087,8640.015564DenseNet20118,104,45413,907,047,4240.029733EfficientNetV2S20,185,1749,394,521,0240.020548EfficientNetV2M52,866,04217,785,164,6720.030332ConvNeXtT27,824,74214,043,361,152 0.0069 144 ConvNeXtS49,459,30227,543,361,1520.013474SwinV2T27,587,1849,644,957,1840.023442SwinV2S48,973,05618,534,710,7840.041124 Computational performance of trained models. Overall, the results reveal a clear trade-off between architectural complexity and inference efficiency. CNN-based models, such as ConvNeXtT and ResNet50, achieve the fastest inference speeds, making them well-suited for real-time or edge deployment scenarios. Although transformer-based architectures from the SwinV2 family demonstrate strong representational capacity, their higher computational latency may limit their applicability in time-sensitive agricultural monitoring systems. Furthermore, models such as EfficientNetV2M and ConvNeXt Small (ConvNeXtS) illustrate that increasing model scale substantially raises computational cost without yielding proportional improvements in inference efficiency. Notably, RegNetY3.2GF provides a favorable balance between parameter count and FLOPs; however, it does not achieve the lowest inference latency among the evaluated models. Discussion Accurate diagnosis of plant diseases is essential for minimizing yield losses and ensuring agricultural sustainability. Although expert-driven inspection by plant pathologists can provide reliable results, it is inherently time-consuming, costly, and subject to human bias. In contrast, DL and computer vision offer scalable, efficient, and cost-effective alternatives for automated disease detection. Deploying trained models on embedded systems, such as single-board computers, enables integration with drones or agricultural machinery, facilitating real-time crop monitoring and targeted intervention (e.g., fungicide spraying) across large-scale farming environments. In this study, the Plant Pathology 2021 dataset from Cornell University, comprising 18,632 apple leaf images, was utilized. The original multi-class annotation scheme (12 classes) was transformed into a multi-label format by encoding each sample as a six-dimensional label vector representing disease presence and healthy conditions. To address class imbalance and improve generalization, data augmentation techniques—including flipping, rotation, shifting, and sharpening—were applied. While sharpening proved beneficial, other augmentations such as median and Gaussian blurring, alternative color spaces (HSV and YCbCr), and negative image transformations did not yield performance improvements. An input resolution of 400× 400 pixels was selected to preserve spatial detail while maintaining computational efficiency. A transfer learning strategy was adopted using pretrained ImageNet-1K75 models, including eight CNN-based architectures and two transformer-based models from the SwinV2 family. To enhance generalization, Dropout (rate = 0.2) and multiple DropBlock layers were incorporated, alongside label smoothing (α = 0.2) and a cosine annealing learning rate scheduler. Among the evaluated models, ConvNeXt demonstrated consistently strong performance, while SwinV2-based architecture exhibited superior learning efficiency, achieving competitive accuracy within fewer training epochs under identical conditions. Given the multi-label formulation, a thresholding mechanism was required to convert model outputs into final predictions. In the final experimental phase, thresholds were optimized using 23 SOAs in conjunction with a genetic algorithm. The Aquila Optimizer (AO)103 achieved the best performance in identifying optimal thresholds. After optimization, ConvNeXtT and SwinV2T remained the top-performing models. However, a clear computational advantage was observed for ConvNeXtT, which achieved an inference speed of 144 FPS, significantly outperforming SwinV2T (42 FPS) and SwinV2S (24 FPS). These findings indicate that ConvNeXtT provides an effective balance between predictive performance and computational efficiency, making it particularly suitable for deployment in resource-constrained environments. Additional techniques were explored to further enhance performance. Learning rate schedulers that incorporate cyclic increases (e.g., triangular scheduling114 resulted in performance degradation. A modified CutMix strategy115, involving the combination of cropped image regions at a resolution of 400 × 400 pixels, did not improve overall accuracy but yielded performance gains for multi-disease classes (e.g., Powdery Mildew/Complex and Rust/Frog Eye Leaf Spot). Figure 14 illustrates an example of an image generated using this customized CutMix approach. Overall, this study demonstrated the effectiveness of combining modern DL architectures, multi-label classification, and swarm-based optimization techniques for plant disease diagnosis. Future work may focus on improving the modeling of complex disease interactions, incorporating larger and more diverse datasets, and optimizing architectures for real-time deployment in precision agriculture systems. Fig. 15Example of an image created by the special CutMix recipe. Example of an image created by the special CutMix recipe. Performance comparison and analysis Most classification errors observed in this study are associated with the Complex class. This category represents leaves exhibiting ambiguous or overlapping symptoms that cannot be clearly attributed to a single disease. Such symptoms often resemble those of other classes, particularly Scab, making accurate discrimination challenging. Although the Complex class contains a relatively limited number of samples, data scarcity alone does not fully explain the observed misclassification, as the Powdery Mildew class—despite having fewer samples—was classified with high accuracy. A more plausible explanation lies in the inherent visual similarity between Complex samples and other disease categories, which complicates feature separation. In addition, potential inaccuracies in expert annotations may introduce label noise, further hindering model performance. Another contributing factor, illustrated in Fig. 16, is the presence of complex backgrounds, including soil, fruits, and other environmental elements, which can obscure disease-specific features and reduce classification reliability. Collectively, these factors highlight the challenges associated with modeling ambiguous and heterogeneous disease patterns. Fig. 16Examples of images from the Plant Pathology 2021 dataset showing complex or unrelated backgrounds. Examples of images from the Plant Pathology 2021 dataset showing complex or unrelated backgrounds. Some studies report higher performance metrics than those achieved in the present work; however, these differences can largely be attributed to variations in experimental design. In this study, 64% of the dataset was used for training, 16% for validation, and 20% for testing, with the test set reserved for final evaluation before and after threshold optimization. In contrast, previous studies have allocated a larger proportion of data for training (e.g., 75%67 to 80%55), which can lead to improved model fitting. Moreover, several studies employ ensemble learning strategies, combining multiple models to enhance feature representation and improve predictive performance. For instance55, utilized advanced pretrained models initialized on ImageNet-1K75 or ImageNet21K116, along with extensive architectural modifications, including Gaussian Dropout and leaky ReLU activations. Similarly67, adopted a multi-label framework but used a smaller test set (15%), while the present study reserves 20% for evaluation, resulting in stricter performance assessment. Differences in dataset composition and evaluation protocols also complicate direct comparisons. Variations in test set characteristics—such as background complexity, noise levels, and image quality—can significantly influence reported performance. Additionally57, focused exclusively on five single-label classes (Scab, Healthy, Rust, Frog Eye, and Complex), excluding multi-disease and Powdery Mildew categories, and employed a 10-fold cross-validation scheme with a separate 15% test set. Such methodological differences highlight the importance of standardized evaluation frameworks for fair and meaningful comparison across studies. Future work Future research directions may focus on several strategies to further enhance model performance and robustness in plant disease classification. First, integrating multiple trained models into an ensemble framework could improve predictive accuracy by leveraging complementary feature representations and reducing model-specific biases. In addition, the use of Generative Adversarial Networks117 for synthetic data generation may provide more diverse and realistic samples compared to conventional data augmentation techniques, thereby improving model generalization. Another promising direction is the implementation of a dual-threshold mechanism, where upper and lower decision thresholds are defined. Predictions falling between these thresholds could be flagged as uncertain and referred to as expert annotation. Over time, incorporating these newly labeled samples into the training set could enhance model robustness and accuracy. An alternative modeling strategy involves training separate binary classifiers for each label, where each model independently predicts the presence or absence of a specific disease. The outputs of these classifiers can then be combined to form a multi-label prediction vector. Within this framework, an image would be classified as healthy if all classifiers predict the absence of disease. Certain advanced techniques were not explored in this study due to methodological constraints. For instance, Online Label Smoothing118, which has shown performance improvements in multi-class settings, is not directly applicable to multi-label classification tasks. Similarly, the use of “Noisy Student” training119, which enhances robustness to label noise, is primarily associated with the EfficientNet framework and was not considered in the present work. Finally, further investigation into the configuration of DropBlock regularization is warranted. In this study, block sizes of 9, 7, 5, and 3 were selected to align with progressively decreasing feature map resolutions across network layers. However, optimizing these parameters through systematic experimentation may yield improved regularization effects and overall model performance. Conclusion Early detection of plant leaf diseases enables timely intervention through appropriate pesticide applications, thereby limiting disease spread and reducing crop losses. Although substantial research has been conducted in this domain, the present study explored both convolutional and transformer-based architectures, including CNNs and ViT models, which have received comparatively less attention in plant disease diagnosis. In addition, DropBlock—a powerful yet underutilized regularization technique—was systematically integrated into the feature extraction layers of these architectures to enhance generalization. To address the realistic scenario in which multiple diseases may co-occur on a single leaf, a multi-label classification framework was adopted instead of a conventional multi-class approach. This formulation provides greater flexibility in modeling complex disease combinations. Furthermore, unlike standard multi-label methods that apply a uniform decision threshold, this study introduced label-specific threshold optimization using 23 SOAs, leading to improved classification performance. Complementary techniques, including data augmentation and additional regularization strategies, were also employed to strengthen model learning. The results from three experimental phases demonstrated that incorporating DropBlock and Dropout with probabilities of 0.05 and 0.2, respectively, significantly enhances model performance. Moreover, recent architectures consistently outperformed earlier models in terms of classification accuracy and F1-score. Among the evaluated optimization methods, the Aquila Optimizer proved to be the most effective in identifying optimal thresholds for most architectures, while other modern nature-inspired algorithms also demonstrated improvements over traditional approaches. Overall, the proposed framework, combining advanced DL architectures, multi-label classification, and swarm-based threshold optimizations, has shown strong potential for real-world deployment. These findings support the development of efficient, hardware-integrated plant disease diagnosis systems capable of delivering accurate and timely predictions in practical agricultural environments.