Abstract:To address the challenges of existing PCB defect detection models, which suffer from excessive parameters, high computational complexity, and limited deploy ability on industrial edge devices with constrained computing resources, we propose a lightweight defect detection algorithm based on STR-DETR. First, we construct a novel backbone network, G-StarNet, by integrating group convolution into the lightweight StarNet architecture. This modification significantly reduces model complexity while preserving multi-scale feature extraction capabilities. Second, within the adaptive feature interaction module, a statistical feature-based self-attention mechanism replaces the conventional multi-head self-attention, effectively lowering computational overhead. Third, the RetBlockC3 module is designed by combining the Manhattan self-attention mechanism and its decomposed form. By incorporating a distance-dependent attenuation strategy, this module prioritizes local feature representation and reduces computational complexity from quadratic to linear scaling. Finally, we introduce a new loss function, FSN Loss, which mitigates the adverse effects of shape/scale variations and imbalanced sample distributions on bounding box regression, thereby enhancing both localization and classification accuracy. Experimental results demonstrate that the improved algorithm achieves an mAP@0.5 of 96.7%. Compared with the baseline model, it reduces parameters by 50.8%, computational load by 55.4%, and increases detection speed by 23.7%. These findings validate the algorithm’s effectiveness in meeting the requirements of lightweight small-target detection tasks.