Aiming at the problem of easy misdetection and omission of small targets of long-distance vehicles in detecting vehicles in traffic scenes, an improved YOLOX_S detection model is proposed. Firstly, the redundant part of the original YOLOX_S network structure is clipped using the model compression strategy, which improves the model inference speed while maintaining the detection accuracy; secondly, the Resunit_CA structure is constructed by incorporating the coordinate attention module in the residual structure, which reduces the loss of feature information and improves the attention to the small target features; thirdly, in order to obtain richer small target features, the PAFPN structure tail to add an adaptive feature fusion module, which improves the model detection accuracy; finally, the loss function is optimized in the decoupled head structure, and the Focal Loss loss function is used to alleviate the problem of uneven distribution of positive and negative samples. The experimental results show that compared with the original YOLOX_S model, the improved model proposed in this paper achieves an average detection accuracy of 77.19% on this experimental dataset. However, the detection speed decreases to 29.73 fps, which is still a large room for improvement in detection in real-time. According to the visualization experimental results, it can be seen that the improved model effectively alleviates the problems of small-target missed detection and multi-target occlusion.