Abstract:There is a trade-off between the lightweight nature of YOLO algorithm models and maintaining detection accuracy. To address the task of detecting small defects in printed circuit boards (PCBs), we propose a lightweight object detection algorithm based on an improved YOLOv8s. This approach significantly reduces the number of parameters and model size while enhancing detection accuracy. Firstly, we introduce a lightweight Cross-Scale Feature Fusion Module (CCFM) and remove the final convolutional layer and C2f layer from the backbone network, reducing model depth and improving the detection accuracy of small objects while achieving model lightweighting. Secondly, we introduce Distribution Shifting Convolution (DSConv), combining C2f and DSConv to create the C2f_DSConv module, which is then integrated with the lightweight attention mechanism CBAM (Convolutional Block Attention Module) to design the C2f_DSConv_CBAM module. This module replaces the C2f components in both the backbone and neck networks, further reducing the number of model parameters and enhancing feature extraction capability. Finally, by combining the auxiliary bounding box loss functions Inner-IoU, the bounding box focal loss function Focal IoU Loss, and the original bounding box loss function CIoU, we design the Focal Inner-CIoU. This introduces a controllable auxiliary bounding box to calculate localization loss, improving the regression contribution of high IoU bounding boxes and ultimately enhancing detection accuracy. Experimental results show that compared to the original YOLOv8s model, the improved model reduces the number of parameters by 81.5%, computation by 21.3%, and model size by 72.3%, while increasing mAP by 3.0%. This effectively lowers the computational cost of the algorithm, making it more suitable for practical applications and deployment.