# A New Hybrid ConvViT Model for Dangerous Farm Insect Detection
## 5 Conclusions  
This study introduces a novel hybrid ConvViT model, combining convolutional neural networks (CNNs) and vision transformers (ViTs) to enhance the detection and classification of harmful agricultural pests. These pests significantly impact crop yields and global food security and necessitate accurate and efficient detection methods to support sustainable agricultural practices. The ConvViT model effectively addresses the limitations of traditional machine learning and transfer learning-based approaches by integrating local feature extraction and global context understanding within a single architecture. Although widely adopted, transfer learning models such as ResNet-50, DenseNet201, and VGG-16 often have limitations in handling datasets with high intra-class similarity and environmental variability. These models primarily rely on localized feature extraction, limiting their ability to capture long-range dependencies, which are crucial for distinguishing between pest species with subtle morphological differences. For instance, VGG-16 achieved a relatively low accuracy of 76.94%, highlighting its limited generalization capacity. Despite their advancements, even EfficientNetB0 and the standalone ViT reported accuracies of 90.27% and 90.55%, respectively, underscoring the need for more robust solutions. In contrast, the proposed ConvViT model achieved a superior accuracy of 93.61%, demonstrating its capability to effectively integrate CNNs' local pattern recognition strengths with ViTs' self-attention mechanisms for capturing global relationships. This hybrid approach outperformed all compared models' accuracy and showed better generalization, with consistent training and testing performance. \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Study** & **Proposed Algorithm** & **Dataset** & **Performance** \\ \hline [PERSON] et al. [8] & Xception & Dangerous Farm Insect & 83.99\% accuracy \\ \hline [PERSON] et al. [10] & Custom CNN & Dangerous Farm Insect & 92\% accuracy \\ \hline \hline \end{tabular}
\begin{tabular}{c c c} \hline \hline \multicolumn{1}{c}{} & 93.61\% accuracy, \\  & & 93.96\% precision, \\  & & 93.61\% recall, \\  & & 93.55\% F-score \\ \hline \hline \end{tabular}
\end{table} 
Table 10: Comparison of the proposed method with previous studies. The ConvViT model's strengths lie in its ability to process complex agricultural datasets, balancing precision and recall across multiple classes. For instance, the F-scores for critical pest classes such as armyworms (Class 3) and corn borers (Class 8) reached 1.0, indicating perfect classification. Furthermore, the model exhibited minimal overfitting, as seen from the closely aligned training and testing loss curves, reinforcing its reliability for practical deployment in agricultural settings. ViTs are known to be computationally intensive, especially compared to traditional CNNs. While the self-attention mechanism in ViTs is powerful for capturing global relationships, it requires significant computational resources, especially for large-scale datasets or high-resolution images. In our work, we alleviate this problem to some extent by combining a ViT with a CNN, thereby reducing the computational burden compared to a standalone ViT model. However, the hybrid ConvViT model may still require significant computational resources, especially for training on larger datasets or real-time applications. Although ConvViT has shown successful results in controlled experimental settings, its practical application in real-world agricultural environments may face difficulties. For example, agricultural environments often have variable light conditions, occlusions, and diverse backgrounds, which may affect the performance of the model. Additionally, using the model on edge devices (e.g., drones or mobile systems) for real-time pest monitoring may require further optimization to reduce the computational and memory requirements of the model. The current study was conducted on a dataset consisting of 15 insect species.