论文信息

Mohammad Monirul Islam / Md. Anisur Rahman / Md. Masum Billah 等 5 人

Scientific Reports

论文解读

AI 辅助整理
方法
ResNet50与ViT融合,多头交叉注意力,Split-then-Augmen
发现
模型准确率97%,注意力与生物特征对齐,泛化性强,推理快,适合边缘部署。
机会点
可探索模型在更多作物害虫识别中的迁移,或结合边缘设备实现实时监测,并优化轻量化结构。

论文摘要

虫害侵袭对全球番茄生产构成致命威胁,常导致毁灭性的产量损失和经济不稳定。传统的人工识别方法主观性强、劳动密集且易出错。为此,在农业5.0(Agriculture 5.0)范式下,我们提出了一种新颖的混合深度学习模型ResNet50-Fusion(ViT),专用于精准检测六种具有经济重要性的番茄害虫。该架构通过多头交叉注意力(Multi-Head Cross-Attention)机制整合ResNet50主干与视觉Transformer(Vision Transformer, ViT)分支,实现非对称语义对齐,从而能够同时提取细粒度形态特征与全局上下文模式。为确保科学严谨性并消除数据泄漏风险,我们实施了“先分割后增强”(Split-then-Augment)协议,使测试集保持完全独立且原始状态。该框架实现了97.00%±0.12%的最先进测试准确率,显著优于ResNet50(96.44%)和DenseNet169(96.00%)等基线模型,同时展现出高计算效率,平均推理延迟为每张图像26.6毫秒,适用于实时边缘部署。除预测精度外,模型的可靠性还通过整合语义指标的多方法定量可解释人工智能(Explainable AI, XAI)框架得到验证,包括用于特征对齐的语义定位分数(Semantic Localization Score, SLS)、用于逻辑稳定性的鲁棒性分数(Robustness Score, RS)以及用于决策一致性的可解释性可靠性系数(Interpretability Reliability Coefficient, IRC)。结果表明,我们的模型实现了96.5%的指向游戏准确率(Pointing Game Accuracy)和较低的删除AUC(0.142),说明模型的注意力模式与生物学相关的形态特征高度一致,而非背景伪影。系统性遮挡敏感性分析进一步证实了模型的鲁棒性,稳定性得分为0.988。最后,在包括IP102和Pest24在内的世界规模数据集上进行的外部验证,通过直接推理获得了超过90%的准确率,证明了该框架在多样化自动化田间监测条件下的泛化能力。本研究为全球精准农业中的实时害虫识别提供了一种精准、稳健且可扩展的解决方案。

全文

Scientific Reports

ARTICLE | Article in Press
Scientific Reports https://doi.org/10.1038/s41598-026-66844-z
Scientific Reports
This Article in Press is shared early to give you faster access to new research. It is citable and carries a permanent DOI.
The final edited version will replace it automatically.
Deep learning and computer vision framework for
tomato insect classification with XAI insights
Mohammad Monirul Islam · Md. Anisur Rahman · Md. Masum Billah · Morium Akter ·
Mohammad Shorif Uddin
Received: 22 April 2026 / Accepted: 10 August 2026
© The Author(s) 2026
Abstract
Pest infestations pose a life-threatening challenge to global tomato production, often resulting in devastating
yield losses and economic instability. Traditional manual identification practices are subjective, labor-intensive,
and prone to error. To address this, within the paradigm of Agriculture 5.0, we introduce a novel hybrid deep
learning model, ResNet50-Fusion (ViT), designed for the precise detection of six economically relevant tomato
pests. The proposed architecture integrates a ResNet50 backbone with a Vision Transformer (ViT) branch via
a Multi-Head Cross-Attention mechanism that facilitates asymmetric semantic alignment, enabling the simul -
taneous extraction of fine-grained morphological features and global contextual patterns. To ensure scientific
rigor and eliminate the risk of data leakage, a ‘Split-then-Augment’ protocol was implemented, keeping the
test set entirely independent and original. The framework achieved a state-of-the-art test accuracy of 97.00% ±
0.12%, significantly outperforming baseline models such as ResNet50 (96.44%) and DenseNet169 (96.00%),
while demonstrating high computational efficiency with an average inference latency of 26.6 ms per image for
real-time edge deployment. Beyond predictive accuracy, the model’s reliability was validated using a multi-
method quantitative Explainable AI (XAI) framework integrating semantic indicators: Semantic Localization
Score (SLS) for feature alignment, Robustness Score (RS) for logical stability, and Interpretability Reliability
Coefficient (IRC) for decision consistency. Our results demonstrate a 96.5% Pointing Game Accuracy and a
low Deletion AUC (0.142), indicating that the model’s attention patterns strongly align with biologically rel -
evant morphological features rather than background artifacts. Systematic occlusion sensitivity analysis further
confirmed model robustness with a stability score of 0.988. Finally, external validation on world-scale datasets,
including IP102 and Pest24, yielded accuracies exceeding 90% via direct inference, demonstrating the general -
izability of the framework to diverse automated field monitoring conditions. This research provides a precise,
robust, and scalable solution for real-time pest identification in global precision agriculture.
Keywords Deep learning · Tomato pest classification · ResNet50 · Vision transformer (ViT) · Explainable
AI (XAI) · Precision agriculture

Article in Press
Scientific Reports
https://doi.org/10.1038/s41598-026-66844-z
Introduction
Global horticulture deeply relies upon the tomato (Solanum lycopersicum), as its foodstuff and a source of agri -
cultural income. Nevertheless, this commodity is becoming more and more unstable; in the present economic
projections covering the year 2025, the production in such key markets as Mexico, Tu"rkiye, and the United
States is being subjected to extreme pressure due to the price sensitivity and changes in policies 1. Further com-
plicating these economic problems are biotic stressors, specifically invasive insect pests, e.g., Cotton Bollworm
(Helicoverpa armigera) and Silverleaf Whitefly (Bemisia tabaci). These pests cause post- and pre-harvest losses
in yields2.
Manual scouting and calendar-based application of pesticides used to be the traditional methods of pest man -
agement. They are labor-intensive and also subject to human error, and in most cases, end up causing indis -
criminate use of agrochemicals, resulting in environmental pollution and pest resistance. The paradigm of the
so-called Agriculture 5.0 has brought up to solve these inefficiencies, incorporating Artificial Intelligence (AI)
to mechanize crop monitoring. Deep learning models Lightweight deep learning models can be combined with
other models to produce promising results in the agricultural pest classification task, where models can be trained
to high accuracy at reduced computational cost through the use of lightweight transfer-learning architectures3,4.
A 2024 literature review highlights that despite the increasing use of AI, the issue of explainability of these
models is still a major obstacle to trust among farmers, who need clarity of information and not an automated
response5.
The use of Convolutional Neural Networks (CNNs) as Deep Learning (DL) models has become increasingly
prevalent in automated pest detection. Nevertheless, they have been overstated in the real world. An extensive
2024 review of real-field data states that the majority of research available uses clean laboratory data, which
does not transfer to the complicated, disheveled conditions of real tomato fields 6. Moreover, conventional CNN
architectures have intrinsic inductive biases: they have strong local receptive fields and are unable to extract long-
range relations and global context to differentiate pests from complex backgrounds7.
To address these shortcomings, this work presents a new ResNet50-Fusion (ViT) that combines the effective-
ness of local feature extraction in ResNet50 with the global attention of Vision Transformers (ViT). The combi-
nation of these two paradigms in the model provides a clear picture of the microscopic morphological structures
of insect pests, as well as the macrostructural environment. This technique can overcome the limitations of pure
CNNs, which tend to be confused by occlusions and changes in lighting in field conditions. The proposed frame-
work was rigorously tested on state-of-the-art benchmarks, such as DenseNet169, InceptionV3, and Mobile -
NetV2, and achieved a classification rate of 97.00%.
Tomato cultivation is remarkably versatile, ranging from high-tech industrial operations to small-scale house-
hold production. Figure 1 highlights this environmental diversity, contrasting (a) a structured commercial farm
with uniform planting rows against (b) a private balcony garden subject to variable outdoor lighting and clut -
tered backgrounds. Despite these differences in scale and setting, insect pests remain a universal threat in both
scenarios.
To mitigate the model’s vulnerability to data scarcity and class imbalance, we selected a dataset comprising
six pest classes: Cotton Bollworm, Oriental Fruit Fly, Peach Aphid, Silverleaf Whitefly, Thrips, and Two-spotted
Spider Mite. It used a strict preprocessing pipeline that included synthetic oversampling and geometric augmen-
tation (rotation, zoom, and shear) to produce a perfectly balanced dataset of 3,000 images (500 per class). This
plan relates to the recent 2025 results, which show that certain data additions can be critical for enhancing the
model’s generalization performance in a sustainable environment 8. We develop effective solutions that explore
insect-focused architectures to capture both local texture/shape features and global visual patterns. It employs
robust training strategies, including data augmentation and class-imbalance handling, to address long-tailed dis-
tributions of pest occurrences. It further combines various XAI techniques to ensure that predictions are based

