Agriculture is the source of food, clothing, and the foundation of human existence. In recent years, various countries have been increasing investment in agricultural production and actively carrying out agricultural pest control work. Therefore, how effectively realizing pest identification is a top priority at present. Traditional identification methods have disadvantages, such as time-consuming and laborious, untimely diagnosis, and limited diagnosis range. With the development of modern digital technology, image processing technology develops rapidly, which opens up a new way for pest identification. This paper proposes an improved network model for pest identification using the YOLOv5 target detection algorithm. Firstly, the data sets of pests and diseases are collected and marked. Then, an improved anchor frame size is proposed to make it more suitable for the data set used in this paper. Finally, an improved network structure of YOLOv5 is proposed, which improves the ability of the network to capture characteristic information. The experimental results show that the mean Average Precision (mAP@0.5) of the improved network model reaches 79.7%. At the same time, compared with Faster R-CNN, Dynamic R-CNN, Double-Head R-CNN, YOLOv3, and YOLOv5, the mAP@0.5 is improved by 8.5%, 8.1%, 8.8%, 9.3%, and 3.7% respectively.