For a variety of crop disease and pest images, it is difficult to achieve satisfactory accuracy due to the technical problems of various diseases and pests and similar characteristics of small targets in the natural environment. In this study, a pest detection and identification model, namely YOLOv5-EB that enhances the fusion of local feature and global feature information in the natural background is proposed, and experiments are carried out on the published large-scale pest dataset IP102. The results show that the accuracy of this study is improved by five percentage points compared with the YOLOv5 model. The MLP operation of replacing channel attention in CBAM with one-dimensional convolution is introduced, which optimizes the problem that channel attention is easy to ignore the information interaction in the channel after global processing. Secondly, the Focus operation is replaced by 6×6 convolution to enhance the ability to extract pest features. The experimental results show that the average accuracy of YOLOv5-EB reaches 87% in detecting pests, which not only effectively improves the identification performance of crop pest images but also increases the detection speed compared with Faster R-CNN, EfficientDet, YOLOv3, YOLOv4, and YOLOv5 models. The study reveals that the YOLOv5-EB algorithm meets the accuracy and real-time requirements of target detection of various crop diseases and pests.