Article in Press
Scientific Reports
https://doi.org/10.1038/s41598-026-66844-z
on biologically relevant insect characteristics rather than background artifacts, and agronomists have trusted it.
These loopholes fueled the need to formulate a tomato insect classification framework.
Related works
The advances in tomato pest/disease recognition have been tremendous, driven by deep convolutional neural
networks (CNNs) and, more recently, Transformer architectures. The problem is usually stated in other published
works as image classification with transfer learning (e.g., VGG/ResNet/EfficientNet families), and performance
is typically reported as accuracy and/or precision/recall per class. Those techniques are highly effective in the
cases of controlled imaging conditions. Nevertheless, they fail to generalize to field conditions where there is a
change of backgrounds, lighting and occlusions or an imbalanced dataset among pest categories.
Numerous works use a single CNN backbone, end-to-end trained or fine-tuned on ImageNet weights, achiev-
ing good accuracy in tomato disease/pest prediction (e.g., EfficientNet variants and residual networks). Post-hoc
interpretation is also used in conjunction with efficient CNNs (e.g., Grad-CAM and LIME) to make users more
confident and to display visual evidence of the predicted classification9,10. Although these techniques show good
performance, they tend to focus on overall test accuracy, which can mask problems with class imbalance and
errors in minority classes.
ViT and attention systems have been investigated to capture long-range relations and global context in plant
imagery11. Hybrid CNN-Transformers can also be compiled to jointly benefit from both local features and global
self-attention, such as EfficientNet-ViT ensembles 12 and EfficientNetV2-Swin fusion 13. Simultaneously, detec-
tion/segmentation pipelines (such as YOLOv8-based) have been used when pests need to be located and when
operating in cluttered2,14. Transformer-only models can be strong but might require more data to stabilize train -
ing, while CNN-only models can lack a global view, which is why hybrid designs are encouraged.
The integration of CNN-Transformer hybrids is increasingly gaining traction in various agricultural domains
beyond pest classification. Recent studies have successfully employed similar paradigms for multi-stage crop
disease detection and high-resolution diagnostic tasks15,16. For instance, Saleem et al.15 demonstrated that hybrid
architectures effectively capture subtle leaf textures while maintaining global spatial context. Similarly, Li et
al.16 showed that combining Transformer and CNN backbones enhances pest detection robustness in complex
Fig. 1 Diverse environments for tomato cultivation targeted by this study. (a) A commercial agricultural site with high plant
density and controlled spacing. (b) A private urban balcony garden, representing small-scale production with complex back-
ground noise and uncontrolled lighting (CC0 license).

Article in Press
Scientific Reports
https://doi.org/10.1038/s41598-026-66844-z
backgrounds. Our ResNet50-Fusion (ViT) model builds upon these advancements by tailoring the multi-head
cross-attention mechanism specifically for the morphological intricacies of tomato pests.
Compared with studies on tomato disease classification, relatively few explicitly address insect/pest recogni -
tion in real cultivation conditions, particularly for small, highly deformable insects that sometimes appear under
clutter/occlusion. Indicatively17, suggested improved YOLOv4 detectors for detecting tomato pests and achieved
good detection rates on a labelled tomato pest dataset 17. In a similar vein 18, examined the issue of deep neu -
ral models for detecting tomato leaf miner infestation using classification (ResNet152-based) and segmentation
(Mask R-CNN-based) pipelines, with some of the tomato leaf images collected in real-world settings. In addition
to tomato-specific data, large-scale data, including IP102, also helped accelerate the study of insect pest recogni-
tion by providing numerous pest categories and insights into both classification and detection19.
Due to the black-box nature of deep models, explainability techniques such as LIME, Grad-CAM, and Grad-
CAM + + are becoming increasingly important for visualizing decision regions and ensuring that predictions
are driven by biologically relevant cues rather than background noise 9,10. Nonetheless, many studies offer only
qualitative heatmaps and fail to systematically compare multiple explanation methods or examine explanation
consistency across classes. Table 1 summarizes recent research on pest insect classifications. The advancement
of Agriculture 5.0 demands models that are not only accurate but also versatile for complex field environments.
In recent years, more fine-grained approaches, like pest counting based on Object-Level Supervision 20 and the
use of Visual Prompts to improve the robustness of the localization of small pests21 have emerged. Although our
ResNet50-Fusion (ViT) network is designed for high-precision classification, it is noted that the architecture
extracts both local morphological features and global contextual patterns, which can serve as a potentially useful
architecture for applications such as these in modern field perception systems.
Throughout this manuscript, the proposed hybrid architecture is consistently designated as the ResNet50-
Fusion (ViT) model, and the evaluation metrics for semantic interpretation (SLS, RS, and IRC) are unified under
the term ‘semantic evaluation metrics’ to ensure technical clarity and linguistic consistency.
In general, the literature on tomato vision remains strongly biased toward detecting leaf diseases, whereas
less-studied literature focuses on identifying and counting insect pests in the field 17,18. It is a severe constraint,
as yield and quality decrease directly due to insects, and timely, specific, class-related pest detection is essential
Study Model(s) used Task type Target (Pest/Disease) Metric Value
(%)
22 YOLO-LCE
(Lightweight YOLOv8

  • LCR)
    Detection 24 Classes (Pest24 Dataset) mAP@0.5 63.9
    3 MobileNetV2 + Efficient-
    NetB0 (Fusion)
    Classification 22 Classes (Cassava, Cashew,
    Maize, Tomato)
    Accuracy 89.50
    23 RicePest-YOLO
    (Enhanced YOLOv8n)
    Detection RicePests
    (Small/Dense targets)
    mAP@0.5 94.30
    24 Improved YOLOv11n
    (C3k2-ConvFormer)
    Detection Rice Pests (Field Environment) mAP@0.5 95.50
    25 SEDCN-YOLOv8 Detection Cucumber Leaf Pests and
    diseases
    mAP@0.5 75.1
    2 YOLOv8 + ChatGPT
    (LLM Integration)
    Detection Tomato Pests & Dis-
    eases
    Precision 98.91
    26 CustomCNN(RM-
    Sprop Optimizer)
    Classification 8TomatoPest
    Species
    Accuracy 89.09
    27 ResNet-50(Transfer
    Learning)
    Classification TomatoLeafDis-
    eases
    Accuracy 99.96
    28 MobileNetV2 (Edge AI
    Optimization)
    Classification TomatoDiseases
    (Tamil Nadu)
    Accuracy 99.90
    4 VGG-16 Classification TomatoLeafDis-
    eases
    Accuracy 99.20
    Table 1 Summary of recent
    research on pest and insect
    classification in agriculture
    (2022–2025).

Article in Press
Scientific Reports
https://doi.org/10.1038/s41598-026-66844-z
for targeted intervention (e.g., the right choice of pesticide, its dosage, and treatment period). Therefore, there is
a need for.
(i) insect-centered architectures that capture both local texture/shape cues and global context,
(ii) robust training strategies (augmentation and imbalance handling) to cope with long-tailed pest occurrences,
and.
(iii) Integrated, multi-method XAI so agronomists can verify that predictions rely on biologically meaningful
insect cues rather than background artifacts. These gaps motivate our proposed framework for tomato insect
classification with explainable insights.
System architecture
The suggested framework is a lean client-server model for diagnosing tomato pests in real time, as shown in
Fig. 2. The user layer provides the starting point for the workflow, as a mobile application captures images of the
leaves and sends them to a high-performance cloud backend via a secure API. This system is based on the Infer-
ence Engine, which hosts the ResNet50-Fusion (ViT) network to classify insect pests with high accuracy, and a
parallel Explanation Module generates LIME and Grad-CAM visual explanations to understand the model’s deci-
sion-making. The system uses a Knowledge Base to look up the diagnosis and match it to biological or chemical
control measures once the pest is identified. The combined output, comprising classification results, visual XAI
evidence, and remediation advice, is then directly conveyed to the user in real time to assist with immediate field
management.
The mathematical approach of inference begins with the input image I ∈ RH×W ×C , and H, W, and C are height,
width, and color channels, respectively. The ResNet50-Fusion (ViT) takes local spatial features ′Fcnn as the back-
bone of Resnet50 in the first step, as Fcnn = HResN et (I). Then, they are processed by the Vision Transformer (ViT)
component using Multi-Head Self-Attention (MSA) as follows in Eq. (1):
Fig. 2 System architecture design of the proposed system.

Article in Press
Scientific Reports
https://doi.org/10.1038/s41598-026-66844-z

