| Forest pest invasions can cause significant damage,leading to a decline in forest product quality,severely impacting economic life,and even worsening the ecological environment.In the process of protecting forest resources and forestry production,pest monitoring is an essential step.Forest pest detection provides data support for pest monitoring and is a critical link in pest monitoring.This paper establishes improved models based on YOLOv4 for forest pest detection from two perspectives: lightweight and high-precision.The content of this paper is as follows:(1)Based on the single-stage object detection YOLOv4,a lightweight forest pest detection model is established using lightweight improvement strategies.The Kmeans++ algorithm is used to optimize the prior box size;depthwise separable convolution is combined with the CSP structure in the CSPDarknet-53 backbone network to construct the DSC-CSP module,enhancing network feature extraction capabilities and reducing model parameters and computational complexity.The SPPF module is used to replace the SPP module,ensuring the same computational effect and reducing module parameters and computational complexity by concatenating the maximum pooling layers.To address the issue of small,similar-colored forest pest detection targets,which causes the model to detect significantly more background pixels than target pixels and has a high error rate in detecting model categories,the Focal Loss is adopted.This balances the positive and negative sample ratios while making the model focus more on learning difficult-to-distinguish samples.Experimental results show that the improved lightweight YOLOv4-based forest pest detection model has an m AP of 88.6%,a model parameter size of 47.68 M,and an FPS of 48.6 f/s.(2)Based on the single-stage object detection algorithm YOLOv4,with highprecision detection as the goal,a target detection model suitable for the characteristics of forest pest detection tasks is established.CBAM attention mechanism is combined with ECA attention mechanism to construct ECA-CBAM,which improves the calculation speed and effectiveness of the attention module,and is introduced into the CSPDarknet-53 backbone network;the network neck is reorganized.An additional SPPF module is introduced based on the SPPF replacement SPP module,constructing SPPF-PANet,which fuses the feature information captured by multiple receptive fields and alleviates gradient vanishing.The Class-balanced Focal Loss is used to improve the loss function,which,based on the advantages of the Focal Loss,alleviates the low detection accuracy of pest categories with few training samples and improves the accuracy loss caused by uneven sample distribution.Experimental results show that the improved high-precision YOLOv4-based forest pest detection model has an m AP of90.7%,a 4.4% improvement over YOLOv4,and an FPS of 34.6 f/s.(3)A forest pest detection system based on the improved YOLOv4 model is developed,consisting of five modules: user management,image management,detection result management,forest pest detection,and detection result analysis.In terms of software development,the system adopts the Python-based GUI development framework Py Qt5,featuring cross-platform compatibility and ease of use.The forest pest detection system provides a feasible solution and practical experience for precise,intelligent,and efficient forest pest detection. |