The damage caused by pests to crops results in reduced crop yield and compromised quality. Accurate and timely pest detection plays a crucial role in helping farmers to defend against and control pests. In this paper, a novel crop pest detection model named YOLOv5s-pest is proposed. Firstly, we design a hybrid spatial pyramid pooling fast (HSPPF) module, which enhances the model’s capability to capture multi-scale receptive field information. Secondly, we design a new convolutional block attention module (NCBAM) that highlights key features, suppresses redundant features, and improves detection precision. Thirdly, the recursive gated convolution (g3Conv) is introduced into the neck, which extends the potential of self-attention mechanism to explore feature representation to arbitrary-order space, enhances model capacity and detection capability. Finally, we replace the non-maximum suppression (NMS) in the post-processing part with Soft-NMS, which improves the missed problem of detection in crowded and dense scenes. The experimental results show that the mAP@0.5 (mean average precision at intersection over union (IoU) threshold of 0.5) of YOLOv5s-pest achieves 92.5% and the mAP@0.5:0.95 (mean average precision from IoU 0.5 to 0.95) achieves 72.6% on the IP16. Furthermore, we also validate our proposed method on other datasets, and the outcomes indicate that YOLOv5s-pest is also effective in other detection tasks.