# A New Hybrid ConvViT Model for Dangerous Farm Insect Detection
## 4 The Experimental Results
CNN-based models VGG-16, ResNet-50, DenseNet201, and EfficientNetB0 mainly learn local features to detect specific patterns or local textures of insects, but these models may need to be improved in terms of learning global relationships. Transformer models such as the ViT and ConvVit extract the global context by modeling  
Figure 10: The confusion matrix for ConvViT. \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Class** & **Accuracy** & **Precision** & **Recall** & **F-Score** \\ \hline \hline \multicolumn{3}{c}{Africanized honey bees (Class 1)} & 0.9473 & 0.7500 & 0.8372 \\ \hline \hline \multicolumn{3}{c}{Aphids (Class 2)} & 0.9565 & 0.9166 & 0.9361 \\ \hline \hline \multicolumn{3}{c}{Armyworms (Class 3)} & 1.0000 & 1.0000 & 1.0000 \\ \hline \multicolumn{3}{c}{Brown marmorated stink bugs (Class 4)} & 0.9565 & 0.9166 & 0.9361 \\ \hline \hline \multicolumn{3}{c}{Cabbage loopers (Class 5)} & 0.9000 & 0.7500 & 0.8181 \\ \hline \hline \multicolumn{3}{c}{Citrus canker (Class 6)} & 0.8888 & 1.0000 & 0.9411 \\ \hline \hline \multicolumn{3}{c}{Colorado potato beetles (Class 7)} & 0.7407 & 0.8333 & 0.7843 \\ \hline \hline \multicolumn{3}{c}{Corn borers (Class 8)} & 1.0000 & 1.0000 & 1.0000 \\ \hline \hline \multicolumn{3}{c}{Corn earworms (Class 9)} & 1.0000 & 0.9583 & 0.9787 \\ \hline \hline \multicolumn{3}{c}{Fall armyworms (Class 10)} & 1.0000 & 1.0000 & 1.0000 \\ \hline \hline \multicolumn{3}{c}{Fruit flies (Class 11)} & 0.8888 & 1.0000 & 0.9411 \\ \hline \hline \multicolumn{3}{c}{Spider mites (Class 12)} & 0.8571 & 1.0000 & 0.9230 \\ \hline \hline \multicolumn{3}{c}{Thrips (Class 13)} & 1.0000 & 0.9583 & 0.9787 \\ \hline \hline \multicolumn{3}{c}{Tomato hornworms (Class 14)} & 1.0000 & 1.0000 & 1.0000 \\ \hline \hline \multicolumn{3}{c}{Western corn rotoworms (Class 15)} & 0.9583 & 0.9583 & 0.9583 \\ \hline \hline \multicolumn{3}{c}{Weighted average} & 0.9361 & 0.9396 & 0.9361 & 0.9355 \\ \hline \hline \end{tabular}
\end{table} 
Table 8: Classification report for ConvViT. long-range correlations on the image. ConvViT combines the local information extraction power of a CNN and the global relationship learning capacity of a transformer. This hybrid structure effectively classifies agricultural pest insects to understand small details and general shapes or relationships. ConvViT first learns local features from the input image with the help of the convolution layer. The learned features are presented to the vision transformer, and thus, local details are obtained before extracting the global context. Sometimes, a general unified view of details such as wings, body structure, or color distribution is needed in insect classification. ConvViT learns these details with convolution layers and can learn the relationship between these details and the vision transformer component. Figure 12 shows that VGG-16's training accuracy increased faster than its test accuracy, but and test accuracy increased more slowly. ResNet-50's training and test accuracies were balanced, but since the test accuracy did not increase further after a certain point, the generalization capacity of the model is limited. DenseNet201's training accuracy increased faster than its test accuracy. Its test accuracy showed a consistent increase. EfficientNetB0's training and test accuracies were parallel, indicating the model has good generalization performance. The ViT's training accuracy increased faster, while its test accuracy increased slowly. ConvViT's training and test accuracies increased in quite a balanced manner. ConvViT's generalization was successful on the training and test sets, and overfitting was very low during learning. Since the test accuracy graph showed a very smooth increase, ConvViT's performance was stable. Figure 11: Comparative analysis of experimental results.