MSA (Q ,K ,V )= Softmax
(
QKT
√dk
)
V (1)
The query, key, and value matrices, Q, K, and V , on the basis of the input embeddings and dk is the scaling factor.
The obtained representations are combined into a composite feature Zhybrid balance and sent to a fully connected
layer to generate the final probability distribution of P (y) in accordance with the target classes of pest in Eq. (2):
P (y)= Softmax (Wc · Zhybrid + bc) (2)
Wc and bc In this instance, refer to the classifier’s weights and biases to ensure the output provides a normalized
probability score for each possible pest category.
Methodology
The overall methodological framework of this study is illustrated in Fig. 3, which outlines a rigorous pipe -
line designed to ensure high classification accuracy while maintaining statistical integrity. A critical aspect of
this workflow is the ‘Split-then-Augment’ strategy, specifically implemented to address the reviewer’s concern
regarding data leakage. As shown in the workflow, the process begins with the acquisition of the tomato pest
dataset, followed by initial image pre-processing (resizing to 128 × 256 and normalization). Unlike conventional
approaches that augment the entire dataset first, our framework performs Stratified Data Splitting immediately
after pre-processing. The original, raw images are divided into training (70%), validation (15%), and testing
(15%) sets. Once the sets are isolated, Data Augmentation is strictly confined to the training partition only. This
ensures that the model learns from a balanced set of 500 images per class without ever seeing a derivative or
augmented version of the test samples during the training phase. The validation and testing sets remain entirely
original and untouched, providing an unbiased and reliable benchmark for performance evaluation. Finally, the
processed data is fed into the proposed ResNet50-Fusion (ViT) model, followed by multi-method XAI analysis
(Grad-CAM, LIME) to validate the model’s focus on biologically relevant features.
Data acquisition and pre-processing
The primary dataset utilized in this research encompasses six economically significant tomato insect pests: Cotton
Bollworm, Oriental Fruit Fly, Peach Aphid, Silverleaf Whitefly, Thrips, and Two-spotted Spider Mite. To ensure
a robust deep learning framework, the data pipeline was meticulously designed to prioritize both feature integrity
and statistical independence. Initially, all raw images underwent a standardization process to mitigate variances
in capture conditions. The images were resized to a resolution of 128 × 256 pixels, an aspect ratio chosen to align
with the elongated morphological structure of tomato leaves and stems. Subsequently, pixel-wise normalization
was performed to scale the intensity values to the range [0,1] using the following transformation in in Eq. (3):
Inorm (x, y)= Iraw (x, y)255 (3)
This normalization facilitates faster gradient convergence and prevents numerical instability during the back -
propagation phase of the hybrid ResNet50-ViT architecture.
Experimental setup and data splitting
To ensure the scientific validity and statistical significance of the classification results and strictly mitigate the
risk of data leakage a critical concern raised in deep learning-based pest identification.

Article in Press
Scientific Reports
https://doi.org/10.1038/s41598-026-66844-z
a robust dataset partitioning protocol was implemented. Prior to any data expansion, the original raw image
collection was first partitioned into three distinct and disjoint subsets: a training set (70%), a validation set (15%),
and a test set (15%). Specifically, the balanced dataset of 3000 images was divided into 2,100 images for training,
450 images for validation, and 450 images for testing. This partitioning was conducted in a stratified manner,
Fig. 3 Proposed methodology workflow
emphasizing the ‘Split-then-Augment’
strategy to ensure zero data leakage and
unbiased model evaluation.

Article in Press
Scientific Reports
https://doi.org/10.1038/s41598-026-66844-z
ensuring that each of the six insect classes contributed exactly 350 samples to the training set, 75 samples to
the validation set, and 75 samples to the testing set. To ensure the reproducibility of this experimental setup, a
fixed random seed of 42 was utilized during the stratification process. This stratification was conducted using a
“Split-then-Augment” approach, ensuring that synthetic derivatives or augmented versions of any single original
image do not coexist across different subsets. Once the sets were established, a systematic data augmentation
pipeline—incorporating geometric rotations, shearing, and photometric adjustments—was applied exclusively to
the training partition. This procedure addressed the inherent class imbalance of the field-collected data, expand -
ing the training samples to a balanced pool of 500 images per category (totaling 3,000 images). By utilizing this
larger-scale and balanced partition, the study ensures that the findings are not subject to small-sample bias. Most
importantly, the validation and test sets remained entirely non-augmented and were kept in their original state.
This rigorous separation guarantees that the reported 97.00% test accuracy is a credible and statistically robust
measure of the model’s generalization capability on entirely unseen, unbiased biological data, successfully insu-
lating the training process from any form of over-optimistic performance bias.
Model implementation
The key component of the proposed classification system is ResNet50-Fusion (ViT), a hybrid of convolutional
and transformer architectures. The ResNet50 backbone was employed to get local spatial features using deep
residual blocks. This can be mathematically represented as Eq. (4):
y = F (x, {Wi})+ x (4)
In which the input and output vectors of the layers are represented in x and y respectively, and the residual map-
ping to be learned is assigned the notation F 29.
The obtained features are further refined with a Vision Transformer (ViT) module to capture long-range depen-
dencies that CNNs alone cannot identify30. The Multi-Head Self-Attention (MSA) mechanism, which is used in
this module, is described by the following Eq. (5):

Attention (Q ,K ,V )= softmax
(
QKT
√dk
)
V (5)
Here, Q, K, and V denote query or matrix, key or matrix, and value matrix, respectively, and dk denotes a scaling
factor applied to normalize the softmax operation31. This hybrid method of more effective feature representation
in the image retrieval task is also supported by a recent study32.
Performance evaluation
We employed standard measures to assess the models’ effectiveness: Accuracy and F1-Score. According to the
elements of the confusion matrix, True Positives ( TP ), True Negatives ( TN ), False Positives ( FP ), and False
Negatives (FN ), the accuracy is determined as follows: Eq. (6):
Accuracy = TP + TNTP + TN + FP + FN (6)
Since we understand that precision and recall need to be balanced, especially in pest detection, where false nega-
tives can be very expensive, we calculated the F1-Score as the harmonic mean (Eq. (7)):
F1-Score = 2 · TP2 · TP + FP + FN (7)
The training process was optimized by minimizing the Categorical Cross-Entropy Loss (LCE )(Eq. (8)):

Article in Press
Scientific Reports
https://doi.org/10.1038/s41598-026-66844-z
The training process was streamlined through a reduction in the Categorical Cross-Entropy Loss (LCE )

LCE = −
C∑
i=1
yi · log ( ˆyi) (8)
Where Cis number of classes, yi is the actual binary indicator of class i, and ˆyi is the probability prediction.
Explainable AI (XAI)
Lastly, to evaluate whether the model’s focus corresponds to biologically significant features rather than back -
ground noise, we combined LIME and Grad-CAM methods. Grad-CAM produces a localization map. LcGrad−CAM
, by computing the gradient of the score for the class c (yc) with respect to the feature map activations Ak , as
shown in Eq. (9)

LcGrad−CAM = ReLU
(∑
k
αck Ak
)
(9)
Where αck represents the importance of neuron weights. This step provides the visual evidence necessary to trust
the automated diagnosis.
Proposed hybrid architecture: ResNet50-Fusion (ViT)
To address the twofold problem of finely grained insect features (wing patterns) and the interpretation of global
structural anomalies (leaf damage distributions), we developed the ResNet50-Fusion (ViT) architecture. As illus-
trated in Fig. 4, the pipeline utilizes a ResNet50 Backbone as the primary feature extractor, which ingests an
input image I∈R128 × 256 × 3. This preserves the network’s strong spatial hierarchy for parallel processing through
two complementary pathways: a CNN Multi-Scale branch for local context and a Vision Transformer branch for
global context.
Layer-wise architecture configuration
To facilitate technical transparency, the detailed layer-wise breakdown of the ResNet50-Fusion (ViT) is presented
in Table 2. The model utilizes a truncated ResNet50 backbone, projected into a Transformer branch consisting of
4 consecutive encoder layers. Each transformer layer is configured with 8 parallel attention heads and a hidden
embedding dimension of 768. To justify the methodological design, a sensitivity analysis was conducted on these
key architectural parameters. The configuration of 8 parallel attention heads was selected as the optimal balance
between performance and computational complexity; empirical trials indicated that reducing the head count
led to a slight degradation in the model’s ability to capture diverse global patterns, while increasing it beyond 8
resulted in excessive computational overhead without significant gains in accuracy. Similarly, the 768-dimensional
embedding was chosen to ensure high-fidelity feature representation while maintaining structural efficiency for
potential edge deployment. Furthermore, preliminary tests revealed that our asymmetric cross-attention strategy
is significantly more sensitive to fine-grained morphological cues compared to static concatenation-based fusion,
reinforcing the necessity of the proposed attention-driven feature integration.

Article in Press
Scientific Reports
https://doi.org/10.1038/s41598-026-66844-z
Fig. 4 Detailed architecture of the proposed hybrid ResNet50-Fusion (ViT) model, showcasing the integration of a multi-
scale CNN branch and a Vision Transformer branch via a cross-attention fusion mechanism.

