In order to solve the problem of low image identification accuracy of Trichagalma glabrosa insect gall pests in a complex natural environment, an image identification method of Trichagalma glabrosa insect gall pests based on YOLOv5s was designed and introduced in this study. The original images were preprocessed with the grayscale maximum method and different gradients of noise, which reduced the color difference interference with complex backgrounds and improved the image identification rate. A total of 6090 images of insect gall pests under opposite light, back light, and complex backgrounds were constructed, which were divided into a training set and a test set with a ratio of 7 : 3. The results showed that the precision, recall, and mean average precision of YOLOv5s were 94.35%, 95.42%, and 95.8%, respectively. YOLOv5s, YOLOv4, and Faster-RCNN were compared and analyzed under the same test conditions. The identification accuracy of YOLOv5s was higher than that of YOLOv4 and Faster-RCNN, and its model size was only 13.8 MB. It was considered that the designed YOLOv5s method could help accurately and quickly identify Trichagalma glabrosa insect gall pests with high identification accuracy and a small model capacity, which was more conducive to the migration application of the model, and provide a new method for the rapid identification of Trichagalma glabrosa insect gall pests in a complex natural environment.