Abstract:A lightweight YOLOv8n-based algorithm for PCB defect detection is proposed to address the trade-off between detection accuracy and model size. Firstly, the large target detection layer is deleted, the small target detection layer is added, and the network structure is adjusted to make the model lightweight and improve detection accuracy. Secondly, the C2f module is combined with GhostConv and DWConv to design the C2f-GhostD module to replace the C2f module, reducing the computational cost of the model. Then, PConv is integrated into the Detect module, resulting in the POne-Detect module, which is applied to the detection network to streamline its structure. Finally, the SimAM attention mechanism is added to the neck network to improve information capture ability. The experimental results show that in the PCB dataset, compared with YOLOv8n, the proposed algorithm reduces the number of parameters by 78.7%, reduces the model size by 73.7%, and improves the mAP0.5 to 98.6%, meeting the hardware deployment requirements of the model.