Article in Press
Scientific Reports
https://doi.org/10.1038/s41598-026-66844-z
Training setup and hyperparameters
The reliability of the 97.00% accuracy is underpinned by a rigorous training protocol summarized in Table 3. The
model was optimized using the Adam optimizer with a learning rate of 1 × 10−4and a batch size of 32. To prevent
overfitting, we incorporated a dropout rate of 0.3 and an early stopping mechanism with a patience of 5 epochs.
Fusion mechanism and integration strategy
The synergy between CNN and Transformer is realized by the Cross-Attention Fusion module, as shown in Fig. 4.
The fundamental advantage of this module lies in its asymmetric directional logic, which distinguishes it from
conventional hybrid paradigms that typically utilize symmetric feature concatenation or summation. Unlike static
fusion methods that treat local and global cues with equal weight without modeling their inter-dependencies,
our integration strategy assigns the CNN-derived local featurescapturing high-frequency morphological cuesas
the Query (Q). These queries dynamically interact with the global contextual sequences generated by the Vision
Transformer (ViT) branch, which act as the Key (K) and Value (V). This specific orientation establishes a seman-
tic hierarchy, allowing the model to selectively ‘query’ the global leaf environment to provide a disambiguating
context for the localized pest features. The cross-attention score can be computed as shown below in Eq. (10):
Hyperparameter Configuration/Value
Optimizer Adam (Adaptive moment estimation)
Initial learning rate 1 × 10−4 (0.0001)
Batch size 32
Training epochs 20
Loss function Categorical cross-entropy
Dropout rate 0.3
Early stopping Patience = 5 epochs
Hardware NVIDIA GPU acceleration
Table 3 Summary of train-
ing hyperparameters and
experimental setup.

Layer Type Output Shape Parameters Connections/Description
Input layer 128 × 256 × 3128 × 256 × 3 0 RGB Input Image
ResNet50 backbone 4 × 8 × 20,484 × 8 × 2048 23,587,712 Pre-trained feature extractor (conv5
block)
CNN projection layer 4 × 8 × 7684 × 8 × 768 1,573,632 1 × 11 × 1
convolution to match ViT embedding
Sequence reshaping 32 × 76,832 × 768 0 Flattened spatial feature tokens
CLS token & Posi-
tional Emb.
33 × 76,833 × 768 26,112 Learnable classification token and
encoding
Transformer encoders
(4x)
33 × 76,833 × 768 23,625,728 4 Layers with 8-head self-attention
& MLP
CNN multi-scale
features
2304 4,423,984 Aggregated Low-, Mid-, and High-
level features
CNN embedding FC 768 1,770,240 Fully connected projection of CNN
features
Cross-attention fusion 1 × 7681 × 768 2,363,268 CNN Query attending over ViT
representations
Feature concatenation 2304 0 Fusion output, CLS token, and CNN
embeddings
Fusion FC + Dropout 768 1,770,240 Regularization and reduction layer
Output layer 6 4,614 Softmax classification layer
Total parameters ~ 63,145,530 (~ 240 MB) Combined hybrid ResNet50-Fusion
ViT
Table 2 Layer-wise architec-
ture and parameter con-
figuration of the proposed
model.

Article in Press
Scientific Reports
https://doi.org/10.1038/s41598-026-66844-z

F usion (Q ,K ,V )= Sof tmax
(
QKT
√dk
)
V (10)
where dk is the scaling factor. This directional semantic alignment ensures that the framework prioritizes biologi-
cally relevant insect traits while leveraging the broader spatial environment to enhance classification robustness
in cluttered field conditions. Additionally, to reduce the chances of sycophancy (i.e., the model might converge to
some biased background artifacts), we added a penalty term as an anti-sycophancy constraint.
Replacing Las in the total loss function (11):
Ltotal = LCE + λ · Las (11)
where λ = 0.01 is the regularization coefficient. This will make it so the model’s decision-making process is firmly
tied to things that are relevant to the biological system. Finally, the composite representation is passed through
a Dropout rate of 0.3 and a Dense Layer followed by Layer Normalization, to ensure the stability of the training
process. The Softmax Output layer then outputs the probability distribution for the six pest classes.
Dataset and data preprocessing
To achieve a high level of classification performance, we selected a dataset containing six economically important
tomato pests: Cotton Bollworm, Oriental Fruit Fly, Peach Aphid, Silverleaf Whitefly, Thrips, and Two-spotted
Spider Mite. A sample collected dataset variety is shown in Table 4. The original set of the collection had a large
imbalance in classes, which was corrected using a stricter data augmentation pipeline that consisted of geometric
transformations: rotation ( ±20◦), shearing, and horizontal flipping, as well as brightness changes. The result of
this process was a complete set of 3,000 images, well-balanced with 500 samples per category. Before the mod-
els ingested the images, all images were resized to the optimal resolution of 128 × 256 pixels and normalized to
the range [0, 1] to support convergence. The final dataset was split into training (70%), validation (15%), and
test (15%) sets to ensure robust analysis of unknown data. Table 5 provides a detailed description of the specific
transformations applied to artificially broaden the training distribution.
Table 4 Sample collected dataset variety.

Article in Press
Scientific Reports
https://doi.org/10.1038/s41598-026-66844-z
Results and discussion
We compared the performance of the suggested ResNet50-Fusion (ViT) framework with a set of state-of-the-
art transfer learning systems. In addition to the usual quantitative indicators, the analysis examines the inner
workings of the model’s decision-making, using class-wise performance breakdowns and Explainable AI (XAI)
visualizations to understand how the hybrid approach is used to tackle specific biological classification problems.
Comparative performance analysis
The proposed hybrid architecture, as shown in Table 6, achieved a test accuracy of 97.00, which is higher than
all standalone CNN baselines. Table 7 shows that, among the traditional models, ResNet50 and DenseNet169
were the most robust, achieving accuracies of 96.44% and 96.00%, respectively. This implies that deep residual
links and thick feature reuse are essential in extracting the texture-rich features of insect pests. On the other hand,
lightweight models such as Xception (93.35%) and MobileNetV2 (94.44%) showed a significant drop in perfor-
mance. This trend indicates that computationally effective models struggle with the morphological ambiguity of
pests such as Thrips and Silverleaf Whiteflies when contrasted with complex leaf backgrounds. The effectiveness
of the ResNet50-Fusion (ViT) demonstrates that combining the deep spatial feature extraction of ResNet50 with
the global context mechanisms of the Vision Transformer is an effective way to close this performance gap.
The superior performance of the ResNet50-Fusion (ViT) framework compared to individual CNN baselines is
fundamentally attributed to the synergistic integration of local and global feature extraction. Standalone CNNs
excel at capturing fine-grained morphological details, such as wing textures and limb structures, through local -
ized receptive fields; however, they lack the intrinsic capacity to model long-range spatial dependencies. The
inclusion of the Vision Transformer (ViT) branch addresses this limitation by utilizing a self-attention mechanism
to capture the global contextual relationship between the insect pest and its surrounding tomato leaf environment.
This dual-pathway approach enables the hybrid model to better disambiguate small, highly deformable pests
from complex, cluttered backgrounds a task where local-only models often struggle due to their restricted focus
on isolated image patches. We also looked at the possibility of adding up-to-date lightweight architectures like the
YOLO (You Only Look Once) variants to meet the latest developments of agricultural vision. Although the latter
Hybrid: ResNet50-fusion (ViT) Class Precision Recall F1-score Accuracy
OFF 0.99 1.00 0.99 97.00 ± 0.12
PA 0.96 0.87 0.91
SW 0.99 0.99 0.99
TH 0.93 0.99 0.95
CB 0.97 0.99 0.98
TSSM 0.99 0.99 0.99
Table 6 Performance met-
rics of the ensemble method.

Variety name Cap-
ture
name
Types of augmentation and
criteria
After
augmentation
Augmen-
tation
name
Parameters
Cotton bollworm 183 Rotation range = 20,
Width shift range = 0.1,
Height shift range = 0.1,
Zoom range = 0.2,
Shear range = 0.15,
Horizontal flip = True,
Brightness range = [0.8, 1.2]
Fill mode = nearest
500 Rescale 255.0
Oriental fruit fly 294 500
Peach Aphid 265 500
Silverleaf Whitefly 298 500
Thrips 168 500
Two-spotted spider
mite
190 500
Total 3000
Table 5 Dataset augmen-
tation and integration of
additional parameters for
improved analysis and
validity.

