Instance-level localization and similarity-aware contrastive learning for robust plant disease classification
Abstract
Introduction Plant disease classification in real-field images remains challenging due to complex backgrounds, overlapping leaves, multiple symptomatic regions, and visually similar disease categories. Conventional image based classifiers may therefore learn mixed representations in which disease-specific cues are confused with healthy tissue, background information, or co-occurring symptoms. Method To address these challenges, this paper proposes an instance-aware and similarity-aware framework for plant disease classification. The proposed method first localizes disease using a lightweight YOLOv8n detector trained with coarse localization labels. Then patches corresponding to the localized regions are extracted and provided as input to hybrid CNN–Transformer architecture, where ResNet-18 captures fine-grained local lesion features and the transformer branch models broader contextual dependencies. These complementary representations are integrated through cross-attention fusion and projected into a shared embedding space. To improve inter-class separability, dynamically updated class prototypes are used to identify visually confusable disease pairs, and a Similarity-Weighted Contrastive Loss is introduced to put separation pressure on confused class boundaries. A decorrelation regularization term is further incorporated to reduce redundancy in the learned embeddings. Result Experiments on the re-annotated DiaMOS Plant leaf dataset, evaluated under a source-image-level partitioning protocol that keeps all patches from the same field image within a single data partition, show that the proposed framework achieves 97.49 ± 0.73% accuracy and 94.82 ± 0.81% macro F1-score on a locked hold-out test set, significantly outperforming reimplemented baseline methods evaluated under the same experimental protocol (p < 0.001). Discussion Embedding-space visualization using t-SNE and the normalized confusion matrix further demonstrate improved class separation and reliable prediction behavior across the four disease categories.