Aiming at the current challenges of vehicle detection algorithms, such as complex models, large parameter sizes, and high requirements for hardware calculation, this paper introduces a lightweight improved YOLOv5 algorithm, which maintains high accuracy while remarkably reducing the number of model parameters. Firstly, the Ghost lightweight module is adopted to reconstruct the backbone network, reducing model parameters and enhancing inference speed. Subsequently, simAM, a parameter-free attention module, is incorporated into the neck network to improve algorithm accuracy and suppress environmental interference. Finally, the NMS algorithm is improved into DioU-NMS, combining the penalty term and centroid distance to minimize the probability of miss. The experimental results indicate that, compared with the original YOLOv5s algorithm, the proposed algorithm showcases a mere 0.8% reduction in the average precision (AP) value, the model parameters are dropped by 48%, and the computational workload is decreased by 49.7%, realizing the lightweight of the algorithm.