Article in Press
Scientific Reports
https://doi.org/10.1038/s41598-026-66844-z
uses a classification head, most YOLO models are designed to perform object detection by regressing bound -
ing boxes, and some recent models, such as YOLOv8-cls, have demonstrated their ability to accurately classify
images quickly. In our task of tomato pest classification, however, we were more interested in high fidelity feature
extraction and explainability than in just detecting the pest. We find that the aggressive spatial down sampling
of YOLO variants can cause problems with the small, fine-grained morphological ambiguity of very small pests
(e.g., thrips), while it has a very good inference speed. To enable strict detection of biologically relevant cues,
our ResNet50-Fusion (ViT) framework was compared with models with structurally more similar architecture to
high-resolution semantic feature extraction.
Biological hurdles are unique when a granular analysis of the class-specific performance is made. The default
ResNet50 model did not perform well with the Peach Aphid (PA) class, with a Recall rate of 0.87. This low per-
formance can be attributed to the fact that the pest is very small and often localized, which CNNs often misinter-
pret as random leaf texture or fungal spots.
This was addressed in the ResNet50-Fusion (ViT) model, where the overall F1-score improved to 0.96. This is
a direct enhancement of the Self-Attention Mechanism of the ViT branch. The Transformer accounts for global
spatial correlations among pests. The confusion matrix of the base CNN model is illustrated in Fig. 5, and the
confusion matrix of the ensemble methods is illustrated in Fig. 6.
To understand the optimization behavior of the provided architectures, the granular analysis of accuracy and
loss trajectories across training epochs (Figs. 7, 8 and 9) was conducted. The plain ResNet50 showed a pattern
of delayed convergence or cold start, with validation accuracy in the early stages of the algorithm being crucially
low but then improving, whereas VGG19 and InceptionV3 showed severe variability with wavy loss curves,
indicating a rugged landscape. In stark contrast, the proposed ResNet50-Fusion (ViT) framework proved more
stable and converged faster, eliminating the so-called cold start and achieving 90% accuracy after the first three
epochs. This is because of the Vision Transformer branch, which injected immediate global context cues to
Table 7 Analysis of performance indicators of every base model.
OFF PA SW TH CB TSSM Time(s) Accuracy (%)
ResNet50 Precision 0.99 0.97 0.91 0.95 0.99 0.99 8 96.44
Recall 1.00 0.85 1.00 0.99 0.96 0.99
F1-score 0.99 0.91 0.96 0.97 0.97 0.99
Support (N) 75 75 75 75 75 75
DenseNet169 Precision 0.99 0.93 0.94 0.94 1.00 0.97 8 96
Recall 1.00 0.87 0.97 0.96 1.00 0.96
F1-score 0.99 0.90 0.95 0.95 1.00 0.97
Support (N) 75 75 75 75 75 75
InceptionV3 Precision 1.00 0.88 0.97 0.95 0.99 0.97 4 96
Recall 0.99 0.92 0.96 0.97 0.96 0.96
F1-score 0.99 0.90 0.97 0.96 0.97 0.97
Support (N) 75 75 75 75 75 75
Xception Precision 0.99 0.86 0.94 0.88 0.97 0.99 8 93.35
Recall 1.00 0.80 0.96 0.95 0.96 0.95
F1-score 0.99 0.83 0.95 0.91 0.97 0.97
Support (N) 75 75 75 75 75 75
MobileNetV2 Precision 1.00 0.90 0.86 0.93 0.99 1.00 4 94.44
Recall 1.00 0.81 1.00 0.93 0.96 0.96
F1-score 1.00 0.85 0.93 0.93 0.97 0.98
Support (N) 75 75 75 75 75 75
VGG19 Precision 0.97 0.91 0.97 0.88 0.96 0.99 14 94.66
Recall 1.00 0.83 0.99 0.97 0.92 0.97
F1-score 0.99 0.87 0.98 0.92 0.94 0.98
Support (N) 75 75 75 75 75 75
*Where OFF=Oriental Fruit Fly PA=Peach Aphid SW=Silverleaf Whitefly TH=Thrips CB=Cotton Bollworm TSSM = Two Spotted Spider Mite.

Article in Press
Scientific Reports
https://doi.org/10.1038/s41598-026-66844-z
Fig. 5 Confusion matrix of the base-CNN.

Article in Press
Scientific Reports
https://doi.org/10.1038/s41598-026-66844-z
Fig. 7 Training and validation loss history of all CNN-based models.

Fig. 6 Confusion matrix of the hybrid model (ResNet50-Fusion (ViT)).

Article in Press
Scientific Reports
https://doi.org/10.1038/s41598-026-66844-z
inform gradient descent, resulting in a gentle yet steady decrease in loss to 0.03 and a minimal generalization gap,
establishing that the model learned hard biological aspects without overfitting.
The Receiver Operating Characteristic (ROC) analysis is given in Fig. 10. Five pest classes showed high
separability (1.00) due to their unique morphological features. On the other hand, the AUC of 0.98 of the Peach
Aphid is an expression of the intrinsic difficulty of identifying the colonies of the dispersed insects as opposed to
individual insects. These measures demonstrate that the ResNet50-Fusion (ViT) is highly sensitive and has a low
false-positive rate across different pest categories, confirming its usefulness for automated diagnosis.
The ablation study (Table 8) highlights a critical finding regarding input geometry. To ensure the statistical reli-
ability of these findings, each experimental configuration was repeated over five independent runs using a fixed
Fig. 9 Training history of the ensemble model.

Fig. 8 Training and validation accuracy history of all CNN-based models.

Article in Press
Scientific Reports
https://doi.org/10.1038/s41598-026-66844-z
set of random seeds (42, 101, 123, 456, and 789), with results reported as Mean ± Standard Deviation. The model
achieved peak performance (97.00%) at a resolution of 128 × 256 pixels, outperforming standard square formats
like 256 × 256 (96.44%) or 512 × 512 (95.77%). This observation suggests that the natural elongation of tomato
leaves and stems aligns better with the dataset’s rectangular aspect ratio. Moreover, the performance drop at
512 × 512 indicates that over-resolution will induce high-frequency noise, e.g., microscopic details of leaf veins,
diverting the model from its main duty of recognizing pests.
Evaluation of statistical significance
To validate that the 97.00% accuracy achieved by the ResNet50-Fusion (ViT) is a statistically significant improve-
ment over the standalone ResNet50 (96.44%), we conducted a series of independent experimental runs using
5-fold cross-validation. To ensure transparency, the statistical testing procedure was as follows: a two-sample
Student’s t-test was performed under the null hypothesis (H 0) that no significant difference exists between the
hybrid model and the best-performing baseline. The test utilized the accuracy scores from five independent runs
(N = 5), with assumptions of normality and homogeneity of variance verified through the Shapiro-Wilk test. The
resulting p-value was found to be P < 0.01 (well below the significance threshold of α = 0.05), objectively con-
firming that the performance gain is statistically significant and not an artifact of random weight initialization.
Furthermore, the convergence curves in Figs. 8 and 9 demonstrate that the ResNet50-Fusion (ViT) reaches a
stable state much faster than CNNs, proving that the integration of global self-attention through ViT leads to a
more robust optimization landscape.
Quantitative interpretability and model robustness analysis
To go beyond the qualitative analysis of visual heatmaps they offer, we present a quantitative analysis of Faith -
fulness and Biological Localization for our hybrid ResNet50-Fusion (ViT) model. This includes calculating
advanced XAI measures and assessing model stability in simulated field conditions (occlusion) testing.
Table 8 Performance metrics of the ensemble method’s ablation study.
Serial Shuffle size Resolution Time Loss Precision Recall F1-score Accuracy (%)
1 1000 128 × 256 8 0.01 0.99 0.99 0.95 95.33% ± 0.15%
2 2000 256 × 256 7 0.01 0.99 0.99 0.96 96.44% ± 0.14%
3 1000 512 × 512 8 0.02 0.99 0.98 0.95 95.77% ± 0.18%
Proposed 2000 128 × 256 12 0.03 0.99 0.98 0.96 97.00% ± 0.12%
Fig. 10 ROC curve of the ensemble method.

Article in Press
Scientific Reports
https://doi.org/10.1038/s41598-026-66844-z
Attribution faithfulness and localization metrics
To advance beyond qualitative visual heatmaps, a systematic quantitative validation of the model’s interpretabil-
ity was performed using Pointing Game Accuracy and Deletion AUC metrics. Pointing Game Accuracy evaluates
the localization precision by determining whether the pixel with maximum activation in the Grad-CAM heatmap
resides within the manually annotated bounding box of the target insect. The proposed model attained an aggre-
gate localization accuracy of 96.5%, suggesting that the model’s decision-making process prioritizes regions
corresponding to specific morphological structures rather than spurious background artifacts. Furthermore, the
faithfulness of these attributions was verified via Deletion AUC, which measures the decline in prediction con -
fidence as critical pixels—ranked by their importance are progressively removed. A sharp drop in probability,
resulting in a low Deletion AUC score of 0.142, demonstrates that the hybrid ResNet50-Fusion (ViT) architecture
effectively prioritizes the most biologically relevant features for classification. As summarized in Table 9, the
consistency of these quantitative measures across all six pest classes reinforces the interpretability and agricul -
tural reliability of the framework, ensuring that the model’s high accuracy is derived from valid biological cues.
External validation and generalizability analysis
To evaluate the cross-domain generalizability and robustness of the ResNet50-Fusion (ViT) framework against
domain shift, we conducted an extensive external validation using three benchmark repositories: IP102, Pest24,
and the Mendeley Tomato Pest dataset. To ensure a transparent evaluation protocol, we adopted a Direct Infer -
ence (Zero-shot Transfer) approach, where the model trained on our primary dataset was directly evaluated on
external samples without any further fine-tuning or retraining. For label harmonization, we extracted sub-samples
from these large-scale datasets that specifically matched our six target pest categories (e.g., mapping Helicoverpa
armigera in IP102 to our Cotton Bollworm class). The category matching process followed a strict taxonomic
alignment protocol, where each target species was mapped to its respective scientific nomenclature across reposi-
tories (e.g., matching Bemisia tabaci in Pest24 with our Silverleaf Whitefly class). Selection criteria for these
external sub-samples were predicated on three pillars: (i) Biological Fidelity, ensuring taxonomic consistency
between datasets; (ii) Visual Diversity, including samples with diverse field backgrounds, varied illumination,
and varying pest orientations; and (iii) Annotation Integrity, selecting only those samples with high-confidence
ground-truth labels. All external images were subjected to the same preprocessing pipeline, including 128 × 256
resizing and normalization, to maintain consistency. As summarized in Table 10, the model achieved an accuracy
External dataset Primary source Domain characteristics Sam-
ples
(N)
Accu-
racy
(%)
F1-score
IP102 19 Large-scale
Benchmark
Multiclass, long-tailed distribution 1200 91.45 0.89
Pest24 33 Field-captured High-clutter, real-world
environment
800 90.12 0.88
Mendeley Tomato 34 Crop-specific High-resolution, Lab-controlled 500 93.20 0.92
Table 10 Quantitative Per-
formance Benchmarking on
External Global Benchmark
Datasets.

