With the advancement of society, ensuring the safety of personnel involved in municipal construction projects, particularly in the context of pandemic control measures, has become a matter of utmost importance. Municipal engineering projects, distinct from other types of engineering endeavors, often unfold within urban environments, are characterized by extended durations, encompass a range of outdoor activities, and are susceptible to the influence of factors such as concurrent operations, traffic, climate, and environmental conditions. Consequently, the approach to safety management in municipal engineering necessitates unique considerations. This paper introduces a method that combines deep learning and target detection technology to propose a lightweight artificial intelligence (AI) detection method capable of simultaneously identifying mask-wearing and safety helmet-wearing individuals. The method primarily incorporates the ShuffleNetv2 feature extraction mechanism within the framework of the YOLOv5s network to reduce computational overhead. Additionally, it employs the ECA attention mechanism and optimized loss functions to generate feature maps with more comprehensive information, thereby enhancing the precision of target detection. Experimental results indicate that this algorithm improves the mean Average Precision (mAP) value by 4.3%. Furthermore, it reduces parameter and computational loads by 54.8% and 53.8%, respectively, effectively striking a balance between lightweight operation and precision. This study serves as a valuable reference for research pertaining to lightweight target detection in the realm of municipal construction safety measures.