# A Hybrid Deep Learning Approach for Cotton Plant Disease Detection Using BERT-ResNet-PSO
## 3 The Proposed Hybrid Deep Learning Approach  
### Proposed Approach  
The proposed hybrid deep learning approach combines a BERT-based encoder, ResNet for feature mapping, and Particle Swarm Optimization (PSO) for effective segmentation and feature extraction of cotton leaf images. This approach is designed to accurately detect and classify diseases in cotton leaves by taking advantage of BERT's contextual understanding and ResNet's powerful feature mapping capabilities. BERT for image segmentation using a Vision Transformer (ViT)-inspired approach. It begins by dividing input images into fixed-size patches, which are then linearly embedded and enhanced with positional encodings to preserve spatial relationships. These embedded patches are treated as a sequence--similar to text tokens--and passed through transformer layers that apply self-attention to capture dependencies across different regions of the image. Finally, a segmentation head interprets the output embeddings to generate a pixel-wise classification mask that highlights diseased areas. This approach effectively leverages transformer-based spatial reasoning for accurate and context-aware image segmentation. Figure 1 presents a visual analysis of various leaf conditions, including a comparison between a normal, healthy leaf and three abnormal conditions: red spots, white spots, and leaf crumpling. These conditions indicate different forms of leaf diseases or environmental stresses affecting the plant. The images illustrate the distinctions between the healthy and affected leaves, potentially for the purpose of identifying or diagnosing plant health issues. Figure 2 shows a multi-step machine-learning framework for classifying cotton leaf images. First, all cotton leaf images are input, preceded by pre-processing to guarantee the quality of the data and their consistency. The process starts with the first stage, a BERT-based segmentation model, to segment leaf images into patches and generate a segmentation mask. After this segmentation, the mask is fed into a ResNet model; it extracts relevant features of not only the mask itself but also of the original image. Further,  
\begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Study** & **Model(s) Used** & **Techniques** & **Dataset Size** & **Accuracy (\%)** & **Comments** & **Limitations** \\ \hline \hline \multirow{4}{*}{ \begin{tabular}{c} [PERSON] et al. \\ [22] \\ \end{tabular}  } & \multirow{4}{*}{VGG16} & Data & \multirow{4}{*}{ \begin{tabular}{c} Two Kaggle \\ Feature \\ Extraction \\ \end{tabular}  } & & Uses \(11\) fully & \begin{tabular}{c} Very high accuracy \\ may indicate \\ overfitting and \\ real-world \\ performance may \\ differ. Limited \\ generalizability \\ across datasets. \\ \end{tabular}  } \\ \hline [PERSON] [23] & \begin{tabular}{c} Faster R-CNN \\ with Region \\ Proposal \\ Network (RPN) \\ \end{tabular}  & Advanced & \multirow{4}{*}{4000+ images} & Faster R-CNN & Limited dataset \\  & & & combined with & diversity and may \\  & & & version of Fast & RPN for faster, & struggle with small \\  & & & R-CNN & & cost-free region & or occluded objects in \\  & & & & proposals. & real-world scenarios. \\ \hline \multirow{4}{*}{ \begin{tabular}{c} [PERSON] \& \\ [PERSON] [24] \\ \end{tabular}  } & ResNet152V2, & \multirow{4}{*}{\ \begin{tabular}{c} Transfer \\ Learning \\ \end{tabular}  } & \multirow{4}{*}{Not specified} & \multirow{4}{*}{VGG16: 95.02} & \multirow{4}{*}{ \begin{tabular}{c} Tested multiple \\ Deep CNNs on \\ a dataset with \\ diverse \\ conditions. \\ \end{tabular}  } & Dataset size and \\  & & & &Particle Swarm Optimization (PSO) is applied to optimize the ResNet model, further improving model performance. In the next step, a scheme in which several models are combined using weighted voting, with the combination weights determined by the author's experience, is used to combine multiple models based on the strengths of single models to achieve higher accuracy.