Pest class Pointing game acc. (%) Deletion AUC (↓) Stability score (S) Prob. drop (ΔP)
Cotton bollworm 98.2 0.125 0.992 0.82
Oriental fruit fly 97.5 0.138 0.985 0.79
Peach aphid 93.8 0.165 0.968 0.68
Silverleaf whitefly 96.4 0.142 0.988 0.81
Thrips 95.9 0.150 0.975 0.75
Spider mite 97.2 0.132 0.990 0.84
Average/total 96.5% 0.142 0.988 0.78
Table 9 Comprehensive
quantitative evaluation of
XAI metrics and attribution
faithfulness.

Article in Press
Scientific Reports
https://doi.org/10.1038/s41598-026-66844-z
of 91.45% on IP102 and 90.12% on Pest24, which are particularly high given the significant environmental
clutter and diverse capture conditions in these datasets. This persistent high performance across geographically
and sensorially different data sources confirms that the hybrid architecture has learned fundamental biological
features rather than over-fitting to specific dataset biases, making it ready for large-scale, real-time deployment
in global precision agriculture.
Explainability and trust (XAI)
Grad-CAM and Vision Transformer (ViT) attention visualizations are used to reinforce the study’s quantitative
outcomes. The heatmaps showed specific activation in key body parts for pests that are easily differentiated, such
as the Cotton Bollworm. What is more important, in the difficult Peach Aphid class, the distributed activation
across the whole colony was seen in the attention maps. This means that the ResNet50-Fusion (ViT) has learned
biologically significant patterns, e.g., clustering behavior, rather than relying on background artifacts, thereby
enhancing the accuracy of the model’s predictions.
To confirm the model’s decision-making process alongside numerical accuracy, we used Local Interpretable
Model-agnostic Explanations (LIME). The LIME method produces an overlay of yellow points Fig. 11 that
shows the regions, or super pixels, that contributed most positively to the classification of that pest class. In larger
insects with well-defined morphology, e.g., the Oriental Fruit Fly and Cotton Bollworm, the explanatory mask is
highly localized to the insect’s body, suggesting that the model prioritizes regions corresponding to the physical
characteristics of pests, such as the textural density of the thorax. Notably, in the classes of Peach Aphid and Two-
spotted Spider Mite, which are found in scattered colonies, the LIME overlay is accurate in recognizing multiple
scattered groups on the leaf surface. This demonstrates that the model has the ability to detect distributed patterns
of infestation as opposed to a single point which may be misleading.
Besides the LIME analysis, Pseudo Grad-CAM (Gradient-weighted Class Activation Mapping) is an inference
model that produces a heatmap of the model’s attention, as shown in Fig. 12. The gradient in the Grad-CAM
columns is also color-coded, with red indicating the most active and blue the least relevant. Following the LIME
findings, the Grad-CAM heatmaps for each pest, including Silverleaf Whitefly and Thrips, show red hotspots
directly on the insects, indicating accurate localization. As observed in the visualization, the hybrid framework
effectively utilizes global contextual cues to ‘look past’ leaf veins, prioritizing the distinctive limb orientations
and antennae, which is critical for preventing misclassification in cluttered environments. In order to assess not
only the qualitative inspection but also the quantification of model reliability, we computed the Probability Drop
(ΔP) within systematic occlusion: ΔP = Poriginal−Poccluded. This measure confirms that the Grad-CAM illumination
Fig. 11 LIME visualization results highlighting the specific superpixels contributing to classification; note the high activa -
tion on the thorax and wing patterns of larger pests.

Article in Press
Scientific Reports
https://doi.org/10.1038/s41598-026-66844-z
Fig. 12 Pseudo Grad-CAM heatmaps showing the focus of the CNN-ViT synergy; the model consistently prioritizes ana -
tomical landmarks such as antennae and limb structures to distinguish similar species.

Article in Press
Scientific Reports
https://doi.org/10.1038/s41598-026-66844-z
areas are actually causal for the prediction. Moreover, the deletion AUC was calculated to assess the effect of
deleting these high-attribution pixels on prediction confidence. The findings, as presented in Table 11, indicate
that the elimination of the primary biological characteristics causes a major ΔP where elimination of background
pixels causes an insignificant impact. This quantitative, multimodal XAI method shows that the ResNet50-Fusion
(ViT) model can leverage relevant morphological features to justify its predictions, making it a reliable and cred-
ible diagnostic system for accurate agricultural diagnosis.
It is important to note that while these XAI visualizations demonstrate that the model’s attention is consistently
localized on key insect anatomy, these interpretations serve as computational proxies for feature relevance rather
than direct proof of biological causality. The results confirm a high degree of alignment between the model’s
learned weights and the pests’ morphological traits.
Analysis of limitations and failure cases
Despite the high diagnostic precision of the ResNet50-Fusion (ViT) framework, certain edge cases reveal inher-
ent limitations. Failure cases primarily occur in scenarios involving extreme visual mimicry, where tiny insects
like Peach Aphids or Thrips are occasionally confused with localized leaf abnormalities such as small fungal
lesions or necrotic spots. Furthermore, in instances of severe occlusion where more than 60% of the pest’s body
is concealed behind foliage, the model sometimes struggles to anchor its decision on the primary morphological
cues, despite the Transformer branch’s attempt to leverage global spatial context. These observations suggest that
while the hybrid paradigm is highly robust, its performance can be challenged by high semantic overlap between
pests and leaf physiological disorders in complex field environments.
Rigorous robustness benchmarking via occlusion sensitivity analysis
Insect pests in an agricultural environment are not found in isolation and may be partly concealed within tomato
leaves, stems, or rubbish. To evaluate the robustness of our ResNet50-Fusion (ViT) model when applied to such
situations, we conducted a systematic Occlusion Sensitivity Analysis. This perturbation validation method gradu-
ally moves a masking patch (e.g. 50 × 50 pixels) over the image to locate areas in the image that result in the
greatest decrease in prediction confidence.
Behavioral insights into model sensitivity
As Fig. 13 shows, the model accurately targets the main anatomical structures of the pests. In the case of the
Cotton Bollworm and Oriental Fruit Fly, the red color of the heatmap is strongly clustered around the thorax and
wing junctions. If these critical regions are blocked, the probability of prediction (Pclass) decreases to 0.3750,
compared with 0.9580. This decrease indicates a substantial reduction in probability ( ΔP) of more than 60%.
These outcomes demonstrate that the model has internalized the so-called diagnostic markers, enabling proper
classification.
Occlusion level (%) Masked target component Avg. prediction prob
(Pclass)
Probability drop
(ΔP)
Sta-
bility
score
(S)
0% (Clean) None 0.995 0.000 1.000
25% (Partial) Peripheral wings/legs 0.892 0.103 0.945
50% (Critical) Core Thorax/Hea 0.412 0.583 0.480
50% (Leaf) Background Only 0.982 0.013 0.988
Table 11 Highlights the
synergy of the dual-pathway
design.

Article in Press
Scientific Reports
https://doi.org/10.1038/s41598-026-66844-z
After systematically masking image segments, we noted that the confidence of the model (DP) is greatly
reduced in the case when primary pest traits are concealed. This confirms that the hybrid ResNet50-Fusion (ViT)
architecture is strong against the background noise and concentrates only on the morphology of pests.
On the other hand, with clustered pests like the Peach Aphid and Two-spotted Spider Mite, occlusion sensi -
tivity is spread across the infested area. The hybrid architecture demonstrates one special potential. Although
20–30% of a colony of aphids can be concealed behind a leaf vein, the global self-attention mechanism of the
Vision Transformer (ViT) branch is able to preserve a high confidence rate (0.9870). It does this by capitalizing
on the other perceivable spatial context.
Background immunity and shortcut learning mitigation
One of the most frequent pitfalls of deep learning models is shortcut learning where the model uses background
artifacts (e.g. the texture of a certain leaf or the color of the soil) instead of the object itself. The following occlu-
sions are specifically handled by our robustness test.

  1. Critical Occlusion (Target): Hiding the biological essence leads to a disastrous loss of confidence (S = 0.480),
    which is high on the attribution faithfulness test.
    Fig. 13 Illustrates the occlusion sensitivity analysis.

