Focusing on the challenges of vehicle detection in foggy weather, especially the algorithm of low accuracy caused by small and incomplete targets in adverse weather conditions, a foggy weather vehicle detection algorithm based on improved lightweight YOLOv8 was proposed. Firstly, the dataset was processed through a combination of data transformation, Dehaze Formers and dark channel preprocessing. Secondly, in the main body of YOLOv8, the C2f component was replaced with the dynamic convolution C2f- DCN, enhancing its adaptability to geometric changes in the image. To further improve the detection performance of the classifier, an improved S5attention module based on S2-MLP was introduced. This module utilizes contextual information to capture long-range dependencies and assign weights to different channels based on their relevance to the task at hand. By considering non-local features, the S5attention module helps the model better capture important spatial relationships within the image. Additionally, the feature extraction module was updated to FasterNext, improving the differential convolution's feature extraction capabilities. The Involution module was also introduced to reduce FLOPs during feature channel fusion and reduce the model's parameter count. Experimental results show that on the RESIDE foggy weather dataset, the improved algorithm has an mAP50 increase of 4.1% compared with the original algorithm, and the model's parameter quantity is only 9.06m, with a computational cost reduced from 28.7G to 28.1G. The research model in this article will provide technical support for detecting vehicle targets in foggy weather, ensuring fast and accurate operation.