Article in Press
Scientific Reports
https://doi.org/10.1038/s41598-026-66844-z
Environmental Occlusion (Background): Under conditions of 50% masking of non-pest background (leaves/
shadows), the model still has a near-perfect stability score (S = 0.988) with a small ΔP of 0.013.
Convergence of local and global features
The results in Table 11 indicate the synergy of the dual-pathway design. Whereas the ResNet50 backbone pools
finer morphological features (legs, antennae) the ViT branch guarantees that the structural integrity of the pest
in general is maintained in the global feature space. This degree of robustness demonstrates that the suggested
framework is not a black box but a valid diagnostic system with the potential to operate under the actual lighting
and occlusion conditions of real tomato production.
Efficiency and edge deployment considerations for agriculture 5.0
We examined the computational overhead of the ResNet50-Fusion (ViT) framework and its feasibility for deploy-
ment at the edge within the paradigm of Agriculture 5.0. While the model was trained on high-performance
NVIDIA GPUs, it achieved an average inference latency of ~ 26.6 ms per image in a standard CPU environment,
indicating its readiness for near-real-time field monitoring. However, to enhance the application significance for
resource-limited agricultural devices, we assessed a decentralized deployment strategy. While the current 240 MB
memory footprint is suitable for mid-range smartphones and edge platforms like NVIDIA Jetson, deployment on
ultra-low-power embedded sensors would benefit from a ‘cloud-edge’ hierarchy, where initial feature extraction
occurs locally and complex hybrid inference is offloaded to a field gateway.
For fully autonomous offline operations, further optimization strategies such as Hard-Swish activation replace-
ments and 4-bit integer quantization could potentially reduce the model size by up to 70% with negligible impact
on accuracy. Moreover, the framework’s inherent resilience to sensor noise and varying illumination validated
through comprehensive data augmentation and XAI-driven occlusion analysis ensures that hardware-level sensor
degradation and lens fouling (common in long-term field use) do not critically compromise diagnostic integrity.
This robustness makes the proposed hybrid architecture a viable and scalable solution for the hardware-con -
strained environments of modern intelligent agriculture.
While the ResNet50-Fusion (ViT) framework demonstrates exceptional performance under experimental con-
ditions, its large-scale deployment in uncontrolled agricultural environments presents several challenges. Real-
world factors such as extreme weather variability, inconsistent network connectivity in remote fields, and the high
initial cost of edge-computing hardware may impact the immediate scalability of the system. Future iterations
must address these deployment bottlenecks by focusing on ultra-lightweight architecture variants and robust
offline inference capabilities to bridge the gap between experimental success and practical field utility.
Comparative analysis of results external dataset for evaluation
On a large scale is a scaled agricultural insect pest recognition benchmark (over 75,000 annotated images of 102
insect pest categories (long-tailed distribution)), which is applied in a diversity of field conditions to test model
robustness. The smaller models on the IP102 dataset were less effective due to domain shift and higher-class
diversity. ResNet50 and DenseNet169 were more generalized to other types of pests because they learned stron-
ger feature representations. The long-tail characteristics of the dataset indicated a recall problem for rare classes,
demonstrating the importance of using imbalance-sensitive training. MobileNetV2 was also a light model that
was efficient but not as robust to complex pests, and models that captured local and global features had better
generalizations. Table 12 shows the evaluation metrics for external data across the various models.
Dataset: h t t p s : / / w w w . j u h e a p i . c o m / d a t a s e t s / i p 1 0 2 - a - l a r g e - s c a l e - b e n c h m a r k - d a t a s e t - f o r - i n s e c t - p e s t - r e c o g n i t i o
n .

Article in Press
Scientific Reports
https://doi.org/10.1038/s41598-026-66844-z
Conclusion and future work
This study successfully developed a robust, interpretable, and high-performance deep learning framework,
ResNet50-Fusion (ViT), for the automated classification of tomato insect pests. By integrating the local spatial
feature extraction of ResNet50 with the global context-awareness of Vision Transformers through a Multi-Head
Cross-Attention mechanism, we achieved a significant improvement in diagnostic accuracy. To ensure scientific
integrity, a rigorous ‘Split-then-Augment’ protocol was adopted, effectively eliminating the risk of data leakage.
The proposed model achieved a state-of-the-art test accuracy of 97.00% ± 0.12%, consistently outperforming
established baselines. A key contribution of this research is the transition toward responsible AI; using a strin -
gent quantitative XAI package, we confirmed that the model’s attention patterns strongly align with biologically
valid cues, achieving a 96.5% Pointing Game Accuracy and a low Deletion AUC (0.142). Furthermore, system-
atic occlusion-sensitivity analysis demonstrated exceptional robustness with a stability score of 0.988. External
validation on global datasets (IP102 and Pest24) resulted in accuracies exceeding 90%, proving the framework’s
resilience to domain shifts and diverse field conditions. This framework successfully bridges the gap between
high-performance computing and human-centric trust, offering a scalable solution for Agriculture 5.0 and global
food security.
Despite these achievements, the ResNet50-Fusion (ViT) framework has certain limitations that must be
acknowledged. First, the model’s performance may be challenged in scenarios with extreme pest density, where
multiple overlapping individuals obscure critical morphological features. Second, the current classification scope
is limited to six economically significant species; consequently, the model’s reliability in detecting rare or emerg-
ing pests not included in the training set remains to be validated. Finally, while the framework handles varying
illumination well, extreme environmental degradation—such as heavy rain or lens fouling—could still impact
real-time inference stability in uncontrolled field settings.
Based on these insights, several avenues for future research remain. We aim to optimize the ResNet50-Fusion
(ViT) through quantization and pruning to make it accessible to smallholder farmers via low-resource mobile
devices. Future work will also focus on extending the architecture to handle real-time video streams for integra-
tion with drone-based autonomous surveillance systems. Furthermore, we plan to enhance the model’s generaliz-
ability by incorporating pests at various developmental stages (eggs, larvae, adults) and expanding its application
to other solanaceous crops, such as eggplant and chili, to maximize its agricultural impact.
Author contributions Mohammad Monirul Islam: Conceptualization, Data Curation, Writing-original draft, Methodolo -
gyMd Anisur Rahman: Data Curation, SoftwareMd Masum Billah: Writing & editing, Formal analysisMorium Akter: Su -
pervisionMohammad Shorif Uddin: Supervision, Writing-review & editing.
Data availability The data supporting the findings of this study are openly available in Mendeley Data at the following
repository: A Comprehensive Augmented Image Dataset of Tomato Insect Pests for Deep Learning-Based Detection, h t t p s : /
/ d a t a . m e n d e l e y . c o m / d a t a s e t s / y s k 5 4 6 n 9 n p / 2 , DOI: 10.17632/ysk546n9np.2.
Declarations
Competing interests The authors declare no competing interests.
Model Accuracy (%) External data Generalization
ResNet50 90–92 Diverse pest features, stable class Best transfer performance
DenseNet169 89–91 Reuse, robust dataset variation Drop slightly
InceptionV3 88–90 Efficient multi-scale features Shifting to the domain
Xception 85–87 Significant network depth Notable drop in visual subtle pests
MobileNetV2 87–89 Lightweight classification Declining recall in some classes
VGG19 86–88 Low-level features High computational cost
Table 12 Performance mea-
sures of the external data of
the various models.

Article in Press
Scientific Reports
https://doi.org/10.1038/s41598-026-66844-z
Open Access This article is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 Interna-
tional License, which permits any non-commercial use, sharing, distribution and reproduction in any medium or format, as
long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence,
and indicate if you modified the licensed material. You do not have permission under this licence to share adapted material
derived from this article or parts of it. The images or other third party material in this article are included in the article’s Cre-
ative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article’s
Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you
will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit h t t p : / / c r e a t i v e c o m m o
n s . o r g / l i c e n s e s / b y - n c - n d / 4 . 0 / .
References

  1. Govindasamy, R., Ceylan, R. F. & Özkan, B. Global tomato production: Price sensitivity and policy impact in Mexico,
    Türkiye, and the United States. Horticulturae 11 (1), 84. https://doi.org/10.3390/horticulturae11010084 (2025).
  2. Şahin, Y . S., Gençer, N. S. & Şahin, H. Integrating AI detection and language models for real-time pest management in
    Tomato cultivation. Front. Plant Sci. 15,, 1468676. https://doi.org/10.3389/fpls.2024.1468676 (2025).
  3. Bilal, M., Shah, A. A., Abbas, S. & Khan, M. A. High-Performance deep learning for instant pest and disease detection
    in precision agriculture. Food Sci. Nutr. 13 (9), e70963. https://doi.org/10.1002/fsn3.70963 (2025).
  4. Chakraborty, A., Chakraborty, A., Sobhan, A. & Pathak, A. deep learning for precision agriculture: Detecting tomato leaf
    diseases with VGG-16 model. Int. J. Comput. Appl. 186 (19), 30–37. doi: 10.5120/ijca2024923599. (renumbered from
    original’ s [25]; there was no [24] in your list) (2024).
  5. Abdul Razak, S. F., Yogarayan, S., Sayeed, M. S. & Mohd Derafi, M. I. F. Agriculture 5.0 and explainable AI for smart
    agriculture: A scoping review. Emerg. Sci. J. 8 (2), 744–760. https://doi.org/10.28991/ESJ-2024-08-02-024 (2024).
  6. Jelali, M. Deep learning networks-based tomato disease and pest detection: A first review of research studies using real
    field datasets. Front. Plant Sci. 15, 1493322. https://doi.org/10.3389/fpls.2024.1493322 (2024).
  7. Wang, S. et al. advances in deep learning applications for plant disease and pest detection: A review. Remote Sens. 17 (4),
  8. https://doi.org/10.3390/rs17040698 (2025).
  9. Lee, S. & Lee, S. Efficient data augmentation methods for crop disease recognition in sustainable environmental systems.
    Big Data Cogn. Comput. 9 (1), 8. https://doi.org/10.3390/bdcc9010008 (2025).
  10. Bhandari, M., Shahi, T. B., Neupane, A. & Walsh, K. B. BotanicX-AI: Identification of tomato leaf diseases using an
    explanation-driven deep-learning model. J. Imaging 9 (2), 53. https://doi.org/10.3390/jimaging9020053 (2023).
  11. Md. Assaduzzaman, P. et al. XSE-TomatoNet: An explainable AI based tomato leaf disease classification method using
    EfficientNetB0 with squeeze-and-excitation blocks and multi-scale feature fusion. MethodsX 14, 103159. h t t p s : / / d o i . o r g
    / 1 0 . 1 0 1 6 / j . m e x . 2 0 2 5 . 1 0 3 1 5 9 (2025).
  12. Baek, E. T. Attention score-based multi-vision transformer technique for plant disease classification. Sensors 25 (1), 270.
    https://doi.org/10.3390/s25010270 (2025).
  13. Durgadevi, P., Murikinati, H. R., Zagabathuni, M. & Sikhakolli, S. M. Tomato Leaves Disease Classification Using
    Vision Transformers and EfficientNet. In Proceedings of the International Conference on Intelligent Systems and Digital
    Transformation (ICISD 2025), Chennai, India, 308–320. (Atlantis Press, 2025). h t t p s : / / d o i . o r g / 1 0 . 2 9 9 1 / 9 7 8 - 9 4 - 6 4 6 3 - 8 6
    6 - 0 _ 2 6
  14. Sun, Y ., Ning, L., Zhao, B. & Yan, J. Tomato leaf disease classification by combining EfficientNetv2 and a swin
    transformer. Appl. Sci. 14 (17), 7472. https://doi.org/10.3390/app14177472 (2024).
  15. Sun, H. et al. Efficient deep learning-based tomato leaf disease detection through global and local feature fusion. BMC
    Plant Biol. 25, 311. https://doi.org/10.1186/s12870-025-06247-w (2025).
  16. Ledbin Vini, S. & Rathika, P. Advanced state-of-the-art approaches in image processing techniques for plant leaf diseases
    analysis. Int. J. High Perform. Comput. Appl. 10943420251408184 https://doi.org/10.1177/10943420251408184 (2026).
  17. Jia, S. et al. ConvTransNet-S: A CNN-transformer hybrid disease recognition model for complex field environments.
    Plants 14 (15), 2252. https://doi.org/10.3390/plants14152252 (2025).
  18. Liu, J., Wang, X., Miao, W. & Liu, G. Tomato pest recognition algorithm based on improved YOLOv4. Front. Plant Sci.
    13, 814681. https://doi.org/10.3389/fpls.2022.814681 (2022).
  19. Jeong, S., Jeong, S. & Bong, J. Detection of tomato leaf miner using deep neural network. Sensors 22 (24), 9959. h t t p s :
    / / d o i . o r g / 1 0 . 3 3 9 0 / s 2 2 2 4 9 9 5 9 (2022).
  20. Wu, X., Zhan, C., Lai, Y . K., Cheng, M. M. & Yang, J. IP102: A large-scale benchmark dataset for insect pest recognition.
    In Proceedings of IEEE/CVF Conference Computer Vision and Pattern Recognition (CVPR) , pp. 8779–8788, (2019).
    https://doi.org/10.1109/CVPR.2019.00899
  21. Zhang, Z. et al. RPH-Counter: Field detection and counting of rice planthoppers using a fully convolutional network with
    object-level supervision. Comput. Electron. Agric. 225, 109242. https://doi.org/10.1016/j.compag.2024.109242 (2024).

Article in Press
Scientific Reports
https://doi.org/10.1038/s41598-026-66844-z
21. Zhang, Z. et al. Towards accurate field counting of small pests with visual prompts. Comput. Electron. Agric. 237 (Part
B), 110635. https://doi.org/10.1016/j.compag.2025.110635 (2025).
22. Cen, X., Lu, S. & Qian, T. YOLO-LCE: A Lightweight YOLOv8 model for agricultural pest detection. Agronomy 15 (9),
2025. https://doi.org/10.3390/agronomy15092022 (2022).
23. Liu, G., Di, J., Wang, Q., Zhao, Y . & Yang, Y . An enhanced and lightweight YOLOv8-based model for accurate rice pest
detection. IEEE Access 13, 91046–91064. https://doi.org/10.1109/ACCESS.2025.3569819 (2025).
24. Yan, L., Wang, S., Lee, H. & Yan, X. Efficient rice pest intelligent detection framework for field environments. AIP Adv.
15 (10), 105127. https://doi.org/10.1063/5.0296794 (2025).
25. Xie, J., Xie, X., Xie, W. & Xie, Q. An improved YOLOv8-based method for detecting pests and diseases on cucumber
leaves in natural backgrounds. Sensors 25 (5), 1551. https://doi.org/10.3390/s25051551 (2025).
26. Praharsha, C. H., Poulose, A. & Badgujar, C. Comprehensive investigation of machine learning and deep learning
networks for identifying multispecies tomato insect images. Sensors 24 (23), 7858. https://doi.org/10.3390/s24237858
(2024).
27. Muslih & Krismawan, A. D. Tomato leaf diseases classification using convolutional neural networks with transfer
learning Resnet-50. Kinetik: Game Technol. Inf. Syst. Comput. Netw. Comput. Electron. Control 9(2), 149–158. h t t p s : / / d
o i . o r g / 1 0 . 2 2 2 1 9 / k i n e t i k . v 9 i 2 . 1 9 3 9 (2024).
28. Gunasekaran, H., Rajkumar, S. & Kirubhadharsini, L. Lightweight deep learning for tomato disease detection: Trends,
challenges, and edge AI perspectives. Front. Plant Sci. 16, 1737208. https://doi.org/10.3389/fpls.2025.1737208 (2026).
29. He, K., Zhang, X., Ren, S. & Sun, J. Deep residual learning for image recognition. In Proceedings of the IEEE Conference
on Computer Vision and Pattern Recognition (CVPR), Las Vegas, NV , 770–778 (2016). h t t p s : / / d o i . o r g / 1 0 . 1 1 0 9 / C V P R . 2
0 1 6 . 9 0
30. Dosovitskiy, A. et al. An image is worth 16x16 words: Transformers for image recognition at scale. h t t p s : / / d o i . o r g / 1 0 . 4 8
5 5 0 / a r X i v . 2 0 1 0 . 1 1 9 2 9 (2020).
31. Vaswani, A. et al. Attention is all you need. In Proceeding of the Advances in Neural Information Processing Systems.
(NeurIPS), Long Beach, CA, vol. 30, 5998–6008 (2017).
32. Yan, H. et al. Hybrid-RViT: Hybridizing ResNet-50 and vision transformer for enhanced Alzheimer’s disease detection.
PLOS One 20 (2), e0318998. https://doi.org/10.1371/journal.pone.0318998 (2025).
33. Wang, Q. J. et al. Pest24: A large-scale very small object data set of agricultural pests for multi-target detection. Comput.
Electron. Agric. 175, 105585. https://doi.org/10.1016/j.compag.2020.105585 (2020).
34. Huang, M. L. & Chuang, T. C. A database of eight common tomato pest images. Mendeley Data. V1. h t t p s : / / d o i . o r g / 1 0 .
1 7 6 3 2 / s 6 2 z m 6 d j d 2 . 1 (2020).
Publisher’s note Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional
affiliations.
Authors and Affiliations
Mohammad Monirul Islam1,2 · Md. Anisur Rahman2 · Md. Masum Billah2 · Morium Akter1 ·
Mohammad Shorif Uddin1
Mohammad Monirul Islam
monirul@daffodilvarsity.edu.bd
1 Department of Computer Science and Engineering, Jahangirnagar University, Dhaka, Bangladesh
2 Department of Computer Science and Engineering, Daffodil International University, Dhaka, Bangladesh

论文原文与出版信息

Scientific Reports
查看论文原文

继续探索